[PATCH v2 2/2] test: qemuhotplugtest mock virFileMakePath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@xxxxxxxxxxxxx>
---
 tests/qemuhotplugmock.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c
index 43a9d79051..06a28742d4 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,19 @@ 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


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux