diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-11-26 05:37:34 -0500 |
---|---|---|
committer | Thanos <tmakatos@gmail.com> | 2020-11-27 09:36:12 +0000 |
commit | 7df3de2f9d2a8fcfd6bb24ddbfc5aa20e237f464 (patch) | |
tree | 821f8cfbbe2ac9906dfa2780e2feab164ba97937 /lib/dma.c | |
parent | 24cacccd92a0da049af83d4da35bd3bcebf236ae (diff) | |
download | libvfio-user-7df3de2f9d2a8fcfd6bb24ddbfc5aa20e237f464.zip libvfio-user-7df3de2f9d2a8fcfd6bb24ddbfc5aa20e237f464.tar.gz libvfio-user-7df3de2f9d2a8fcfd6bb24ddbfc5aa20e237f464.tar.bz2 |
add unit tests for DMA regions without file descriptor
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/dma.c')
-rw-r--r-- | lib/dma.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -90,7 +90,7 @@ dma_controller_create(lm_ctx_t *lm_ctx, int max_regions) return dma; } -static void +void _dma_controller_do_remove_region(dma_controller_t *dma, dma_memory_region_t *region) { @@ -111,6 +111,14 @@ _dma_controller_do_remove_region(dma_controller_t *dma, } } } +UNIT_TEST_SYMBOL(_dma_controller_do_remove_region); + +/* + * FIXME super ugly, but without this functions within the same compilation + * unit don't call the wrapped version, making unit testing impossible. + * Ideally we'd like the UNIT_TEST_SYMBOL macro to solve this. + */ +#define _dma_controller_do_remove_region __wrap__dma_controller_do_remove_region /* * FIXME no longer used. Also, it doesn't work for addresses that span two @@ -173,6 +181,7 @@ dma_controller_remove_region(dma_controller_t *dma, } return -ENOENT; } +UNIT_TEST_SYMBOL(dma_controller_remove_region); static inline void dma_controller_remove_regions(dma_controller_t *dma) @@ -292,6 +301,8 @@ dma_controller_add_region(dma_controller_t *dma, } goto err; } + } else { + region->virt_addr = NULL; } dma->nregions++; @@ -300,6 +311,7 @@ dma_controller_add_region(dma_controller_t *dma, err: return -idx - 1; } +UNIT_TEST_SYMBOL(dma_controller_add_region); static inline void mmap_round(size_t *offset, size_t *size, size_t page_size) @@ -334,6 +346,7 @@ dma_map_region(dma_memory_region_t *region, int prot, size_t offset, size_t len) return mmap_base + (offset - mmap_offset); } +UNIT_TEST_SYMBOL(dma_map_region); int dma_unmap_region(dma_memory_region_t *region, void *virt_addr, size_t len) |