[libvirt] [PATCH v2 2/7] tests: qemuxml2argv: Add infrastructure to pass output file suffix

Peter Krempa pkrempa at redhat.com
Wed Apr 18 09:38:42 UTC 2018


To allow having more than one output file in the qemuxml2argvtest add a
suffix member to the testInfo struct which will allow testing the same
XML file with multiple capabilities files.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/qemuxml2argvtest.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7732116604..31218652ce 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -270,6 +270,7 @@ typedef enum {

 struct testInfo {
     const char *name;
+    const char *suffix;
     virQEMUCapsPtr qemuCaps;
     const char *migrateFrom;
     int migrateFd;
@@ -442,6 +443,7 @@ testCompareXMLToArgv(const void *data)
     char *args = NULL;
     char *migrateURI = NULL;
     char *actualargv = NULL;
+    const char *suffix = info->suffix;
     unsigned int flags = info->flags;
     unsigned int parseFlags = info->parseFlags;
     int ret = -1;
@@ -458,6 +460,9 @@ testCompareXMLToArgv(const void *data)
     if (!(conn = virGetConnect()))
         goto cleanup;

+    if (!suffix)
+        suffix = "";
+
     conn->secretDriver = &fakeSecretDriver;
     conn->storageDriver = &fakeStorageDriver;

@@ -472,8 +477,8 @@ testCompareXMLToArgv(const void *data)

     if (virAsprintf(&xml, "%s/qemuxml2argvdata/%s.xml",
                     abs_srcdir, info->name) < 0 ||
-        virAsprintf(&args, "%s/qemuxml2argvdata/%s.args",
-                    abs_srcdir, info->name) < 0)
+        virAsprintf(&args, "%s/qemuxml2argvdata/%s%s.args",
+                    abs_srcdir, info->name, suffix) < 0)
         goto cleanup;

     if (info->migrateFrom &&
@@ -657,7 +662,7 @@ mymain(void)
                       parseFlags, gic, ...) \
     do { \
         static struct testInfo info = { \
-            name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
+            name, NULL, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
             false, NULL \
         }; \
         info.skipLegacyCPUs = skipLegacyCPUs; \
-- 
2.16.2




More information about the libvir-list mailing list