diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/py/libvfio_user.py | 2 | ||||
-rw-r--r-- | test/py/test_dma_unmap.py | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/test/py/libvfio_user.py b/test/py/libvfio_user.py index c7e3765..bf3e9cd 100644 --- a/test/py/libvfio_user.py +++ b/test/py/libvfio_user.py @@ -97,6 +97,8 @@ VFIO_IRQ_SET_ACTION_MASK = (1 << 3) VFIO_IRQ_SET_ACTION_UNMASK = (1 << 4) VFIO_IRQ_SET_ACTION_TRIGGER = (1 << 5) +VFIO_DMA_UNMAP_FLAG_ALL = (1 << 1) + # libvfio-user defines VFU_TRANS_SOCK = 0 diff --git a/test/py/test_dma_unmap.py b/test/py/test_dma_unmap.py index 0200c43..f070ede 100644 --- a/test/py/test_dma_unmap.py +++ b/test/py/test_dma_unmap.py @@ -65,7 +65,7 @@ def test_dma_unmap_bad_argsz(): def test_dma_unmap_invalid_flags(): payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), - flags=0x2323, addr=0x1000, size=4096) + flags=0x4, addr=0x1000, size=4096) msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload, expect=errno.ENOTSUP) def test_dma_unmap(): @@ -74,6 +74,38 @@ def test_dma_unmap(): flags=0, addr=0x1000, size=4096) msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload) +def test_dma_unmap_all(): + + for i in range(0, MAX_DMA_REGIONS): + 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 * i, size=4096) + + msg(ctx, sock, VFIO_USER_DMA_MAP, payload) + + payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), + flags=VFIO_DMA_UNMAP_FLAG_ALL, addr=0, size=0) + + msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload) + +def test_dma_unmap_all_invalid_addr(): + + payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), + flags=VFIO_DMA_UNMAP_FLAG_ALL, addr=0x10000, size=4096) + + msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload, expect=errno.EINVAL) + +def test_dma_unmap_all_invalid_flags(): + + payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), + flags=(VFIO_DMA_UNMAP_FLAG_ALL | VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP), + addr=0, size=0) + + msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload, expect=errno.EINVAL) + def test_dma_unmap_cleanup(): disconnect_client(ctx, sock) vfu_destroy_ctx(ctx) + +# ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab |