]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: qemuxml2argv: move DO_TEST qemuCaps init
authorCole Robinson <crobinso@redhat.com>
Thu, 14 Mar 2019 10:19:28 +0000 (06:19 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 21 Mar 2019 16:43:02 +0000 (12:43 -0400)
Move DO_TEST* qemuCaps init into testInfoSetArgs. This is a step
towards unifying the different test macro implementations

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
tests/qemuxml2argvtest.c

index 004d3b4c4fc914fb271f22a3167970d5a33c9f5e..14d3df02a90a364832dd9a4706adf743f4dbfca3 100644 (file)
@@ -632,19 +632,21 @@ testInfoSetArgs(struct testInfo *info, ...)
 {
     va_list argptr;
     testInfoArgName argname;
+    virQEMUCapsPtr qemuCaps = NULL;
+    int gic = GIC_NONE;
     int ret = -1;
 
     va_start(argptr, info);
     while ((argname = va_arg(argptr, testInfoArgName)) < ARG_END) {
         switch (argname) {
         case ARG_QEMU_CAPS:
-            virQEMUCapsSetVAList(info->qemuCaps, argptr);
+            if (qemuCaps || !(qemuCaps = virQEMUCapsNew()))
+                goto cleanup;
+            virQEMUCapsSetVAList(qemuCaps, argptr);
             break;
 
         case ARG_GIC:
-            if (testQemuCapsSetGIC(info->qemuCaps,
-                                   va_arg(argptr, int)) < 0)
-                goto cleanup;
+            gic = va_arg(argptr, int);
             break;
 
         case ARG_MIGRATE_FROM:
@@ -670,9 +672,21 @@ testInfoSetArgs(struct testInfo *info, ...)
         }
     }
 
+    if (!info->qemuCaps) {
+        if (!qemuCaps) {
+            fprintf(stderr, "No qemuCaps generated\n");
+            goto cleanup;
+        }
+        VIR_STEAL_PTR(info->qemuCaps, qemuCaps);
+    }
+
+    if (gic != GIC_NONE && testQemuCapsSetGIC(info->qemuCaps, gic) < 0)
+        goto cleanup;
+
     ret = 0;
 
  cleanup:
+    virObjectUnref(qemuCaps);
     va_end(argptr);
 
     return ret;
@@ -862,8 +876,6 @@ mymain(void)
         static struct testInfo info = { \
             .name = _name, \
         }; \
-        if (!(info.qemuCaps = virQEMUCapsNew())) \
-            return EXIT_FAILURE; \
         if (testInfoSetArgs(&info, __VA_ARGS__, QEMU_CAPS_LAST, ARG_END) < 0) \
             return EXIT_FAILURE; \
         if (virTestRun("QEMU XML-2-ARGV " _name, \