tests: Drop dirname argument from testQemuGetLatestCapsForArch()

As evidenced by all existing callers, the only directory it makes
sense to use is TEST_QEMU_CAPS_PATH, so let's just bake that into
the function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Andrea Bolognani 2019-04-16 12:26:22 +02:00
parent f0e48979c9
commit 3fe020a038
4 changed files with 9 additions and 14 deletions

View File

@ -327,8 +327,7 @@ mymain(void)
diskxmljsondata.driver = &driver; diskxmljsondata.driver = &driver;
if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata", if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch("x86_64", "xml")))
"x86_64", "xml")))
return EXIT_FAILURE; return EXIT_FAILURE;
VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64); VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64);

View File

@ -805,8 +805,7 @@ testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps,
char * char *
testQemuGetLatestCapsForArch(const char *dirname, testQemuGetLatestCapsForArch(const char *arch,
const char *arch,
const char *suffix) const char *suffix)
{ {
struct dirent *ent; struct dirent *ent;
@ -822,10 +821,10 @@ testQemuGetLatestCapsForArch(const char *dirname,
if (virAsprintf(&fullsuffix, "%s.%s", arch, suffix) < 0) if (virAsprintf(&fullsuffix, "%s.%s", arch, suffix) < 0)
goto cleanup; goto cleanup;
if (virDirOpen(&dir, dirname) < 0) if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
goto cleanup; goto cleanup;
while ((rc = virDirRead(dir, &ent, dirname)) > 0) { while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
VIR_FREE(tmp); VIR_FREE(tmp);
if ((rc = VIR_STRDUP(tmp, STRSKIP(ent->d_name, "caps_"))) < 0) if ((rc = VIR_STRDUP(tmp, STRSKIP(ent->d_name, "caps_"))) < 0)
@ -853,11 +852,11 @@ testQemuGetLatestCapsForArch(const char *dirname,
if (!maxname) { if (!maxname) {
VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'\n", VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'\n",
arch, dirname); arch, TEST_QEMU_CAPS_PATH);
goto cleanup; goto cleanup;
} }
ignore_value(virAsprintf(&ret, "%s/%s", dirname, maxname)); ignore_value(virAsprintf(&ret, "%s/%s", TEST_QEMU_CAPS_PATH, maxname));
cleanup: cleanup:
VIR_FREE(tmp); VIR_FREE(tmp);
@ -886,8 +885,7 @@ testQemuGetLatestCaps(void)
VIR_TEST_VERBOSE("\n"); VIR_TEST_VERBOSE("\n");
for (i = 0; i < ARRAY_CARDINALITY(archs); ++i) { for (i = 0; i < ARRAY_CARDINALITY(archs); ++i) {
char *cap = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata", char *cap = testQemuGetLatestCapsForArch(archs[i], "xml");
archs[i], "xml");
if (!cap || virHashAddEntry(capslatest, archs[i], cap) < 0) if (!cap || virHashAddEntry(capslatest, archs[i], cap) < 0)
goto error; goto error;

View File

@ -92,8 +92,7 @@ int qemuTestCapsCacheInsert(virFileCachePtr cache,
int testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps, int testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps,
int gic); int gic);
char *testQemuGetLatestCapsForArch(const char *dirname, char *testQemuGetLatestCapsForArch(const char *arch,
const char *arch,
const char *suffix); const char *suffix);
virHashTablePtr testQemuGetLatestCaps(void); virHashTablePtr testQemuGetLatestCaps(void);

View File

@ -533,8 +533,7 @@ testQEMUSchemaGetLatest(void)
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
virJSONValuePtr schema = NULL; virJSONValuePtr schema = NULL;
if (!(capsLatestFile = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata", if (!(capsLatestFile = testQemuGetLatestCapsForArch("x86_64", "replies"))) {
"x86_64", "replies"))) {
VIR_TEST_VERBOSE("failed to find latest caps replies\n"); VIR_TEST_VERBOSE("failed to find latest caps replies\n");
return NULL; return NULL;
} }