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

Misc pyverbs tests fixes round 2 #780

Merged
merged 5 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyverbs/cq.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ cdef class CQ(PyverbsCM):
"""
rc = v.ibv_req_notify_cq(self.cq, solicited_only)
if rc != 0:
raise PyverbsRDMAErrno('Request notify CQ returned {rc}'.
format(rc=rc))
raise PyverbsRDMAError('Request notify CQ returned {rc}'.
format(rc=rc), rc)

def ack_events(self, num_events):
"""
Expand Down
1 change: 1 addition & 0 deletions pyverbs/libibverbs_enums.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cdef extern from '<infiniband/verbs.h>':
IBV_NODE_RNIC
IBV_NODE_USNIC
IBV_NODE_USNIC_UDP
IBV_NODE_UNSPECIFIED

cpdef enum:
IBV_LINK_LAYER_UNSPECIFIED
Expand Down
3 changes: 3 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def _add_gids_per_port(self, ctx, dev, port):
ctx.query_gid_type(port, idx) == e.IBV_GID_TYPE_ROCE_V2 and \
has_roce_hw_bug(vendor_id, vendor_pid):
continue
if not os.path.exists('/sys/class/infiniband/{}/device/net/'.format(dev)):
self.args.append([dev, port, idx, None])
continue
net_name = self.get_net_name(dev)
try:
ip_addr = self.get_ip_address(net_name)
Expand Down
13 changes: 8 additions & 5 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from tests.base import PyverbsAPITestCase
import tests.utils as u
import pyverbs.device as d
import pyverbs.enums as e

PAGE_SIZE = resource.getpagesize()

Expand Down Expand Up @@ -60,7 +61,7 @@ def test_query_device(self):
for dev in self.get_device_list():
with d.Context(name=dev.name.decode()) as ctx:
attr = ctx.query_device()
self.verify_device_attr(attr)
self.verify_device_attr(attr, dev)

def test_query_gid(self):
"""
Expand All @@ -71,15 +72,17 @@ def test_query_gid(self):
ctx.query_gid(port_num=1, index=0)

@staticmethod
def verify_device_attr(attr):
def verify_device_attr(attr, device):
"""
Helper method that verifies correctness of some members of DeviceAttr
object.
:param attr: A DeviceAttr object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the device param to the docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

:param device: A Device object
:return: None
"""
assert attr.node_guid != 0
assert attr.sys_image_guid != 0
if device.node_type != e.IBV_NODE_UNSPECIFIED and device.node_type != e.IBV_NODE_UNKNOWN:
assert attr.node_guid != 0
assert attr.sys_image_guid != 0
assert attr.max_mr_size > PAGE_SIZE
assert attr.page_size_cap >= PAGE_SIZE
assert attr.vendor_id != 0
Expand All @@ -101,7 +104,7 @@ def test_query_device_ex(self):
for dev in self.get_device_list():
with d.Context(name=dev.name.decode()) as ctx:
attr_ex = ctx.query_device_ex()
self.verify_device_attr(attr_ex.orig_attr)
self.verify_device_attr(attr_ex.orig_attr, dev)

@staticmethod
def verify_port_attr(attr):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_mr.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ def test_reg_mw_wrong_type(self):
try:
mw_type = random.randint(3, 100)
MW(pd, mw_type)
except PyverbsRDMAError:
pass
except PyverbsRDMAError as ex:
if ex.error_code == errno.EOPNOTSUPP:
raise unittest.SkipTest('Create memory window of type {} is not supported'.format(mw_type))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use f-strings in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

else:
raise PyverbsError('Created a MW with type {t}'.\
format(t=mw_type))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_qp.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_query_qp(self):
if ex.error_code == errno.EOPNOTSUPP:
raise unittest.SkipTest('Create QP with extended attrs is not supported')
raise ex
qp_attr, qp_init_attr = qp.query(e.IBV_QP_CUR_STATE |
qp_attr, qp_init_attr = qp.query(e.IBV_QP_STATE |
e.IBV_QP_CAP)
verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
qp_attr)
Expand All @@ -257,7 +257,7 @@ def test_query_qp(self):
qia.qp_type = qpt
caps = qia.cap # Save them to verify values later
qp = QP(pd, qia)
qp_attr, qp_init_attr = qp.query(e.IBV_QP_CUR_STATE |
qp_attr, qp_init_attr = qp.query(e.IBV_QP_STATE |
e.IBV_QP_CAP)
verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
qp_attr)
Expand Down