[08/21] tests: qemuxml2argv: handle flags with varargs

Message ID 9180674e3de344c4e02ecd79952ac8d6b9e0cc3f.1552574299.git.crobinso@redhat.com
State Accepted
Commit 4cbf6830c185b684a1165b3a6e6b2cb7b8740135
Headers show
Series
  • tests: qemuxml2argv: support optional arguments
Related show

Commit Message

Cole Robinson March 14, 2019, 2:44 p.m.
This allows us to drop flags from DO_TEST_FULL

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 tests/qemuxml2argvtest.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Andrea Bolognani March 19, 2019, 1:12 p.m. | #1
On Thu, 2019-03-14 at 10:44 -0400, Cole Robinson wrote:
> This allows us to drop flags from DO_TEST_FULL

> 

> Signed-off-by: Cole Robinson <crobinso@redhat.com>

> ---

>  tests/qemuxml2argvtest.c | 37 ++++++++++++++++++++++---------------

>  1 file changed, 22 insertions(+), 15 deletions(-)


Reviewed-by: Andrea Bolognani <abologna@redhat.com>


-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Patch

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c6bd240c54..bb3d53070f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -610,6 +610,7 @@  typedef enum {
     ARG_GIC,
     ARG_MIGRATE_FROM,
     ARG_MIGRATE_FD,
+    ARG_FLAGS,
 
     ARG_END = QEMU_CAPS_LAST,
 } testInfoArgNames;
@@ -642,6 +643,10 @@  testInfoSetArgs(struct testInfo *info, ...)
             info->migrateFd = va_arg(argptr, int);
             break;
 
+        case ARG_FLAGS:
+            info->flags = va_arg(argptr, int);
+            break;
+
         case ARG_END:
         default:
             fprintf(stderr, "Unexpected test info argument");
@@ -832,10 +837,10 @@  mymain(void)
 # define DO_TEST_CAPS(name, ver) \
     DO_TEST_CAPS_FULL(name, 0, 0, ver)
 
-# define DO_TEST_FULL(name, flags, parseFlags, ...) \
+# define DO_TEST_FULL(name, parseFlags, ...) \
     do { \
         static struct testInfo info = { \
-            name, NULL, NULL, NULL, -1, (flags), parseFlags, \
+            name, NULL, NULL, NULL, -1, 0, parseFlags, \
         }; \
         if (!(info.qemuCaps = virQEMUCapsNew())) \
             return EXIT_FAILURE; \
@@ -848,29 +853,30 @@  mymain(void)
     } while (0)
 
 # define DO_TEST(name, ...) \
-    DO_TEST_FULL(name, 0, 0, \
+    DO_TEST_FULL(name, 0, \
                  ARG_QEMU_CAPS, __VA_ARGS__)
 
 # define DO_TEST_GIC(name, gic, ...) \
-    DO_TEST_FULL(name, 0, 0, \
+    DO_TEST_FULL(name, 0, \
                  ARG_GIC, gic, \
                  ARG_QEMU_CAPS, __VA_ARGS__)
 
 # define DO_TEST_FAILURE(name, ...) \
-    DO_TEST_FULL(name, FLAG_EXPECT_FAILURE, \
+    DO_TEST_FULL(name, \
                  0, \
+                 ARG_FLAGS, FLAG_EXPECT_FAILURE, \
                  ARG_QEMU_CAPS, __VA_ARGS__)
 
 # define DO_TEST_PARSE_ERROR(name, ...) \
     DO_TEST_FULL(name, \
-                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
                  0, \
+                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
                  ARG_QEMU_CAPS, __VA_ARGS__)
 
 # define DO_TEST_PARSE_FLAGS_ERROR(name, parseFlags, ...) \
     DO_TEST_FULL(name, \
-                 FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
                  parseFlags, \
+                 ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \
                  ARG_QEMU_CAPS, __VA_ARGS__)
 
 # define NONE QEMU_CAPS_LAST
@@ -1709,20 +1715,20 @@  mymain(void)
             QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
             QEMU_CAPS_DEVICE_VFIO_CCW);
 
-    DO_TEST_FULL("restore-v2", 0, 0,
+    DO_TEST_FULL("restore-v2", 0,
                  ARG_MIGRATE_FROM, "exec:cat", ARG_MIGRATE_FD, 7,
                  ARG_QEMU_CAPS, NONE);
-    DO_TEST_FULL("restore-v2-fd", 0, 0,
+    DO_TEST_FULL("restore-v2-fd", 0,
                  ARG_MIGRATE_FROM, "stdio", ARG_MIGRATE_FD, 7,
                  ARG_QEMU_CAPS, NONE);
-    DO_TEST_FULL("restore-v2-fd", 0, 0,
+    DO_TEST_FULL("restore-v2-fd", 0,
                  ARG_MIGRATE_FROM, "fd:7", ARG_MIGRATE_FD, 7,
                  ARG_QEMU_CAPS, NONE);
-    DO_TEST_FULL("migrate", 0, 0,
+    DO_TEST_FULL("migrate", 0,
                  ARG_MIGRATE_FROM, "tcp:10.0.0.1:5000",
                  ARG_QEMU_CAPS, NONE);
 
-    DO_TEST_FULL("migrate-numa-unaligned", 0, 0,
+    DO_TEST_FULL("migrate-numa-unaligned", 0,
                  ARG_MIGRATE_FROM, "stdio", ARG_MIGRATE_FD, 7,
                  ARG_QEMU_CAPS,
                  QEMU_CAPS_NUMA,
@@ -1767,11 +1773,12 @@  mymain(void)
     DO_TEST("cpu-host-model", NONE);
     DO_TEST("cpu-host-model-vendor", NONE);
     DO_TEST_FULL("cpu-host-model-fallback",
-                 FLAG_SKIP_LEGACY_CPUS, 0,
+                 0,
+                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS,
                  ARG_QEMU_CAPS, NONE);
     DO_TEST_FULL("cpu-host-model-nofallback",
-                 FLAG_SKIP_LEGACY_CPUS | FLAG_EXPECT_FAILURE,
                  0,
+                 ARG_FLAGS, FLAG_SKIP_LEGACY_CPUS | FLAG_EXPECT_FAILURE,
                  ARG_QEMU_CAPS, NONE);
     DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
     DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
@@ -2860,7 +2867,7 @@  mymain(void)
     DO_TEST("ppc64-usb-controller-legacy",
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
             QEMU_CAPS_PIIX3_USB_UHCI);
-    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci", 0,
+    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci",
                  VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                  ARG_QEMU_CAPS,
                  QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,