diff mbox series

[14/21] tests: qemuxml2argv: use varargs for CAPS flags

Message ID 1b8192f82c70865feaec767456508eed2263d022.1552574299.git.crobinso@redhat.com
State Accepted
Commit c824ce1ba0907180aadedaae568bc0c09e9cf3c7
Headers show
Series tests: qemuxml2argv: support optional arguments | expand

Commit Message

Cole Robinson March 14, 2019, 2:44 p.m. UTC
Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 tests/qemuxml2argvtest.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 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:55 p.m. UTC | #1
On Thu, 2019-03-14 at 10:44 -0400, Cole Robinson wrote:
[...]
> +# define DO_TEST_CAPS_INTERNAL(name, suffix, \

> +                               arch, capsfile, stripmachinealiases, ...) \

>      do { \

>          static struct testInfo info = { \

> -            name, "." suffix, NULL, NULL, -1,\

> -            (flags | FLAG_REAL_CAPS), parseFlags, \

> +            name, "." suffix, NULL, NULL, -1, 0, 0, \

>          }; \

>          if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \

>                                                              capsfile))) \

>              return EXIT_FAILURE; \

>          if (stripmachinealiases) \

>              virQEMUCapsStripMachineAliases(info.qemuCaps); \

> +        if (testInfoSetArgs(&info, __VA_ARGS__, ARG_END) < 0) \

> +            return EXIT_FAILURE; \


Since you already have an explicit ARG_END here, it's kinda ugly
that you need another one...

[...]
> +# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \

> +    DO_TEST_CAPS_INTERNAL(name, arch "-" ver, \

> +                          arch, TEST_CAPS_PATH ver "." arch ".xml", false, \

> +                          __VA_ARGS__)

>  

>  # define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \

> -    DO_TEST_CAPS_ARCH_VER_FULL(name, 0, 0, arch, ver)

> +    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END)


... both here...

[...]
> +# define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \

> +    DO_TEST_CAPS_INTERNAL(name, arch "-latest", arch, \

> +                          virHashLookup(capslatest, arch), true, \

> +                          __VA_ARGS__)

>  

>  # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \

> -    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, 0, 0)

> +    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)


... and here, but the underlying macro can't take zero variadic
arguments so there's no way around it I guess...

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
diff mbox series

Patch

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7708e8db70..176e4eff3e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -786,18 +786,20 @@  mymain(void)
  * the test cases should be forked using DO_TEST_CAPS_VER with the appropriate
  * version.
  */
-# define DO_TEST_CAPS_INTERNAL(name, suffix, flags, parseFlags, \
-                               arch, capsfile, stripmachinealiases) \
+# define DO_TEST_CAPS_INTERNAL(name, suffix, \
+                               arch, capsfile, stripmachinealiases, ...) \
     do { \
         static struct testInfo info = { \
-            name, "." suffix, NULL, NULL, -1,\
-            (flags | FLAG_REAL_CAPS), parseFlags, \
+            name, "." suffix, NULL, NULL, -1, 0, 0, \
         }; \
         if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
                                                             capsfile))) \
             return EXIT_FAILURE; \
         if (stripmachinealiases) \
             virQEMUCapsStripMachineAliases(info.qemuCaps); \
+        if (testInfoSetArgs(&info, __VA_ARGS__, ARG_END) < 0) \
+            return EXIT_FAILURE; \
+        info.flags |= FLAG_REAL_CAPS; \
         if (virTestRun("QEMU XML-2-ARGV " name "." suffix, \
                        testCompareXMLToArgv, &info) < 0) \
             ret = -1; \
@@ -806,31 +808,35 @@  mymain(void)
 
 # define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata/caps_"
 
-# define DO_TEST_CAPS_ARCH_VER_FULL(name, flags, parseFlags, arch, ver) \
-    DO_TEST_CAPS_INTERNAL(name, arch "-" ver, flags, parseFlags, \
-                          arch, TEST_CAPS_PATH ver "." arch ".xml", false)
+# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \
+    DO_TEST_CAPS_INTERNAL(name, arch "-" ver, \
+                          arch, TEST_CAPS_PATH ver "." arch ".xml", false, \
+                          __VA_ARGS__)
 
 # define DO_TEST_CAPS_ARCH_VER(name, arch, ver) \
-    DO_TEST_CAPS_ARCH_VER_FULL(name, 0, 0, arch, ver)
+    DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ARG_END)
 
 # define DO_TEST_CAPS_VER(name, ver) \
     DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)
 
-# define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, flags, parseFlags) \
-    DO_TEST_CAPS_INTERNAL(name, arch "-latest", flags, parseFlags, arch, \
-                          virHashLookup(capslatest, arch), true)
+# define DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ...) \
+    DO_TEST_CAPS_INTERNAL(name, arch "-latest", arch, \
+                          virHashLookup(capslatest, arch), true, \
+                          __VA_ARGS__)
 
 # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \
-    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, 0, 0)
+    DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)
 
 # define DO_TEST_CAPS_LATEST(name) \
     DO_TEST_CAPS_ARCH_LATEST(name, "x86_64")
 
 # define DO_TEST_CAPS_LATEST_FAILURE(name) \
-    DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", FLAG_EXPECT_FAILURE, 0)
+    DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \
+                                  ARG_FLAGS, FLAG_EXPECT_FAILURE)
 
 # define DO_TEST_CAPS_LATEST_PARSE_ERROR(name) \
-    DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", FLAG_EXPECT_PARSE_ERROR, 0)
+    DO_TEST_CAPS_ARCH_LATEST_FULL(name, "x86_64", \
+                                  ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR)
 
 
 /* All the following macros require an explicit QEMU_CAPS_* list