]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemudomainsnapshotxml2xmltest: Allow regenerating into non-existing output file
authorPeter Krempa <pkrempa@redhat.com>
Thu, 25 Aug 2022 09:05:39 +0000 (11:05 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 1 Sep 2022 11:11:09 +0000 (13:11 +0200)
Replacing the 'virTestLoadFile' + 'virTestDifferenceFull' by '
virTestCompareToFile' allows to use the VIR_TEST_REGENERATE_OUTPUT=1
option to also generate the output file if it doesn't exist.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemudomainsnapshotxml2xmltest.c

index 2f66839ae808953193640994395c6c9d44e87866..6881d692eed8c695073eba19b0994161dbb5d949 100644 (file)
@@ -30,7 +30,6 @@ testCompareXMLToXMLFiles(const char *inxml,
                          unsigned int flags)
 {
     g_autofree char *inXmlData = NULL;
-    g_autofree char *outXmlData = NULL;
     g_autofree char *actual = NULL;
     unsigned int parseflags = 0;
     unsigned int formatflags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE;
@@ -48,9 +47,6 @@ testCompareXMLToXMLFiles(const char *inxml,
     if (virTestLoadFile(inxml, &inXmlData) < 0)
         return -1;
 
-    if (virTestLoadFile(outxml, &outXmlData) < 0)
-        return -1;
-
     if (!(def = virDomainSnapshotDefParseString(inXmlData,
                                                 driver.xmlopt, NULL, &cur,
                                                 parseflags)))
@@ -71,10 +67,8 @@ testCompareXMLToXMLFiles(const char *inxml,
                                               formatflags)))
         return -1;
 
-    if (STRNEQ(outXmlData, actual)) {
-        virTestDifferenceFull(stderr, outXmlData, outxml, actual, inxml);
+    if (virTestCompareToFile(actual, outxml) < 0)
         return -1;
-    }
 
     return 0;
 }