aboutsummaryrefslogtreecommitdiff
path: root/test/mocks.c
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2021-02-17 13:15:35 +0000
committerGitHub <noreply@github.com>2021-02-17 13:15:35 +0000
commit47a6fdbb8b3e459ba4f7815269bae0abf95d29a6 (patch)
treefadcb3199e69d75a29b707915612c1ba43d8fe4f /test/mocks.c
parente4e0ebde2c25f3011d20b6a2f1b1b8f510b09d9e (diff)
downloadlibvfio-user-47a6fdbb8b3e459ba4f7815269bae0abf95d29a6.zip
libvfio-user-47a6fdbb8b3e459ba4f7815269bae0abf95d29a6.tar.gz
libvfio-user-47a6fdbb8b3e459ba4f7815269bae0abf95d29a6.tar.bz2
add unit tests for handle dirty pages w/o DMA (#348)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'test/mocks.c')
-rw-r--r--test/mocks.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/mocks.c b/test/mocks.c
index 303a6c2..80545e6 100644
--- a/test/mocks.c
+++ b/test/mocks.c
@@ -88,6 +88,9 @@ __wrap__dma_controller_do_remove_region(dma_controller_t *dma,
bool
__wrap_device_is_stopped(struct migration *migr)
{
+ if (!is_patched(device_is_stopped)) {
+ return __real_device_is_stopped(migr);
+ }
check_expected(migr);
return mock();
}
@@ -109,6 +112,11 @@ __wrap_exec_command(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr,
int *nr_fds_out, struct iovec *_iovecs, struct iovec **iovecs,
size_t *nr_iovecs, bool *free_iovec_data)
{
+ if (!is_patched(exec_command)) {
+ return __real_exec_command(vfu_ctx, hdr, size, fds, nr_fds, fds_out,
+ nr_fds_out, _iovecs, iovecs, nr_iovecs,
+ free_iovec_data);
+ }
check_expected(vfu_ctx);
check_expected(hdr);
check_expected(size);
@@ -187,6 +195,23 @@ int __wrap_listen(int sockfd __attribute__((unused)),
return 0;
}
+int
+__wrap_handle_dirty_pages(vfu_ctx_t *vfu_ctx, uint32_t size,
+ struct iovec **iovecs, size_t *nr_iovecs,
+ struct vfio_iommu_type1_dirty_bitmap *dirty_bitmap)
+{
+ if (!is_patched(handle_dirty_pages)) {
+ return __real_handle_dirty_pages(vfu_ctx, size, iovecs, nr_iovecs,
+ dirty_bitmap);
+ }
+ check_expected(vfu_ctx);
+ check_expected(size);
+ check_expected(iovecs);
+ check_expected(nr_iovecs);
+ check_expected(dirty_bitmap);
+ return mock();
+}
+
/* FIXME should be something faster than unsorted array, look at tsearch(3). */
static struct function funcs[] = {
{.addr = &__wrap_dma_controller_add_region},
@@ -200,7 +225,8 @@ static struct function funcs[] = {
{.addr = &__wrap_free},
{.addr = &__wrap_process_request},
{.addr = &__wrap_bind},
- {.addr = &__wrap_listen}
+ {.addr = &__wrap_listen},
+ {.addr = &__wrap_handle_dirty_pages},
};
static struct function*