diff options
author | John Levon <john.levon@nutanix.com> | 2021-07-14 12:22:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-14 12:22:33 +0100 |
commit | 561b3092c73b1b45756630fac73b182a3de0fdff (patch) | |
tree | e221ca1c2e753bfbf72e061d4fd4a12410adcec6 /test/py/libvfio_user.py | |
parent | e0c15dfd087f8093ee6aab697e9ac2a252ab42bb (diff) | |
download | libvfio-user-561b3092c73b1b45756630fac73b182a3de0fdff.zip libvfio-user-561b3092c73b1b45756630fac73b182a3de0fdff.tar.gz libvfio-user-561b3092c73b1b45756630fac73b182a3de0fdff.tar.bz2 |
check vfu_run_ctx() in python tests (#582)
Verify that the return value from vfu_run_ctx() is what we're expecting, rather
than just driving on in case of error.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py/libvfio_user.py')
-rw-r--r-- | test/py/libvfio_user.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/py/libvfio_user.py b/test/py/libvfio_user.py index ff5c1cd..8cd1c5d 100644 --- a/test/py/libvfio_user.py +++ b/test/py/libvfio_user.py @@ -34,6 +34,7 @@ from collections import namedtuple from types import SimpleNamespace import ctypes as c +import errno import json import mmap import os @@ -481,7 +482,9 @@ def disconnect_client(ctx, sock): sock.close() # notice client closed connection - vfu_run_ctx(ctx) + ret = vfu_run_ctx(ctx) + assert ret == -1 + assert c.get_errno() == errno.ENOTCONN def get_reply(sock, expect=0): buf = sock.recv(4096) @@ -500,7 +503,9 @@ def msg(ctx, sock, cmd, payload, expect=0, fds=None): else: sock.send(hdr + payload) - vfu_run_ctx(ctx) + ret = vfu_run_ctx(ctx) + assert ret >= 0 + return get_reply(sock, expect=expect) def get_pci_header(ctx): @@ -541,10 +546,8 @@ def access_region(ctx, sock, is_write, region, offset, count, payload += data cmd = VFIO_USER_REGION_WRITE if is_write else VFIO_USER_REGION_READ - hdr = vfio_user_header(cmd, size=len(payload)) - sock.send(hdr + payload) - vfu_run_ctx(ctx) - result = get_reply(sock, expect=expect) + + result = msg(ctx, sock, cmd, payload, expect=expect) if is_write: return None |