9c6c51
From d87b6566d14526883e9439ebd3f922fc7ed22abb Mon Sep 17 00:00:00 2001
9c6c51
Message-Id: <d87b6566d14526883e9439ebd3f922fc7ed22abb@dist-git>
9c6c51
From: Bjoern Walk <bwalk@linux.ibm.com>
9c6c51
Date: Wed, 17 Apr 2019 14:46:00 +0200
9c6c51
Subject: [PATCH] tests: qemuxml2argv: add CAPS_ARCH_LATEST macro
9c6c51
MIME-Version: 1.0
9c6c51
Content-Type: text/plain; charset=UTF-8
9c6c51
Content-Transfer-Encoding: 8bit
9c6c51
9c6c51
Testing with the latest capabilities is possible with the x86_64 centric
9c6c51
implemented macro CAPS_LATEST. The new macro CAPS_ARCH_LATEST provides
9c6c51
the user the ability to specify the desired architecture when testing with
9c6c51
the latest capabilities.
9c6c51
9c6c51
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
9c6c51
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
9c6c51
(cherry picked from commit bc4c83838d51f42b86d189280c9011494ef435f0)
9c6c51
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9c6c51
9c6c51
RHEL 8.1: https://bugzilla.redhat.com/show_bug.cgi?id=1698855
9c6c51
Message-Id: <c75aeb78417e458e1fc0c9a5994e4d462cf1c0a0.1555505143.git.jtomko@redhat.com>
9c6c51
9c6c51
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
9c6c51
---
9c6c51
 tests/qemuxml2argvtest.c | 31 +++++++++++++++++++++++--------
9c6c51
 1 file changed, 23 insertions(+), 8 deletions(-)
9c6c51
9c6c51
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
9c6c51
index 690a39054e..abb256c913 100644
9c6c51
--- a/tests/qemuxml2argvtest.c
9c6c51
+++ b/tests/qemuxml2argvtest.c
9c6c51
@@ -623,10 +623,11 @@ testCompareXMLToArgv(const void *data)
9c6c51
 static int
9c6c51
 mymain(void)
9c6c51
 {
9c6c51
-    int ret = 0;
9c6c51
+    int ret = 0, i;
9c6c51
     char *fakerootdir;
9c6c51
     bool skipLegacyCPUs = false;
9c6c51
-    char *capslatest_x86_64 = NULL;
9c6c51
+    const char *archs[] = { "x86_64", "s390x" };
9c6c51
+    virHashTablePtr capslatest = NULL;
9c6c51
 
9c6c51
     if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
9c6c51
         fprintf(stderr, "Out of memory\n");
9c6c51
@@ -695,12 +696,23 @@ mymain(void)
9c6c51
     if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0)
9c6c51
         return EXIT_FAILURE;
9c6c51
 
9c6c51
-    if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata",
9c6c51
-                                                           "x86_64", "xml")))
9c6c51
+    capslatest = virHashCreate(4, virHashValueFree);
9c6c51
+    if (!capslatest)
9c6c51
         return EXIT_FAILURE;
9c6c51
 
9c6c51
-    VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64);
9c6c51
+    VIR_TEST_VERBOSE("\n");
9c6c51
 
9c6c51
+    for (i = 0; i < ARRAY_CARDINALITY(archs); ++i) {
9c6c51
+        char *cap = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata",
9c6c51
+                                                 archs[i], "xml");
9c6c51
+
9c6c51
+        if (!cap || virHashAddEntry(capslatest, archs[i], cap) < 0)
9c6c51
+            return EXIT_FAILURE;
9c6c51
+
9c6c51
+        VIR_TEST_VERBOSE("latest caps for %s: %s\n", archs[i], cap);
9c6c51
+    }
9c6c51
+
9c6c51
+    VIR_TEST_VERBOSE("\n");
9c6c51
 
9c6c51
 /**
9c6c51
  * The following set of macros allows testing of XML -> argv conversion with a
9c6c51
@@ -748,9 +760,12 @@ mymain(void)
9c6c51
 # define DO_TEST_CAPS_VER(name, ver) \
9c6c51
     DO_TEST_CAPS_ARCH_VER(name, "x86_64", ver)
9c6c51
 
9c6c51
+# define DO_TEST_CAPS_ARCH_LATEST(name, arch) \
9c6c51
+    DO_TEST_CAPS_INTERNAL(name, arch "-latest", NULL, 0, 0, arch, \
9c6c51
+                          virHashLookup(capslatest, arch), true)
9c6c51
+
9c6c51
 # define DO_TEST_CAPS_LATEST(name) \
9c6c51
-    DO_TEST_CAPS_INTERNAL(name, "x86_64-latest", NULL, 0, 0, "x86_64", \
9c6c51
-                          capslatest_x86_64, true)
9c6c51
+    DO_TEST_CAPS_ARCH_LATEST(name, "x86_64")
9c6c51
 
9c6c51
 /**
9c6c51
  * The following test macros should be used only in cases when the tests require
9c6c51
@@ -2966,7 +2981,7 @@ mymain(void)
9c6c51
     VIR_FREE(driver.config->nbdTLSx509certdir);
9c6c51
     qemuTestDriverFree(&driver);
9c6c51
     VIR_FREE(fakerootdir);
9c6c51
-    VIR_FREE(capslatest_x86_64);
9c6c51
+    virHashFree(capslatest);
9c6c51
 
9c6c51
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
9c6c51
 }
9c6c51
-- 
9c6c51
2.21.0
9c6c51