Skip to content

Commit

Permalink
tests: Conditional verification of attributes in query device
Browse files Browse the repository at this point in the history
Skip verification of a few device attributes in case the node type is
unspecified/unknown.

The missing IBV_NODE_UNSPECIFIED enum value was added to
libibverbs_enums.pxd.

Signed-off-by: Chen Brasch <cbrasch@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
  • Loading branch information
Chen Brasch authored and gal-pressman committed Jun 30, 2020
1 parent 79f6e8e commit 20e13b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions pyverbs/libibverbs_enums.pxd
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
13 changes: 8 additions & 5 deletions tests/test_device.py
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
: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

0 comments on commit 20e13b0

Please sign in to comment.