[libvirt PATCH] tests: fix mocking on macOS
On macOS we use flat namespace so we cannot have multiple mocks for the same function. Fixes: 63434db800b921e96fec424a667b7161af1f02de Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- tests/domaincapsmock.c | 4 ++++ tests/qemuhotplugmock.c | 23 ----------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c index aa13deb324..4fb44f7244 100644 --- a/tests/domaincapsmock.c +++ b/tests/domaincapsmock.c @@ -95,6 +95,10 @@ virFileExists(const char *path) if (STREQ(path, "/dev/vfio/vfio")) return true; + /* required by qemuhotplugtest */ + if (STREQ(path, "/dev/mapper/virt")) + return true; + return real_virFileExists(path); } diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index dd7e2c67e0..79e9bdd8a8 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -24,22 +24,11 @@ #include "testutilsqemu.h" #include "conf/domain_conf.h" #include "virdevmapper.h" -#include "virmock.h" #include <fcntl.h> #define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW #include "qemu/qemu_monitor_priv.h" -static bool (*real_virFileExists)(const char *path); - -static void -init_syms(void) -{ - if (real_virFileExists) - return; - - VIR_MOCK_REAL_INIT(virFileExists); -} unsigned long long qemuDomainGetUnplugTimeout(virDomainObj *vm) @@ -69,18 +58,6 @@ virDevMapperGetTargets(const char *path, } -bool -virFileExists(const char *path) -{ - init_syms(); - - if (STREQ(path, "/dev/mapper/virt")) - return true; - - return real_virFileExists(path); -} - - int qemuProcessStartManagedPRDaemon(virDomainObj *vm G_GNUC_UNUSED) { -- 2.53.0
On 2/17/26 10:21, Pavel Hrdina via Devel wrote:
On macOS we use flat namespace so we cannot have multiple mocks for the same function.
Fixes: 63434db800b921e96fec424a667b7161af1f02de Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- tests/domaincapsmock.c | 4 ++++ tests/qemuhotplugmock.c | 23 ----------------------- 2 files changed, 4 insertions(+), 23 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Michal Prívozník -
Pavel Hrdina