[17/21] tests: qemuxml2argv: build capsfile in DO_TEST_CAPS_INTERNAL

Message ID 3ff1cdf384d4f47a84ff76a894374d618c83732a.1552574299.git.crobinso@redhat.com
State Accepted
Commit 5eaaa10679d5ea7c696ce21863b8e310dc55acc7
Headers show
Series
  • tests: qemuxml2argv: support optional arguments
Related show

Commit Message

Cole Robinson March 14, 2019, 2:44 p.m.
Rather than make callers do it. The operative info is just arch
and ver which we are passing in already.

Fold in stripmachinealiases too since it is just dependent on
ver value

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

---
 tests/qemuxml2argvtest.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 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, 2:27 p.m. | #1
On Thu, 2019-03-14 at 10:44 -0400, Cole Robinson wrote:
> Rather than make callers do it. The operative info is just arch

> and ver which we are passing in already.

> 

> Fold in stripmachinealiases too since it is just dependent on

> ver value

> 

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

> ---

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

>  1 file changed, 11 insertions(+), 12 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 4b34bbcb63..496e33f4e5 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -786,13 +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, arch, ver, \
-                               capsfile, stripmachinealiases, ...) \
+# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata/caps_"
+
+# define DO_TEST_CAPS_INTERNAL(_name, arch, ver, ...) \
     do { \
         static struct testInfo info = { \
             .name = _name, \
             .suffix = "." arch "-" ver, \
         }; \
+        static const char *capsfile = TEST_CAPS_PATH ver "." arch ".xml"; \
+        static bool stripmachinealiases; \
+        if (STREQ(ver, "latest")) { \
+            capsfile = virHashLookup(capslatest, arch); \
+            stripmachinealiases = true; \
+        } \
         if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
                                                             capsfile))) \
             return EXIT_FAILURE; \
@@ -807,23 +814,15 @@  mymain(void)
         virObjectUnref(info.qemuCaps); \
     } while (0)
 
-# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata/caps_"
-
-# define DO_TEST_CAPS_ARCH_VER_FULL(name, arch, ver, ...) \
-    DO_TEST_CAPS_INTERNAL(name, arch, ver, \
-                          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, arch, ver, ARG_END)
+    DO_TEST_CAPS_INTERNAL(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, ...) \
-    DO_TEST_CAPS_INTERNAL(name, arch, "latest", \
-                          virHashLookup(capslatest, arch), true, \
-                          __VA_ARGS__)
+    DO_TEST_CAPS_INTERNAL(name, arch, "latest", __VA_ARGS__)
 
 # define DO_TEST_CAPS_ARCH_LATEST(name, arch) \
     DO_TEST_CAPS_ARCH_LATEST_FULL(name, arch, ARG_END)