@@ -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",
@@ -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;
+}
@@ -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
Move the capslatest building from qemuxml2argv to testutilsqemu Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/qemuxml2argvtest.c | 25 ++----------------------- tests/testutilsqemu.c | 37 +++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 1 + 3 files changed, 40 insertions(+), 23 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list