aboutsummaryrefslogtreecommitdiff
path: root/test/py/test_device_get_region_info.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py/test_device_get_region_info.py')
-rw-r--r--test/py/test_device_get_region_info.py49
1 files changed, 25 insertions, 24 deletions
diff --git a/test/py/test_device_get_region_info.py b/test/py/test_device_get_region_info.py
index 62d6740..f847cb4 100644
--- a/test/py/test_device_get_region_info.py
+++ b/test/py/test_device_get_region_info.py
@@ -32,7 +32,7 @@ import errno
import tempfile
ctx = None
-sock = None
+client = None
argsz = len(vfio_region_info())
migr_region_size = 2 << PAGE_SHIFT
@@ -40,7 +40,7 @@ migr_mmap_areas = [(PAGE_SIZE, PAGE_SIZE)]
def test_device_get_region_info_setup():
- global ctx, sock
+ global ctx, client
ctx = vfu_create_ctx(flags=LIBVFIO_USER_FLAG_ATTACH_NB)
assert ctx is not None
@@ -89,14 +89,14 @@ def test_device_get_region_info_setup():
ret = vfu_realize_ctx(ctx)
assert ret == 0
- sock = connect_client(ctx)
+ client = connect_client(ctx)
def test_device_get_region_info_short_write():
payload = struct.pack("II", 0, 0)
- msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
+ msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
expect=errno.EINVAL)
@@ -106,7 +106,7 @@ def test_device_get_region_info_bad_argsz():
index=VFU_PCI_DEV_BAR1_REGION_IDX, cap_offset=0,
size=0, offset=0)
- msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
+ msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
expect=errno.EINVAL)
@@ -116,7 +116,7 @@ def test_device_get_region_info_bad_index():
index=VFU_PCI_DEV_NUM_REGIONS, cap_offset=0,
size=0, offset=0)
- msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
+ msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
expect=errno.EINVAL)
@@ -126,7 +126,7 @@ def test_device_get_region_info_larger_argsz():
index=VFU_PCI_DEV_BAR1_REGION_IDX, cap_offset=0,
size=0, offset=0)
- result = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
+ result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
assert len(result) == argsz
@@ -142,13 +142,13 @@ def test_device_get_region_info_larger_argsz():
def test_device_get_region_info_small_argsz_caps():
- global sock
+ global client
payload = vfio_region_info(argsz=argsz, flags=0,
index=VFU_PCI_DEV_BAR2_REGION_IDX, cap_offset=0,
size=0, offset=0)
- result = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
+ result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
info, _ = vfio_region_info.pop_from_buffer(result)
@@ -167,20 +167,21 @@ def test_device_get_region_info_small_argsz_caps():
assert info.offset == 0x8000
# skip reading the SCM_RIGHTS
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
def test_device_get_region_info_caps():
- global sock
+ global client
- sock = connect_client(ctx)
+ client = connect_client(ctx)
payload = vfio_region_info(argsz=80, flags=0,
index=VFU_PCI_DEV_BAR2_REGION_IDX, cap_offset=0,
size=0, offset=0)
payload = bytes(payload) + b'\0' * (80 - 32)
- fds, result = msg_fds(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
+ fds, result = msg_fds(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO,
+ payload)
info, result = vfio_region_info.pop_from_buffer(result)
cap, result = vfio_region_info_cap_sparse_mmap.pop_from_buffer(result)
@@ -203,20 +204,20 @@ def test_device_get_region_info_caps():
assert area2.size == 0x2000
assert len(fds) == 1
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
def test_device_get_region_info_migr():
- global sock
+ global client
- sock = connect_client(ctx)
+ client = connect_client(ctx)
payload = vfio_region_info(argsz=80, flags=0,
index=VFU_PCI_DEV_MIGR_REGION_IDX, cap_offset=0,
size=0, offset=0)
payload = bytes(payload) + b'\0' * (80 - 32)
- result = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
+ result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
info, result = vfio_region_info.pop_from_buffer(result)
mcap, result = vfio_region_info_cap_type.pop_from_buffer(result)
@@ -241,7 +242,7 @@ def test_device_get_region_info_migr():
assert area.size == migr_mmap_areas[0][1]
# skip reading the SCM_RIGHTS
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
def test_device_get_region_info_cleanup():
@@ -260,13 +261,13 @@ def test_device_get_pci_config_space_info_implicit_pci_init():
ret = vfu_realize_ctx(ctx)
assert ret == 0
- sock = connect_client(ctx)
+ client = connect_client(ctx)
payload = vfio_region_info(argsz=argsz + 8, flags=0,
index=VFU_PCI_DEV_CFG_REGION_IDX, cap_offset=0,
size=0, offset=0)
- result = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
+ result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
assert len(result) == argsz
@@ -281,7 +282,7 @@ def test_device_get_pci_config_space_info_implicit_pci_init():
assert info.size == PCI_CFG_SPACE_EXP_SIZE
assert info.offset == 0
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
vfu_destroy_ctx(ctx)
@@ -296,13 +297,13 @@ def test_device_get_pci_config_space_info_implicit_no_pci_init():
ret = vfu_realize_ctx(ctx)
assert ret == 0
- sock = connect_client(ctx)
+ client = connect_client(ctx)
payload = vfio_region_info(argsz=argsz + 8, flags=0,
index=VFU_PCI_DEV_CFG_REGION_IDX, cap_offset=0,
size=0, offset=0)
- result = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
+ result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload)
assert len(result) == argsz
@@ -315,7 +316,7 @@ def test_device_get_pci_config_space_info_implicit_no_pci_init():
assert info.size == PCI_CFG_SPACE_SIZE
assert info.offset == 0
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
vfu_destroy_ctx(ctx)