]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Use virAsprintf() to build titles
authorAndrea Bolognani <abologna@redhat.com>
Thu, 7 Mar 2019 14:37:40 +0000 (15:37 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 13 Mar 2019 10:07:04 +0000 (11:07 +0100)
We're using static string concatenation at the moment, but
that will no longer be a possibility in a bit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
tests/qemucapabilitiestest.c
tests/qemucaps2xmltest.c

index e3c6681dd4f4283e66066faf7e62c58a446bffa9..222ac05d790355095e43a9599edc26ba729102ff 100644 (file)
@@ -196,12 +196,17 @@ mymain(void)
 
 #define DO_TEST(arch, name) \
     do { \
+        VIR_AUTOFREE(char *) title = NULL; \
+        VIR_AUTOFREE(char *) copyTitle = NULL; \
+        if (virAsprintf(&title, "%s (%s)", name, arch) < 0 || \
+            virAsprintf(&copyTitle, "copy %s (%s)", name, arch) < 0) { \
+            return -EXIT_FAILURE; \
+        } \
         data.archName = arch; \
         data.base = name; \
-        if (virTestRun(name "(" arch ")", testQemuCaps, &data) < 0) \
+        if (virTestRun(title, testQemuCaps, &data) < 0) \
             data.ret = -1; \
-        if (virTestRun("copy " name "(" arch ")", \
-                       testQemuCapsCopy, &data) < 0) \
+        if (virTestRun(copyTitle, testQemuCapsCopy, &data) < 0) \
             data.ret = -1; \
     } while (0)
 
index 6ced328092ed7d216ef741f290a66e8219b82c31..1fa16e91de088f0e7efa931a5384379d7ac784d0 100644 (file)
@@ -192,10 +192,15 @@ mymain(void)
         return EXIT_FAILURE;
 
 #define DO_TEST(arch, name) \
-    data.archName = arch; \
-    data.base = name; \
-    if (virTestRun(name "(" arch ")", testQemuCapsXML, &data) < 0) \
-        data.ret = -1
+    do { \
+        VIR_AUTOFREE(char *) title = NULL; \
+        if (virAsprintf(&title, "%s (%s)", name, arch) < 0) \
+            return -EXIT_FAILURE; \
+        data.archName = arch; \
+        data.base = name; \
+        if (virTestRun(title, testQemuCapsXML, &data) < 0) \
+            data.ret = -1; \
+    } while (0)
 
     /* Keep this in sync with qemucapabilitiestest */
     DO_TEST("x86_64", "caps_1.5.3");