Exemplo n.º 1
0
 def test_create_dm_bad_flow(self):
     """
     test ibv_alloc_dm() with an illegal size and comp mask
     """
     dm_len = self.attr_ex.max_dm_size + 1
     dm_attrs = u.get_dm_attrs(dm_len)
     try:
         d.DM(self.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:
         d.DM(self.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))
Exemplo n.º 2
0
 def test_create_dm(self):
     """
     test ibv_alloc_dm()
     """
     dm_len = random.randrange(u.MIN_DM_SIZE, self.attr_ex.max_dm_size / 2,
                               u.DM_ALIGNMENT)
     dm_attrs = u.get_dm_attrs(dm_len)
     with d.DM(self.ctx, dm_attrs):
         pass
Exemplo n.º 3
0
 def test_destroy_dm(self):
     """
     test ibv_free_dm()
     """
     dm_len = random.randrange(u.MIN_DM_SIZE, self.attr_ex.max_dm_size / 2,
                               u.DM_ALIGNMENT)
     dm_attrs = u.get_dm_attrs(dm_len)
     dm = d.DM(self.ctx, dm_attrs)
     dm.close()
Exemplo n.º 4
0
 def test_destroy_dm_bad_flow(self):
     """
     Test calling ibv_free_dm() twice
     """
     dm_len = random.randrange(u.MIN_DM_SIZE, self.attr_ex.max_dm_size / 2,
                               u.DM_ALIGNMENT)
     dm_attrs = u.get_dm_attrs(dm_len)
     dm = d.DM(self.ctx, dm_attrs)
     dm.close()
     dm.close()
Exemplo n.º 5
0
 def test_destroy_dm(self):
     """
     test ibv_free_dm()
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             raise unittest.SkipTest('Device memory is not supported')
         dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size / 2,
                                   u.DM_ALIGNMENT)
         dm_attrs = u.get_dm_attrs(dm_len)
         dm = d.DM(ctx, dm_attrs)
         dm.close()
Exemplo n.º 6
0
 def test_create_dm(self):
     """
     test ibv_alloc_dm()
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             raise unittest.SkipTest('Device memory is not supported')
         dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size / 2,
                                   u.DM_ALIGNMENT)
         dm_attrs = u.get_dm_attrs(dm_len)
         with d.DM(ctx, dm_attrs):
             pass
Exemplo n.º 7
0
 def test_destroy_dm(self):
     """
     test ibv_free_dm()
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             return
         dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size / 2,
                                   u.DM_ALIGNMENT)
         dm_attrs = u.get_dm_attrs(dm_len)
         dm = d.DM(ctx, dm_attrs)
         dm.close()
Exemplo n.º 8
0
 def test_create_dm(self):
     """
     test ibv_alloc_dm()
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             return
         dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size / 2,
                                   u.DM_ALIGNMENT)
         dm_attrs = u.get_dm_attrs(dm_len)
         with d.DM(ctx, dm_attrs):
             pass
Exemplo n.º 9
0
 def test_dm_write(self):
     """
     Test writing to the device memory
     """
     dm_len = random.randrange(u.MIN_DM_SIZE, self.attr_ex.max_dm_size / 2,
                               u.DM_ALIGNMENT)
     dm_attrs = u.get_dm_attrs(dm_len)
     with d.DM(self.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 = 'a' * data_length
         dm.copy_to_dm(data_offset, data.encode(), data_length)
Exemplo n.º 10
0
 def test_dm_read(self):
     """
     Test reading from the device memory
     """
     dm_len = random.randrange(u.MIN_DM_SIZE, self.attr_ex.max_dm_size / 2,
                               u.DM_ALIGNMENT)
     dm_attrs = u.get_dm_attrs(dm_len)
     with d.DM(self.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 = 'a' * data_length
         dm.copy_to_dm(data_offset, data.encode(), data_length)
         read_str = dm.copy_from_dm(data_offset, data_length)
         assert read_str.decode() == data
Exemplo n.º 11
0
 def test_dm_write(self):
     """
     Test writing to the device memory
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             raise unittest.SkipTest('Device memory is not supported')
         dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size / 2,
                                   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 = 'a' * data_length
             dm.copy_to_dm(data_offset, data.encode(), data_length)
Exemplo n.º 12
0
 def test_create_dm_mr(self):
     """
     Test ibv_reg_dm_mr
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             raise unittest.SkipTest('Device memory is not supported')
         with PD(ctx) as pd:
             for i in range(10):
                 dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size/2,
                                           u.DM_ALIGNMENT)
                 dm_attrs = u.get_dm_attrs(dm_len)
                 with d.DM(ctx, dm_attrs) as dm:
                     dm_mr_len = random.randint(1, dm_len)
                     dm_mr_offset = random.randint(0, (dm_len - dm_mr_len))
                     DMMR(pd, dm_mr_len, e.IBV_ACCESS_ZERO_BASED, dm=dm,
                          offset=dm_mr_offset)
Exemplo n.º 13
0
 def test_destroy_dm_mr(self):
     """
     Test freeing of dm_mr
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             return
         with PD(ctx) as pd:
             for i in range(10):
                 dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size/2,
                                           u.DM_ALIGNMENT)
                 dm_attrs = u.get_dm_attrs(dm_len)
                 with d.DM(ctx, dm_attrs) as dm:
                     dm_mr_len = random.randint(1, dm_len)
                     dm_mr_offset = random.randint(0, (dm_len - dm_mr_len))
                     dm_mr = DMMR(pd, dm_mr_len, e.IBV_ACCESS_ZERO_BASED,
                                  dm=dm, offset=dm_mr_offset)
                     dm_mr.close()
Exemplo n.º 14
0
 def test_dm_write_bad_flow(self):
     """
     Test writing to the device memory with bad offset and length
     """
     dm_len = random.randrange(u.MIN_DM_SIZE, self.attr_ex.max_dm_size / 2,
                               u.DM_ALIGNMENT)
     dm_attrs = u.get_dm_attrs(dm_len)
     with d.DM(self.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 = 'a' * 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')