[libvirt PATCH 10/17] tests: testutilsqemu: move virFindFileInPath into domaincapsmock

Pavel Hrdina phrdina at redhat.com
Fri Apr 16 19:12:39 UTC 2021


Having the function on mock library reflect more closely what we usually
do in tests.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 tests/domaincapsmock.c | 16 ++++++++++++++++
 tests/testutilsqemu.c  | 15 ---------------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c
index d81a898dc0..73690f0b9e 100644
--- a/tests/domaincapsmock.c
+++ b/tests/domaincapsmock.c
@@ -16,6 +16,7 @@
 
 #include <config.h>
 
+#include "virfile.h"
 #include "virhostcpu.h"
 #ifdef WITH_LIBXL
 # include "libxl/libxl_capabilities.h"
@@ -40,3 +41,18 @@ virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED)
 {
     return 0;
 }
+
+char *
+virFindFileInPath(const char *file)
+{
+    if (g_str_has_prefix(file, "qemu-system") ||
+        g_str_equal(file, "qemu-kvm")) {
+        return g_strdup_printf("/usr/bin/%s", file);
+    }
+
+    /* Nothing in tests should be relying on real files
+     * in host OS, so we return NULL to try to force
+     * an error in such a case
+     */
+    return NULL;
+}
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 7451929807..0a2af5036e 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -117,21 +117,6 @@ static const char *qemu_default_ram_id[VIR_ARCH_LAST] = {
     [VIR_ARCH_SPARC] = "sun4m.ram",
 };
 
-char *
-virFindFileInPath(const char *file)
-{
-    if (g_str_has_prefix(file, "qemu-system") ||
-        g_str_equal(file, "qemu-kvm")) {
-        return g_strdup_printf("/usr/bin/%s", file);
-    }
-
-    /* Nothing in tests should be relying on real files
-     * in host OS, so we return NULL to try to force
-     * an error in such a case
-     */
-    return NULL;
-}
-
 
 virCapsHostNUMA *
 virCapabilitiesHostNUMANewHost(void)
-- 
2.30.2




More information about the libvir-list mailing list