[PATCH 3/4] tests: More output options for xml2xml tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So far, qemuxml2xml test was only able to check if the result matches
the original or the appropriate XML in qemuxml2xmloutdata regardless on
flags used to format the XML. Since the result can be different
depending on VIR_DOMAIN_XML_INACTIVE flag being used or not, this patch
adds support for qemuxml2xmlout-%s-active.xml and
qemuxml2xmlout-%s-inactive.xml output files. If the file specific to the
flag used exists, it is used in preference to the generic
qemuxml2xmlout-%s.xml file when reading the expected output.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 tests/qemuxml2xmltest.c | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index bf9d736..abad2f4 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -81,31 +81,55 @@ testCompareXMLToXMLHelper(const void *data)
     const struct testInfo *info = data;
     char *xml_in = NULL;
     char *xml_out = NULL;
+    char *xml_out_active = NULL;
+    char *xml_out_inactive = NULL;
     int ret = -1;
 
     if (virAsprintf(&xml_in, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
                     abs_srcdir, info->name) < 0 ||
         virAsprintf(&xml_out, "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s.xml",
+                    abs_srcdir, info->name) < 0 ||
+        virAsprintf(&xml_out_active,
+                    "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s-active.xml",
+                    abs_srcdir, info->name) < 0 ||
+        virAsprintf(&xml_out_inactive,
+                    "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s-inactive.xml",
                     abs_srcdir, info->name) < 0)
         goto cleanup;
 
-    if ((info->when & WHEN_INACTIVE) &&
-        testCompareXMLToXMLFiles(xml_in,
-                                 info->different ? xml_out : xml_in,
-                                 false) < 0)
-        goto cleanup;
+    if ((info->when & WHEN_INACTIVE)) {
+        char *out;
+        if (!info->different)
+            out = xml_in;
+        else if (virFileExists(xml_out_inactive))
+            out = xml_out_inactive;
+        else
+            out = xml_out;
+
+        if (testCompareXMLToXMLFiles(xml_in, out, false) < 0)
+            goto cleanup;
+    }
 
-    if ((info->when & WHEN_ACTIVE) &&
-        testCompareXMLToXMLFiles(xml_in,
-                                 info->different ? xml_out : xml_in,
-                                 true) < 0)
-        goto cleanup;
+    if ((info->when & WHEN_ACTIVE)) {
+        char *out;
+        if (!info->different)
+            out = xml_in;
+        else if (virFileExists(xml_out_active))
+            out = xml_out_active;
+        else
+            out = xml_out;
+
+        if (testCompareXMLToXMLFiles(xml_in, out, true) < 0)
+            goto cleanup;
+    }
 
     ret = 0;
 
  cleanup:
     VIR_FREE(xml_in);
     VIR_FREE(xml_out);
+    VIR_FREE(xml_out_active);
+    VIR_FREE(xml_out_inactive);
     return ret;
 }
 
-- 
1.9.2

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]