diff mbox

[5/5] tests: lxcconf2xml: Drop XML blanking

Message ID 2dc5c766c10be02d62aef58661f4215403391a16.1455644471.git.crobinso@redhat.com
State Accepted
Commit 1064fb33148e5001ed7a7fc4d5ba4441446125cb
Headers show

Commit Message

Cole Robinson Feb. 16, 2016, 5:44 p.m. UTC
Hardcode a UUID like we did for qemuargv2xml, so we can use standard
comparison helpers, which gives us VIR_TEST_REGENERATE_OUTPUT support
---
 tests/lxcconf2xmltest.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

-- 
2.5.0

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

Patch

diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c
index fc071f7..83895cd 100644
--- a/tests/lxcconf2xmltest.c
+++ b/tests/lxcconf2xmltest.c
@@ -13,22 +13,21 @@ 
 static virCapsPtr caps;
 static virDomainXMLOptionPtr xmlopt;
 
-static int
-blankProblemElements(char *data)
+static int testSanitizeDef(virDomainDefPtr vmdef)
 {
-    if (virtTestClearLineRegex("<uuid>([[:alnum:]]|-)+</uuid>", data) < 0)
+    /* Remove UUID randomness */
+    if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", vmdef->uuid) < 0)
         return -1;
     return 0;
 }
 
 static int
-testCompareXMLToConfigFiles(const char *xml,
+testCompareXMLToConfigFiles(const char *xmlfile,
                             const char *configfile,
                             bool expectError)
 {
     int ret = -1;
     char *config = NULL;
-    char *expectxml = NULL;
     char *actualxml = NULL;
     virDomainDefPtr vmdef = NULL;
 
@@ -40,26 +39,19 @@  testCompareXMLToConfigFiles(const char *xml,
         goto fail;
 
     if (vmdef) {
-        if (!(actualxml = virDomainDefFormat(vmdef, caps, 0)))
+        if (testSanitizeDef(vmdef) < 0)
             goto fail;
 
-        if (virtTestLoadFile(xml, &expectxml) < 0)
-            goto fail;
-
-        if (blankProblemElements(expectxml) < 0 ||
-            blankProblemElements(actualxml) < 0)
+        if (!(actualxml = virDomainDefFormat(vmdef, caps, 0)))
             goto fail;
 
-        if (STRNEQ(expectxml, actualxml)) {
-            virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL);
+        if (virtTestCompareToFile(actualxml, xmlfile) < 0)
             goto fail;
-        }
     }
 
     ret = 0;
 
  fail:
-    VIR_FREE(expectxml);
     VIR_FREE(actualxml);
     VIR_FREE(config);
     virDomainDefFree(vmdef);