[04/12] tests: qemuxml2argv: Add info->{in, out}file

Message ID 30eaad11068f933f64ac07af35495bb5b2953377.1554137098.git.crobinso@redhat.com
State Accepted
Commit 2d3ba1bf061ad84ddb1d2deb29dd4a11894b7e07
Headers show
Series
  • tests: qemuxml2xml: add DO_TEST_CAPS*
Related show

Commit Message

Cole Robinson April 1, 2019, 4:47 p.m.
Track infile and outfile in testInfo. This is step towards moving path
creation out of the test case, which will eventually help sharing more
code with qemuxml2xmltest.c

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 tests/qemuxml2argvtest.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Andrea Bolognani April 10, 2019, 3:52 p.m. | #1
On Mon, 2019-04-01 at 12:47 -0400, Cole Robinson wrote:
> Track infile and outfile in testInfo. This is step towards moving path

> creation out of the test case, which will eventually help sharing more

> code with qemuxml2xmltest.c

> 

> Signed-off-by: Cole Robinson <crobinso@redhat.com>

> ---

>  tests/qemuxml2argvtest.c | 19 ++++++++++---------

>  1 file changed, 10 insertions(+), 9 deletions(-)


Reviewed-by: Andrea Bolognani <abologna@redhat.com>


-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Patch

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0c0dcae197..ff7bacf8db 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -299,6 +299,8 @@  typedef enum {
 struct testInfo {
     const char *name;
     const char *suffix;
+    char *infile;
+    char *outfile;
     virQEMUCapsPtr qemuCaps;
     const char *migrateFrom;
     int migrateFd;
@@ -427,8 +429,6 @@  static int
 testCompareXMLToArgv(const void *data)
 {
     struct testInfo *info = (void *) data;
-    char *xml = NULL;
-    char *args = NULL;
     char *migrateURI = NULL;
     char *actualargv = NULL;
     const char *suffix = info->suffix;
@@ -471,9 +471,9 @@  testCompareXMLToArgv(const void *data)
     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
         goto cleanup;
 
-    if (virAsprintf(&xml, "%s/qemuxml2argvdata/%s.xml",
+    if (virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
                     abs_srcdir, info->name) < 0 ||
-        virAsprintf(&args, "%s/qemuxml2argvdata/%s%s.args",
+        virAsprintf(&info->outfile, "%s/qemuxml2argvdata/%s%s.args",
                     abs_srcdir, info->name, suffix) < 0)
         goto cleanup;
 
@@ -486,7 +486,8 @@  testCompareXMLToArgv(const void *data)
         goto cleanup;
 
     parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
-    if (!(vm->def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
+    if (!(vm->def = virDomainDefParseFile(info->infile,
+                                          driver.caps, driver.xmlopt,
                                           NULL, parseFlags))) {
         if (flags & FLAG_EXPECT_PARSE_ERROR)
             goto ok;
@@ -502,7 +503,7 @@  testCompareXMLToArgv(const void *data)
         goto cleanup;
 
     if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) {
-        VIR_TEST_DEBUG("ABI stability check failed on %s", xml);
+        VIR_TEST_DEBUG("ABI stability check failed on %s", info->infile);
         goto cleanup;
     }
 
@@ -570,7 +571,7 @@  testCompareXMLToArgv(const void *data)
     if (!(actualargv = virCommandToString(cmd, false)))
         goto cleanup;
 
-    if (virTestCompareToFile(actualargv, args) < 0)
+    if (virTestCompareToFile(actualargv, info->outfile) < 0)
         goto cleanup;
 
     ret = 0;
@@ -600,8 +601,6 @@  testCompareXMLToArgv(const void *data)
     virSetConnectStorage(NULL);
     virObjectUnref(conn);
     VIR_FREE(migrateURI);
-    VIR_FREE(xml);
-    VIR_FREE(args);
     return ret;
 }
 
@@ -754,6 +753,8 @@  testInfoSetArgs(struct testInfo *info,
 static void
 testInfoClear(struct testInfo *info)
 {
+    VIR_FREE(info->infile);
+    VIR_FREE(info->outfile);
     virObjectUnref(info->qemuCaps);
 }