]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemuxml2argv: add testInfoSetPaths
authorCole Robinson <crobinso@redhat.com>
Sun, 31 Mar 2019 15:08:19 +0000 (11:08 -0400)
committerCole Robinson <crobinso@redhat.com>
Wed, 10 Apr 2019 23:05:08 +0000 (19:05 -0400)
This moves infile and outfile building outside the test case,
which better fits the pattern of qemuxml2xmltest. It also lets us
drop the qemuxml2argtest-specific 'suffix' from testInfo

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
tests/qemuxml2argvtest.c

index 680b983665fb711b84335082792621e258dc5fa4..555a7a13d033d96f00a1016e1d4a660443690d49 100644 (file)
@@ -298,7 +298,6 @@ typedef enum {
 
 struct testInfo {
     const char *name;
-    const char *suffix;
     char *infile;
     char *outfile;
     virQEMUCapsPtr qemuCaps;
@@ -431,7 +430,6 @@ testCompareXMLToArgv(const void *data)
     struct testInfo *info = (void *) data;
     char *migrateURI = NULL;
     char *actualargv = NULL;
-    const char *suffix = info->suffix;
     unsigned int flags = info->flags;
     unsigned int parseFlags = info->parseFlags;
     int ret = -1;
@@ -448,9 +446,6 @@ testCompareXMLToArgv(const void *data)
     if (!(conn = virGetConnect()))
         goto cleanup;
 
-    if (!suffix)
-        suffix = "";
-
     conn->secretDriver = &fakeSecretDriver;
     conn->storageDriver = &fakeStorageDriver;
     conn->nwfilterDriver = &fakeNWFilterDriver;
@@ -471,12 +466,6 @@ testCompareXMLToArgv(const void *data)
     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
         goto cleanup;
 
-    if (virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
-                    abs_srcdir, info->name) < 0 ||
-        virAsprintf(&info->outfile, "%s/qemuxml2argvdata/%s%s.args",
-                    abs_srcdir, info->name, suffix) < 0)
-        goto cleanup;
-
     if (info->migrateFrom &&
         !(migrateURI = qemuMigrationDstGetURI(info->migrateFrom,
                                               info->migrateFd)))
@@ -758,6 +747,20 @@ testInfoClear(struct testInfo *info)
     virObjectUnref(info->qemuCaps);
 }
 
+static int
+testInfoSetPaths(struct testInfo *info,
+                 const char *suffix)
+{
+    if (virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
+                    abs_srcdir, info->name) < 0 ||
+        virAsprintf(&info->outfile, "%s/qemuxml2argvdata/%s%s.args",
+                    abs_srcdir, info->name, suffix ? suffix : "") < 0) {
+        return -1;
+    }
+
+    return 0;
+}
+
 # define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
 
 static int
@@ -883,11 +886,14 @@ mymain(void)
     do { \
         static struct testInfo info = { \
             .name = _name, \
-            .suffix = _suffix, \
         }; \
         if (testInfoSetArgs(&info, capslatest, \
                             __VA_ARGS__, ARG_END) < 0) \
             return EXIT_FAILURE; \
+        if (testInfoSetPaths(&info, _suffix) < 0) { \
+            VIR_TEST_DEBUG("Failed to generate paths for '%s'", _name); \
+            return EXIT_FAILURE; \
+        } \
         if (virTestRun("QEMU XML-2-ARGV " _name _suffix, \
                        testCompareXMLToArgv, &info) < 0) \
             ret = -1; \