Move the capslatest building from qemuxml2argv to testutilsqemu
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
tests/qemuxml2argvtest.c | 25 ++-----------------------
tests/testutilsqemu.c | 37 +++++++++++++++++++++++++++++++++++++
tests/testutilsqemu.h | 1 +
3 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a51bdb2453..b2dda3845d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -590,15 +590,8 @@ testInfoSetPaths(struct testQemuInfo *info, const char *suffix)
static int
mymain(void)
{
- int ret = 0, i;
+ int ret = 0;
char *fakerootdir;
- const char *archs[] = {
- "aarch64",
- "ppc64",
- "riscv64",
- "s390x",
- "x86_64",
- };
virHashTablePtr capslatest = NULL;
if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
@@ -667,24 +660,10 @@ mymain(void)
if (VIR_STRDUP(driver.config->nvramDir, "/var/lib/libvirt/qemu/nvram")
< 0)
return EXIT_FAILURE;
- capslatest = virHashCreate(4, virHashValueFree);
+ capslatest = testQemuGetCapsLatest();
if (!capslatest)
return EXIT_FAILURE;
- 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");
-
virFileWrapperAddPrefix(SYSCONFDIR "/qemu/firmware",
abs_srcdir "/qemufirmwaredata/etc/qemu/firmware");
virFileWrapperAddPrefix(PREFIX "/share/qemu/firmware",
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 6286c7b3c7..66464d4101 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -1062,3 +1062,40 @@ testQemuInfoClear(struct testQemuInfo *info)
VIR_FREE(info->outfile);
virObjectUnref(info->qemuCaps);
}
+
+
+virHashTablePtr
+testQemuGetCapsLatest(void)
+{
+ const char *archs[] = {
+ "aarch64",
+ "ppc64",
+ "riscv64",
+ "s390x",
+ "x86_64",
+ };
+ virHashTablePtr capslatest;
+ size_t i;
+
+ if (!(capslatest = virHashCreate(4, virHashValueFree)))
+ goto error;
+
+ 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)
+ goto error;
+
+ VIR_TEST_VERBOSE("latest caps for %s: %s\n", archs[i], cap);
+ }
+
+ VIR_TEST_VERBOSE("\n");
+ return capslatest;
+
+ error:
+ virHashFree(capslatest);
+ return NULL;
+}
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index f6ae2a38d3..6d4719dc12 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -109,6 +109,7 @@ int testQemuCapsIterate(const char *dirname,
int testQemuInfoSetArgs(struct testQemuInfo *info,
virHashTablePtr capslatest, ...);
void testQemuInfoClear(struct testQemuInfo *info);
+virHashTablePtr testQemuGetCapsLatest(void);
# endif
--
2.21.0