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