]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Move code from DO_TEST() to doCapsTest()
authorAndrea Bolognani <abologna@redhat.com>
Thu, 7 Mar 2019 13:53:18 +0000 (14:53 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 13 Mar 2019 10:07:06 +0000 (11:07 +0100)
This removes the awkard escaping and will allow us to perform
some more refactoring later on.

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

index 222ac05d790355095e43a9599edc26ba729102ff..b4ed081d3e6af7de5d2d419ad06bbfeb1f67d2ae 100644 (file)
@@ -176,6 +176,32 @@ testQemuCapsCopy(const void *opaque)
 }
 
 
+static int
+doCapsTest(const char *base,
+           const char *archName,
+           testQemuDataPtr data)
+{
+    VIR_AUTOFREE(char *) title = NULL;
+    VIR_AUTOFREE(char *) copyTitle = NULL;
+
+    if (virAsprintf(&title, "%s (%s)", base, archName) < 0 ||
+        virAsprintf(&copyTitle, "copy %s (%s)", base, archName) < 0) {
+        return -1;
+    }
+
+    data->base = base;
+    data->archName = archName;
+
+    if (virTestRun(title, testQemuCaps, data) < 0)
+        data->ret = -1;
+
+    if (virTestRun(copyTitle, testQemuCapsCopy, data) < 0)
+        data->ret = -1;
+
+    return 0;
+}
+
+
 static int
 mymain(void)
 {
@@ -196,18 +222,8 @@ 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(title, testQemuCaps, &data) < 0) \
-            data.ret = -1; \
-        if (virTestRun(copyTitle, testQemuCapsCopy, &data) < 0) \
-            data.ret = -1; \
+        if (doCapsTest(name, arch, &data) < 0) \
+            return EXIT_FAILURE; \
     } while (0)
 
     /* Keep this in sync with qemucaps2xmltest */
index 1fa16e91de088f0e7efa931a5384379d7ac784d0..76775a81c228464471f3c1245c462318a593b197 100644 (file)
@@ -173,6 +173,25 @@ testQemuCapsXML(const void *opaque)
     return ret;
 }
 
+static int
+doCapsTest(const char *base,
+           const char *archName,
+           testQemuDataPtr data)
+{
+    VIR_AUTOFREE(char *) title = NULL;
+
+    if (virAsprintf(&title, "%s (%s)", base, archName) < 0)
+        return -1;
+
+    data->base = base;
+    data->archName = archName;
+
+    if (virTestRun(title, testQemuCapsXML, data) < 0)
+        data->ret = -1;
+
+    return 0;
+}
+
 static int
 mymain(void)
 {
@@ -193,13 +212,8 @@ mymain(void)
 
 #define DO_TEST(arch, name) \
     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; \
+        if (doCapsTest(name, arch, &data) < 0) \
+            return EXIT_FAILURE; \
     } while (0)
 
     /* Keep this in sync with qemucapabilitiestest */