diff options
author | Mattias Nissler <122288598+mnissler-rivos@users.noreply.github.com> | 2023-08-31 11:38:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 10:38:55 +0100 |
commit | a7eedffe20bd6e480c9e2c65e68daef1beb2af05 (patch) | |
tree | 37f46c9cbf8de3fbb0622b7472157d60f1b8550f /test/py/test_device_get_irq_info.py | |
parent | 2e8ec2e17a5252d29bae849eb4ccd7ca6bab216a (diff) | |
download | libvfio-user-a7eedffe20bd6e480c9e2c65e68daef1beb2af05.zip libvfio-user-a7eedffe20bd6e480c9e2c65e68daef1beb2af05.tar.gz libvfio-user-a7eedffe20bd6e480c9e2c65e68daef1beb2af05.tar.bz2 |
Introduce client object in python tests (#772)
Thus far, the client end of the socket is the only piece of client state
tracked in tests, for which a global `socket` variable has been used. In
preparation to add more state, replace the `socket` global with a
`client` global object that groups all client state.
Signed-off-by: Mattias Nissler <mnissler@rivosinc.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py/test_device_get_irq_info.py')
-rw-r--r-- | test/py/test_device_get_irq_info.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/py/test_device_get_irq_info.py b/test/py/test_device_get_irq_info.py index 0a9b089..8ac6759 100644 --- a/test/py/test_device_get_irq_info.py +++ b/test/py/test_device_get_irq_info.py @@ -31,13 +31,13 @@ from libvfio_user import * import errno ctx = None -sock = None +client = None argsz = len(vfio_irq_info()) def test_device_get_irq_info_setup(): - global ctx, sock + global ctx, client ctx = vfu_create_ctx(flags=LIBVFIO_USER_FLAG_ATTACH_NB) assert ctx is not None @@ -55,27 +55,27 @@ def test_device_get_irq_info_setup(): ret = vfu_realize_ctx(ctx) assert ret == 0 - sock = connect_client(ctx) + client = connect_client(ctx) def test_device_get_irq_info_bad_in(): payload = struct.pack("II", 0, 0) - msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload, + msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload, expect=errno.EINVAL) # bad argsz payload = vfio_irq_info(argsz=8, flags=0, index=VFU_DEV_REQ_IRQ, count=0) - msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload, + msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload, expect=errno.EINVAL) # bad index payload = vfio_irq_info(argsz=argsz, flags=0, index=VFU_DEV_NUM_IRQS, count=0) - msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload, + msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload, expect=errno.EINVAL) @@ -86,12 +86,12 @@ def test_device_get_irq_info(): payload = vfio_irq_info(argsz=argsz + 16, flags=0, index=VFU_DEV_REQ_IRQ, count=0) - msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) + msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) payload = vfio_irq_info(argsz=argsz, flags=0, index=VFU_DEV_REQ_IRQ, count=0) - result = msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) + result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) info, _ = vfio_irq_info.pop_from_buffer(result) @@ -103,7 +103,7 @@ def test_device_get_irq_info(): payload = vfio_irq_info(argsz=argsz, flags=0, index=VFU_DEV_ERR_IRQ, count=0) - result = msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) + result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) info, _ = vfio_irq_info.pop_from_buffer(result) @@ -115,7 +115,7 @@ def test_device_get_irq_info(): payload = vfio_irq_info(argsz=argsz, flags=0, index=VFU_DEV_MSIX_IRQ, count=0) - result = msg(ctx, sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) + result = msg(ctx, client.sock, VFIO_USER_DEVICE_GET_IRQ_INFO, payload) info, _ = vfio_irq_info.pop_from_buffer(result) @@ -126,7 +126,7 @@ def test_device_get_irq_info(): def test_device_get_irq_info_cleanup(): - disconnect_client(ctx, sock) + client.disconnect(ctx) vfu_destroy_ctx(ctx) |