Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: test_device: Fix the use of get_device_list() #1546

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ def test_query_gid_table(self):
"""
Test ibv_query_gid_table()
"""
devs = self.get_device_list()
with d.Context(name=devs[0].name.decode()) as ctx:
device_attr = ctx.query_device()
max_entries = 0
for port_num in range(1, device_attr.phys_port_cnt + 1):
port_attr = ctx.query_port(port_num)
max_entries += port_attr.gid_tbl_len
try:
if max_entries > 0:
ctx.query_gid_table(max_entries)
except PyverbsRDMAError as ex:
if ex.error_code in [-errno.EOPNOTSUPP, -errno.EPROTONOSUPPORT]:
raise unittest.SkipTest('ibv_query_gid_table is not'\
' supported on this device')
raise ex
for dev in self.get_device_list():
with d.Context(name=dev.name.decode()) as ctx:
device_attr = ctx.query_device()
max_entries = 0
for port_num in range(1, device_attr.phys_port_cnt + 1):
port_attr = ctx.query_port(port_num)
max_entries += port_attr.gid_tbl_len
try:
if max_entries > 0:
ctx.query_gid_table(max_entries)
except PyverbsRDMAError as ex:
if ex.error_code in [-errno.EOPNOTSUPP, -errno.EPROTONOSUPPORT]:
raise unittest.SkipTest('ibv_query_gid_table is not'\
' supported on this device')
raise ex

def test_query_gid_table_bad_flow(self):
"""
Expand All @@ -134,17 +134,17 @@ def test_query_gid_ex(self):
"""
Test ibv_query_gid_ex()
"""
devs = self.get_device_list()
with d.Context(name=devs[0].name.decode()) as ctx:
try:
gid_tbl_len = ctx.query_port(self.ib_port).gid_tbl_len
if gid_tbl_len > 0:
ctx.query_gid_ex(port_num=self.ib_port, gid_index=0)
except PyverbsRDMAError as ex:
if ex.error_code in [errno.EOPNOTSUPP, errno.EPROTONOSUPPORT]:
raise unittest.SkipTest('ibv_query_gid_ex is not'\
' supported on this device')
raise ex
for dev in self.get_device_list():
with d.Context(name=dev.name.decode()) as ctx:
try:
gid_tbl_len = ctx.query_port(self.ib_port).gid_tbl_len
if gid_tbl_len > 0:
ctx.query_gid_ex(port_num=self.ib_port, gid_index=0)
except PyverbsRDMAError as ex:
if ex.error_code in [errno.EOPNOTSUPP, errno.EPROTONOSUPPORT]:
raise unittest.SkipTest('ibv_query_gid_ex is not'\
' supported on this device')
raise ex

def test_query_gid_ex_bad_flow(self):
"""
Expand Down