[PATCH 05/10] tests: use virtTestDifferenceFull in tests where we have output file

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

 



This will enable regenerate functionality for those tests to make
developer lives easier while updating tests.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 tests/domainsnapshotxml2xmltest.c |  2 +-
 tests/interfacexml2xmltest.c      |  2 +-
 tests/lxcconf2xmltest.c           |  2 +-
 tests/nodedevxml2xmltest.c        |  2 +-
 tests/qemuargv2xmltest.c          |  7 ++++---
 tests/qemuhotplugtest.c           | 11 ++++++++---
 tests/vboxsnapshotxmltest.c       |  2 +-
 7 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index cd91cfa..cf91447 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -114,7 +114,7 @@ testCompareXMLToXMLFiles(const char *inxml,
     }
 
     if (STRNEQ(outXmlData, actual)) {
-        virtTestDifference(stderr, outXmlData, actual);
+        virtTestDifferenceFull(stderr, outXmlData, outxml, actual, inxml);
         goto cleanup;
     }
 
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c
index 65f5167..ba34746 100644
--- a/tests/interfacexml2xmltest.c
+++ b/tests/interfacexml2xmltest.c
@@ -34,7 +34,7 @@ testCompareXMLToXMLFiles(const char *xml)
         goto fail;
 
     if (STRNEQ(xmlData, actual)) {
-        virtTestDifference(stderr, xmlData, actual);
+        virtTestDifferenceFull(stderr, xmlData, xml, actual, NULL);
         goto fail;
     }
 
diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c
index ed21e8a..fd5bc03 100644
--- a/tests/lxcconf2xmltest.c
+++ b/tests/lxcconf2xmltest.c
@@ -51,7 +51,7 @@ testCompareXMLToConfigFiles(const char *xml,
             goto fail;
 
         if (STRNEQ(expectxml, actualxml)) {
-            virtTestDifference(stderr, expectxml, actualxml);
+            virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL);
             goto fail;
         }
     }
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index a37d729..0089b5d 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -34,7 +34,7 @@ testCompareXMLToXMLFiles(const char *xml)
         goto fail;
 
     if (STRNEQ(xmlData, actual)) {
-        virtTestDifference(stderr, xmlData, actual);
+        virtTestDifferenceFull(stderr, xmlData, xml, actual, NULL);
         goto fail;
     }
 
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 7759a09..fc18b55 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -90,12 +90,13 @@ static int testCompareXMLToArgvFiles(const char *xml,
     if (!(actualxml = virDomainDefFormat(vmdef, 0)))
         goto fail;
 
-    if (blankProblemElements(expectxml) < 0 ||
-        blankProblemElements(actualxml) < 0)
+    if (!virTestGetRegenerate() &&
+        (blankProblemElements(expectxml) < 0 ||
+         blankProblemElements(actualxml) < 0))
         goto fail;
 
     if (STRNEQ(expectxml, actualxml)) {
-        virtTestDifference(stderr, expectxml, actualxml);
+        virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL);
         goto fail;
     }
 
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 102e052..61ade25 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -175,6 +175,7 @@ testQemuHotplugUpdate(virDomainObjPtr vm,
 static int
 testQemuHotplugCheckResult(virDomainObjPtr vm,
                            const char *expected,
+                           const char *expectedFile,
                            bool fail)
 {
     char *actual;
@@ -192,7 +193,9 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
         ret = 0;
     } else {
         if (!fail)
-            virtTestDifference(stderr, expected, actual);
+            virtTestDifferenceFull(stderr,
+                                   expected, expectedFile,
+                                   actual, NULL);
         ret = -1;
     }
 
@@ -294,13 +297,15 @@ testQemuHotplug(const void *data)
             VIR_FREE(dev);
         }
         if (ret == 0 || fail)
-            ret = testQemuHotplugCheckResult(vm, result_xml, fail);
+            ret = testQemuHotplugCheckResult(vm, result_xml,
+                                             result_filename, fail);
         break;
 
     case DETACH:
         ret = testQemuHotplugDetach(vm, dev);
         if (ret == 0 || fail)
-            ret = testQemuHotplugCheckResult(vm, domain_xml, fail);
+            ret = testQemuHotplugCheckResult(vm, domain_xml,
+                                             domain_filename, fail);
         break;
 
     case UPDATE:
diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c
index 4ee7537..87b8571 100644
--- a/tests/vboxsnapshotxmltest.c
+++ b/tests/vboxsnapshotxmltest.c
@@ -85,7 +85,7 @@ testCompareXMLtoXMLFiles(const char *xml)
         goto cleanup;
 
     if (STRNEQ(actual, xmlData)) {
-        virtTestDifference(stderr, xmlData, actual);
+        virtTestDifferenceFull(stderr, xmlData, xml, actual, NULL);
         goto cleanup;
     }
 
-- 
2.7.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]