diff options
author | John Levon <john.levon@nutanix.com> | 2021-03-25 16:54:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 16:54:53 +0000 |
commit | 710a0081aa206b319161fac9bbafce14f5045ee8 (patch) | |
tree | fbf91231220be75cd05279c0492f90cf1d5ab669 /lib/private.h | |
parent | 4f4c378978f0e22ec5b803496e2971adca6a3f8f (diff) | |
download | libvfio-user-710a0081aa206b319161fac9bbafce14f5045ee8.zip libvfio-user-710a0081aa206b319161fac9bbafce14f5045ee8.tar.gz libvfio-user-710a0081aa206b319161fac9bbafce14f5045ee8.tar.bz2 |
re-work unit test mocking (#400)
Instead of trying to use the linker's --wrap, which just led to more problems
when we want to call the real function, we'll add two defines, MOCK_DEFINE() and
MOCK_DECLARE(), that behave differently when building the unit tests, such that
all wrapped functions are picked up from test/mocks.c instead, regardless of
compilation unit.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/private.h')
-rw-r--r-- | lib/private.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/private.h b/lib/private.h index 9f06304..c463fea 100644 --- a/lib/private.h +++ b/lib/private.h @@ -163,23 +163,23 @@ int handle_device_set_irqs(vfu_ctx_t *vfu_ctx, uint32_t size, int *fds, size_t nr_fds, struct vfio_irq_set *irq_set); -MOCKED(bool, should_exec_command, vfu_ctx_t *vfu_ctx, uint16_t cmd); +MOCK_DECLARE(bool, should_exec_command, vfu_ctx_t *vfu_ctx, uint16_t cmd); -MOCKED(bool, cmd_allowed_when_stopped_and_copying, uint16_t cmd); +MOCK_DECLARE(bool, cmd_allowed_when_stopped_and_copying, uint16_t cmd); -MOCKED(int, get_next_command, vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr, - int *fds, size_t *nr_fds); +MOCK_DECLARE(int, get_next_command, vfu_ctx_t *vfu_ctx, + struct vfio_user_header *hdr, int *fds, size_t *nr_fds); -MOCKED(int, exec_command, vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr, - size_t size, int *fds, size_t nr_fds, int **fds_out, size_t *nr_fds_out, - struct iovec *_iovecs, struct iovec **iovecs, size_t *nr_iovecs, - bool *free_iovec_data); +MOCK_DECLARE(int, exec_command, vfu_ctx_t *vfu_ctx, + struct vfio_user_header *hdr, size_t size, int *fds, size_t nr_fds, + int **fds_out, size_t *nr_fds_out, struct iovec *_iovecs, + struct iovec **iovecs, size_t *nr_iovecs, bool *free_iovec_data); -MOCKED(int, process_request, vfu_ctx_t *vfu_ctx); +MOCK_DECLARE(int, process_request, vfu_ctx_t *vfu_ctx); -MOCKED(int, 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); +MOCK_DECLARE(int, 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); #endif /* LIB_VFIO_USER_PRIVATE_H */ |