[PATCH 03/24] domaincapstest: Make construction of filename more extensible

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

 



Rather than trying to cram everything into one printf statement format
the type with prefix and machine with prefix separately and then
concatenate everything into the filename.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/domaincapstest.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 359ead2d32..2120e7efd5 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -252,13 +252,31 @@ doTestQemuInternal(const char *version,
     g_autofree char *name = NULL;
     g_autofree char *capsName = NULL;
     g_autofree char *emulator = NULL;
+    const char *typestr = NULL;
+    g_autofree char *mach = NULL;
     int rc;

-    name = g_strdup_printf("qemu_%s%s%s%s.%s",
-                           version,
-                           (type == VIR_DOMAIN_VIRT_QEMU ? "-tcg" : ""),
-                           (machine ? "-" : ""), (machine ? machine : ""),
-                           arch);
+    switch ((unsigned int) type) {
+    case VIR_DOMAIN_VIRT_QEMU:
+        typestr = "-tcg";
+        break;
+
+    case VIR_DOMAIN_VIRT_KVM:
+        typestr = "";
+        break;
+
+    default:
+        abort();
+        break;
+    }
+
+    if (machine)
+        mach = g_strdup_printf("-%s", machine);
+    else
+        mach = g_strdup("");
+
+    name = g_strdup_printf("qemu_%s%s%s.%s",
+                           version, typestr, mach, arch);
     capsName = g_strdup_printf("caps_%s", version);
     emulator = g_strdup_printf("/usr/bin/qemu-system-%s", arch);

-- 
2.39.2




[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