Example #1
0
 def test_create_dm_bad_flow(self):
     """
     test ibv_alloc_dm() with an illegal size and comp mask
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr = ctx.query_device_ex()
             if attr.max_dm_size == 0:
                 return
             dm_len = attr.max_dm_size + 1
             dm_attrs = u.get_dm_attrs(dm_len)
             try:
                 dm = d.DM(ctx, dm_attrs)
             except PyverbsRDMAError as e:
                 assert 'Failed to allocate device memory of size' in e.args[
                     0]
                 assert 'Max available size' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a DM with size larger than max reported')
             dm_attrs.comp_mask = random.randint(1, 100)
             try:
                 dm = d.DM(ctx, dm_attrs)
             except PyverbsRDMAError as e:
                 assert 'Failed to allocate device memory of size' in e.args[
                     0]
             else:
                 raise PyverbsError('Created a DM with illegal comp mask {c}'.\
                                    format(c=dm_attrs.comp_mask))
Example #2
0
 def test_dm_write_bad_flow(self):
     """
     Test writing to the device memory with bad offset and length
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr = ctx.query_device_ex()
             if attr.max_dm_size == 0:
                 return
             dm_len = random.randrange(u.MIN_DM_SIZE, attr.max_dm_size,
                                       u.DM_ALIGNMENT)
             dm_attrs = u.get_dm_attrs(dm_len)
             with d.DM(ctx, dm_attrs) as dm:
                 data_length = random.randrange(4, dm_len, u.DM_ALIGNMENT)
                 data_offset = random.randrange(0, dm_len - data_length,
                                                u.DM_ALIGNMENT)
                 data_offset += 1  # offset needs to be a multiple of 4
                 data = u.get_data(data_length)
                 try:
                     dm.copy_to_dm(data_offset, data.encode(), data_length)
                 except PyverbsRDMAError as e:
                     assert 'Failed to copy to dm' in e.args[0]
                 else:
                     raise PyverbsError(
                         'Wrote to device memory with a bad offset')
Example #3
0
 def test_create_cq_ex_bad_flow():
     """
     Test ibv_create_cq_ex() with wrong comp_vector / number of cqes
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attrs_ex = get_attrs_ex(ctx)
             max_cqe = ctx.query_device().max_cqe
             attrs_ex.cqe = max_cqe + random.randint(1, 100)
             try:
                 CQEX(ctx, attrs_ex)
             except PyverbsError as e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with {c} CQEs while device\'s max CQE={dc}'
                     .format(c=attrs_ex.cqe, dc=max_cqe))
             comp_channel = random.randint(ctx.num_comp_vectors, 100)
             attrs_ex.comp_vector = comp_channel
             attrs_ex.cqe = get_num_cqes(ctx)
             try:
                 CQEX(ctx, attrs_ex)
             except PyverbsError as e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with comp_vector={c} while device\'s num_comp_vectors={dc}'
                     .format(c=comp_channel, dc=ctx.num_comp_vectors))
Example #4
0
 def test_open_dev():
     """
     Test ibv_open_device()
     """
     lst = d.get_device_list()
     for dev in lst:
         d.Context(name=dev.name.decode())
Example #5
0
 def test_query_gid():
     """
     Test ibv_query_gid()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             ctx.query_gid(port_num=1, index=0)
 def test_query_device(self):
     """
     Test ibv_query_device()
     """
     lst = d.get_device_list()
     for dev in lst:
         ctx = d.Context(name=dev.name.decode())
         ctx.query_device()
Example #7
0
 def test_dereg_mr(self):
     """ Test ibv_dereg_mr() """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 with MR(pd, u.get_mr_length(), u.get_access_flags()) as mr:
                     mr.close()
Example #8
0
 def test_open_dev():
     """
     Test ibv_open_device()
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         d.Context(name=dev.name.decode())
Example #9
0
 def test_dealloc_pd():
     """
     Test ibv_dealloc_pd()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 pd.close()
Example #10
0
 def test_create_comp_channel():
     """
     Test ibv_create_comp_channel()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CompChannel(ctx):
                 pass
Example #11
0
 def test_alloc_pd(self):
     """
     Test ibv_alloc_pd()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx):
                 pass
Example #12
0
 def test_destroy_cq_ex():
     """
     Test ibv_destroy_cq() for extended CQs
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CQEX(ctx, get_attrs_ex(ctx)) as cq:
                 cq.close()
Example #13
0
 def test_create_cq_ex():
     """
     Test ibv_create_cq_ex()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CQEX(ctx, get_attrs_ex(ctx)):
                 pass
Example #14
0
 def test_query_device_ex(self):
     """
     Test ibv_query_device_ex()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr_ex = ctx.query_device_ex()
             self.verify_device_attr(attr_ex.orig_attr)
Example #15
0
 def test_destroy_comp_channel():
     """
     Test ibv_destroy_comp_channel()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             cc = CompChannel(ctx)
             cc.close()
Example #16
0
 def test_multiple_pd_creation():
     """
     Test multiple creations and destructions of a PD object
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             for i in range(random.randint(1, 200)):
                 with PD(ctx) as pd:
                     pd.close()
Example #17
0
 def test_query_gid():
     """
     Test ibv_query_gid()
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             ctx.query_gid(port_num=1, index=0)
Example #18
0
 def test_dereg_mw(self):
     """ Test ibv_dealloc_mw() """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 with MW(pd,
                         random.choice([e.IBV_MW_TYPE_1,
                                        e.IBV_MW_TYPE_2])) as mw:
                     mw.close()
Example #19
0
 def test_dereg_mr_twice(self):
     """ Verify that explicit call to MR's close() doesn't fails """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 with MR(pd, u.get_mr_length(), u.get_access_flags()) as mr:
                     # Pyverbs supports multiple destruction of objects, we are
                     # not expecting an exception here.
                     mr.close()
                     mr.close()
Example #20
0
 def test_query_device_ex(self):
     """
     Test ibv_query_device_ex()
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr_ex = ctx.query_device_ex()
             self.verify_device_attr(attr_ex.orig_attr)
Example #21
0
 def setUp(self):
     """
     Opens the devices and queries them
     """
     lst = d.get_device_list()
     self.devices = []
     for dev in lst:
         c = d.Context(name=dev.name.decode())
         attr = c.query_device()
         attr_ex = c.query_device_ex()
         self.devices.append((c, attr, attr_ex))
Example #22
0
 def test_query_port(self):
     """
     Test ibv_query_port
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             num_ports = ctx.query_device().phys_port_cnt
             for p in range(num_ports):
                 port_attr = ctx.query_port(p + 1)
                 self.verify_port_attr(port_attr)
Example #23
0
 def test_buffer(self):
     """
     Test reading buf property
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 length = u.get_mr_length()
                 with MR(pd, length, u.get_access_flags()) as mr:
                     buf = mr.buf
Example #24
0
 def test_write(self):
     """
     Test writing to MR's buffer
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 mr_len = u.get_mr_length()
                 with MR(pd, mr_len, u.get_access_flags()) as mr:
                     write_len = min(random.randint(1, MAX_IO_LEN), mr_len)
                     mr.write(u.get_data(write_len), write_len)
Example #25
0
 def test_destroy_pd_twice():
     """
     Test bad flow cases in destruction of a PD object
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 # Pyverbs supports multiple destruction of objects, we are
                 # not expecting an exception here.
                 pd.close()
                 pd.close()
Example #26
0
 def test_query_port(self):
     """
     Test ibv_query_port
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             num_ports = ctx.query_device().phys_port_cnt
             for p in range(num_ports):
                 port_attr = ctx.query_port(p + 1)
                 self.verify_port_attr(port_attr)
 def get_device_list(self):
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB device found')
     dev_name = self.config['dev']
     if dev_name:
         for dev in lst:
             if dev.name.decode() == dev_name:
                 lst = [dev]
                 break
         if len(lst) == 0:
             raise PyverbsRDMAError(f'No IB device with name {dev_name} found')
     return lst
Example #28
0
 def setUp(self):
     """
     Opens the devices and queries them
     """
     lst = d.get_device_list()
     self.devices = []
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         c = d.Context(name=dev.name.decode())
         attr = c.query_device()
         attr_ex = c.query_device_ex()
         self.devices.append((c, attr, attr_ex))
Example #29
0
 def test_reg_mw_wrong_type(self):
     """ Test ibv_alloc_mw() """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 try:
                     mw_type = random.randint(3, 100)
                     mw = MW(pd, mw_type)
                 except PyverbsRDMAError as e:
                     pass
                 else:
                     raise PyverbsError('Created a MW with type {t}'.\
                                        format(t=mw_type))
Example #30
0
 def test_destroy_cq():
     """
     Test ibv_destroy_cq()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             cqes = get_num_cqes(ctx)
             comp_vector = random.randint(0, ctx.num_comp_vectors - 1)
             if random.choice([True, False]):
                 with CompChannel(ctx) as cc:
                     cq = CQ(ctx, cqes, None, cc, comp_vector)
             else:
                 cq = CQ(ctx, cqes, None, None, comp_vector)
             cq.close()