aboutsummaryrefslogtreecommitdiff
path: root/test/py/test_sgl_get_put.py
diff options
context:
space:
mode:
authorMattias Nissler <122288598+mnissler-rivos@users.noreply.github.com>2023-08-31 11:38:55 +0200
committerGitHub <noreply@github.com>2023-08-31 10:38:55 +0100
commita7eedffe20bd6e480c9e2c65e68daef1beb2af05 (patch)
tree37f46c9cbf8de3fbb0622b7472157d60f1b8550f /test/py/test_sgl_get_put.py
parent2e8ec2e17a5252d29bae849eb4ccd7ca6bab216a (diff)
downloadlibvfio-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_sgl_get_put.py')
-rw-r--r--test/py/test_sgl_get_put.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/py/test_sgl_get_put.py b/test/py/test_sgl_get_put.py
index d44dc6e..53203fc 100644
--- a/test/py/test_sgl_get_put.py
+++ b/test/py/test_sgl_get_put.py
@@ -54,13 +54,13 @@ def test_sgl_get_with_invalid_region():
def test_sgl_get_without_fd():
- sock = connect_client(ctx)
+ client = connect_client(ctx)
payload = vfio_user_dma_map(argsz=len(vfio_user_dma_map()),
flags=(VFIO_USER_F_DMA_REGION_READ |
VFIO_USER_F_DMA_REGION_WRITE),
offset=0, addr=0x1000, size=4096)
- msg(ctx, sock, VFIO_USER_DMA_MAP, payload)
+ msg(ctx, client.sock, VFIO_USER_DMA_MAP, payload)
sg = dma_sg_t()
iovec = iovec_t()
sg.region = 0
@@ -68,11 +68,11 @@ def test_sgl_get_without_fd():
assert ret == -1
assert ctypes.get_errno() == errno.EFAULT
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
def test_get_multiple_sge():
- sock = connect_client(ctx)
+ client = connect_client(ctx)
regions = 4
f = tempfile.TemporaryFile()
f.truncate(0x1000 * regions)
@@ -81,7 +81,7 @@ def test_get_multiple_sge():
flags=(VFIO_USER_F_DMA_REGION_READ |
VFIO_USER_F_DMA_REGION_WRITE),
offset=0, addr=0x1000 * i, size=4096)
- msg(ctx, sock, VFIO_USER_DMA_MAP, payload, fds=[f.fileno()])
+ msg(ctx, client.sock, VFIO_USER_DMA_MAP, payload, fds=[f.fileno()])
ret, sg = vfu_addr_to_sgl(ctx, dma_addr=0x1000, length=4096 * 3,
max_nr_sgs=3, prot=mmap.PROT_READ)
@@ -94,11 +94,11 @@ def test_get_multiple_sge():
assert iovec[1].iov_len == 4096
assert iovec[2].iov_len == 4096
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
def test_sgl_put():
- sock = connect_client(ctx)
+ client = connect_client(ctx)
regions = 4
f = tempfile.TemporaryFile()
f.truncate(0x1000 * regions)
@@ -107,7 +107,7 @@ def test_sgl_put():
flags=(VFIO_USER_F_DMA_REGION_READ |
VFIO_USER_F_DMA_REGION_WRITE),
offset=0, addr=0x1000 * i, size=4096)
- msg(ctx, sock, VFIO_USER_DMA_MAP, payload, fds=[f.fileno()])
+ msg(ctx, client.sock, VFIO_USER_DMA_MAP, payload, fds=[f.fileno()])
ret, sg = vfu_addr_to_sgl(ctx, dma_addr=0x1000, length=4096 * 3,
max_nr_sgs=3, prot=mmap.PROT_READ)
@@ -118,7 +118,7 @@ def test_sgl_put():
assert ret == 0
vfu_sgl_put(ctx, sg, iovec, cnt=3)
- disconnect_client(ctx, sock)
+ client.disconnect(ctx)
def test_sgl_get_put_cleanup():