diff options
author | John Levon <john.levon@nutanix.com> | 2021-06-10 11:35:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 11:35:08 +0100 |
commit | c34d6ec02bae297b9256ac45ff71da0e2d4b4bc1 (patch) | |
tree | 1ca0d1f797bb38ffa06a2f132d613fa0e3785fa3 /test/py/test_device_get_info.py | |
parent | b665c3982c1efe2bb896fc8b556d24bcf996435a (diff) | |
download | libvfio-user-c34d6ec02bae297b9256ac45ff71da0e2d4b4bc1.zip libvfio-user-c34d6ec02bae297b9256ac45ff71da0e2d4b4bc1.tar.gz libvfio-user-c34d6ec02bae297b9256ac45ff71da0e2d4b4bc1.tar.bz2 |
python tests: add msg() utility function (#562)
Most tests need to send a request, process it, then retrieve the reply.
Add a utility function to avoid lots of tedious boilerplate.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py/test_device_get_info.py')
-rw-r--r-- | test/py/test_device_get_info.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/test/py/test_device_get_info.py b/test/py/test_device_get_info.py index a778604..ea9251b 100644 --- a/test/py/test_device_get_info.py +++ b/test/py/test_device_get_info.py @@ -52,28 +52,19 @@ def test_device_get_info(): payload = struct.pack("II", 0, 0) - hdr = vfio_user_header(VFIO_USER_DEVICE_GET_INFO, size=len(payload)) - sock.send(hdr + payload) - vfu_run_ctx(ctx) - get_reply(sock, expect=errno.EINVAL) + msg(ctx, sock, VFIO_USER_DEVICE_GET_INFO, payload, expect=errno.EINVAL) # bad argsz payload = vfio_user_device_info(argsz=8, flags=0, num_regions=0, num_irqs=0) - hdr = vfio_user_header(VFIO_USER_DEVICE_GET_INFO, size=len(payload)) - sock.send(hdr + payload) - vfu_run_ctx(ctx) - get_reply(sock, expect=errno.EINVAL) + msg(ctx, sock, VFIO_USER_DEVICE_GET_INFO, payload, expect=errno.EINVAL) # valid with larger argsz payload = vfio_user_device_info(argsz=32, flags=0, num_regions=0, num_irqs=0) - hdr = vfio_user_header(VFIO_USER_DEVICE_GET_INFO, size=len(payload)) - sock.send(hdr + payload) - vfu_run_ctx(ctx) - result = get_reply(sock) + result = msg(ctx, sock, VFIO_USER_DEVICE_GET_INFO, payload) (argsz, flags, num_regions, num_irqs) = struct.unpack("IIII", result) |