aboutsummaryrefslogtreecommitdiff
path: root/lib/migration.c
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-03-25 16:54:53 +0000
committerGitHub <noreply@github.com>2021-03-25 16:54:53 +0000
commit710a0081aa206b319161fac9bbafce14f5045ee8 (patch)
treefbf91231220be75cd05279c0492f90cf1d5ab669 /lib/migration.c
parent4f4c378978f0e22ec5b803496e2971adca6a3f8f (diff)
downloadlibvfio-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/migration.c')
-rw-r--r--lib/migration.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/migration.c b/lib/migration.c
index cc7abcf..93703a0 100644
--- a/lib/migration.c
+++ b/lib/migration.c
@@ -477,13 +477,13 @@ migration_region_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count,
}
bool
-device_is_stopped_and_copying(struct migration *migr)
+MOCK_DEFINE(device_is_stopped_and_copying)(struct migration *migr)
{
return migr != NULL && migr->info.device_state == VFIO_DEVICE_STATE_SAVING;
}
bool
-device_is_stopped(struct migration *migr)
+MOCK_DEFINE(device_is_stopped)(struct migration *migr)
{
return migr != NULL && migr->info.device_state == VFIO_DEVICE_STATE_STOP;
}