From 7056525da5399d00831e90bed4aedb4b8442c9b2 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 2 Dec 2021 10:34:49 +0000 Subject: test more region access validation code (#634) Add a little more coverage of our validation, and correct a small typo. Signed-off-by: John Levon Reviewed-by: Thanos Makatos --- test/py/test_setup_region.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/py/test_setup_region.py b/test/py/test_setup_region.py index f06d31c..b55f56f 100644 --- a/test/py/test_setup_region.py +++ b/test/py/test_setup_region.py @@ -35,7 +35,7 @@ import tempfile ctx = None -def test_device_set_irqs_setup(): +def test_setup_region_setup(): global ctx ctx = vfu_create_ctx(flags=LIBVFIO_USER_FLAG_ATTACH_NB) @@ -215,6 +215,30 @@ def test_access_region_zero_count(): disconnect_client(ctx, sock) +def test_access_region_large_count(): + global ctx + + sock = connect_client(ctx) + + read_region(ctx, sock, VFU_PCI_DEV_CFG_REGION_IDX, offset=0, + count=SERVER_MAX_DATA_XFER_SIZE + 8, expect=errno.EINVAL) + + disconnect_client(ctx, sock) + + +def test_region_offset_too_short(): + global ctx + + sock = connect_client(ctx) + + payload = struct.pack("Q", 0) + + msg(ctx, sock, VFIO_USER_REGION_WRITE, payload, + expect_reply_errno=errno.EINVAL) + + disconnect_client(ctx, sock) + + def test_setup_region_cleanup(): vfu_destroy_ctx(ctx) -- cgit v1.1