In certain build environments (e.g. Debian and Ubuntu) $HOME is set
to a non existing path intentionally. That breaks and crashes
qemuhotplugtest by failing the init in virHostdevManagerGetDefault.
Avoid that issue by mocking the virFileMakePath behavior if it is
passed a path that matches $HOME and doesn't exists. That fixes
qemuhotplugtest in Debian/Ubuntu builds of v6.0.0.
Signed-off-by: Christian Ehrhardt <christian.ehrhardt(a)canonical.com>
---
tests/qemuhotplugmock.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c
index 43a9d79051..bd5eb3ceb6 100644
--- a/tests/qemuhotplugmock.c
+++ b/tests/qemuhotplugmock.c
@@ -18,6 +18,7 @@
#include <config.h>
+#include "virmock.h"
#include "qemu/qemu_hotplug.h"
#include "conf/domain_conf.h"
@@ -31,3 +32,20 @@ qemuDomainGetUnplugTimeout(virDomainObjPtr vm G_GNUC_UNUSED)
return 200;
return 100;
}
+
+VIR_MOCK_IMPL_RET_ARGS(virFileMakePath, int,
+ const char *, path)
+{
+ const char *home;
+
+ VIR_MOCK_REAL_INIT(virFileMakePath);
+
+ /* ignore non-existing homes (e.g. in build environments) */
+ home = getenv("HOME");
+ if (strstr(path, home)) {
+ if (!g_file_test (home, G_FILE_TEST_EXISTS)) {
+ return 0;
+ }
+ }
+ return real_virFileMakePath(path);
+}
--
2.25.0