Skip to content

Commit

Permalink
Add simple tests for 64bits and prefetch region flag
Browse files Browse the repository at this point in the history
Test that BARs created with VFU_REGION_FLAG_64_BITS and/or
VFU_REGION_FLAG_PREFETCH flags do have the right flags in their
header.

Signed-off-by: Jérémy Fanguède <[email protected]>
  • Loading branch information
jfgd committed Mar 28, 2024
1 parent 6b6e7db commit edd4549
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/py/libvfio_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ def is_32bit():
VFU_REGION_FLAG_RW = (VFU_REGION_FLAG_READ | VFU_REGION_FLAG_WRITE)
VFU_REGION_FLAG_MEM = 4
VFU_REGION_FLAG_ALWAYS_CB = 8
VFU_REGION_FLAG_64_BITS = 16
VFU_REGION_FLAG_PREFETCH = 32

VFIO_USER_F_DMA_REGION_READ = (1 << 0)
VFIO_USER_F_DMA_REGION_WRITE = (1 << 1)
Expand Down
13 changes: 13 additions & 0 deletions test/py/test_vfu_realize_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ def test_vfu_realize_ctx_pci_bars():
ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR1_REGION_IDX, size=4096,
flags=(VFU_REGION_FLAG_RW | VFU_REGION_FLAG_MEM))
assert ret == 0
ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR2_REGION_IDX,
size=1048576,
flags=(VFU_REGION_FLAG_RW | VFU_REGION_FLAG_MEM
| VFU_REGION_FLAG_64_BITS))
assert ret == 0
ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR4_REGION_IDX,
size=1073741824,
flags=(VFU_REGION_FLAG_RW | VFU_REGION_FLAG_MEM
| VFU_REGION_FLAG_64_BITS
| VFU_REGION_FLAG_PREFETCH))
assert ret == 0

ret = vfu_realize_ctx(ctx)
assert ret == 0
Expand All @@ -81,6 +92,8 @@ def test_vfu_realize_ctx_pci_bars():
hdr = get_pci_header(ctx)
assert hdr.bars[0].io == 0x1
assert hdr.bars[1].io == 0
assert hdr.bars[2].io == 0x4
assert hdr.bars[4].io == 0x4 + 0x8

vfu_destroy_ctx(ctx)

Expand Down

0 comments on commit edd4549

Please sign in to comment.