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

Cole Robinson posted 21 patches 6 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH 14/21] tests: qemuxml2argv: use varargs for CAPS flags
Posted by Cole Robinson 6 years, 11 months ago
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 tests/qemuxml2argvtest.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

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
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 14/21] tests: qemuxml2argv: use varargs for CAPS flags
Posted by Andrea Bolognani 6 years, 10 months ago
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