[PATCH 4/6] tests: qemuxml2xml: drop early file loading

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

 



For the standard active/inactive XML testing, if we leave the file loading
up to the generic XML2XML infrastructure, we get the benefit of
VIR_TEST_REGENERATE_OUTPUT, at the price of a few more disk reads. Seems
worth it.
---
 tests/qemuxml2xmltest.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 312bb53..9482f6c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -30,13 +30,8 @@ enum {
 
 struct testInfo {
     char *inName;
-    char *inFile;
-
     char *outActiveName;
-    char *outActiveFile;
-
     char *outInactiveName;
-    char *outInactiveFile;
 };
 
 static int
@@ -95,13 +90,19 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
     char *expect = NULL;
     char *actual = NULL;
     char *source = NULL;
+    char *inFile = NULL, *outActiveFile = NULL;
     int ret = -1;
     int keepBlanksDefault = xmlKeepBlanksDefault(0);
 
+    if (virtTestLoadFile(data->inName, &inFile) < 0)
+        goto cleanup;
+    if (virtTestLoadFile(data->outActiveName, &outActiveFile) < 0)
+        goto cleanup;
+
     /* construct faked source status XML */
     virBufferAdd(&buf, testStatusXMLPrefix, -1);
     virBufferAdjustIndent(&buf, 2);
-    virBufferAddStr(&buf, data->inFile);
+    virBufferAddStr(&buf, inFile);
     virBufferAdjustIndent(&buf, -2);
     virBufferAdd(&buf, testStatusXMLSuffix, -1);
 
@@ -113,7 +114,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
     /* construct the expect string */
     virBufferAdd(&buf, testStatusXMLPrefix, -1);
     virBufferAdjustIndent(&buf, 2);
-    virBufferAddStr(&buf, data->outActiveFile);
+    virBufferAddStr(&buf, outActiveFile);
     virBufferAdjustIndent(&buf, -2);
     virBufferAdd(&buf, testStatusXMLSuffix, -1);
 
@@ -158,6 +159,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
     VIR_FREE(expect);
     VIR_FREE(actual);
     VIR_FREE(source);
+    VIR_FREE(inFile);
+    VIR_FREE(outActiveFile);
     return ret;
 }
 
@@ -166,13 +169,8 @@ static void
 testInfoFree(struct testInfo *info)
 {
     VIR_FREE(info->inName);
-    VIR_FREE(info->inFile);
-
     VIR_FREE(info->outActiveName);
-    VIR_FREE(info->outActiveFile);
-
     VIR_FREE(info->outInactiveName);
-    VIR_FREE(info->outInactiveFile);
 }
 
 
@@ -186,9 +184,6 @@ testInfoSet(struct testInfo *info,
                     abs_srcdir, name) < 0)
         goto error;
 
-    if (virtTestLoadFile(info->inName, &info->inFile) < 0)
-        goto error;
-
     if (when & WHEN_INACTIVE) {
         if (different) {
             if (virAsprintf(&info->outInactiveName,
@@ -208,9 +203,6 @@ testInfoSet(struct testInfo *info,
             if (VIR_STRDUP(info->outInactiveName, info->inName) < 0)
                 goto error;
         }
-
-        if (virtTestLoadFile(info->outInactiveName, &info->outInactiveFile) < 0)
-            goto error;
     }
 
     if (when & WHEN_ACTIVE) {
@@ -233,8 +225,6 @@ testInfoSet(struct testInfo *info,
                 goto error;
         }
 
-        if (virtTestLoadFile(info->outActiveName, &info->outActiveFile) < 0)
-            goto error;
     }
 
     return 0;
-- 
2.5.0

--
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]