[PATCH 11/20] networkxml2conftest: Allow regenerating more in one run

Michal Privoznik via Devel posted 20 patches 4 days, 15 hours ago
[PATCH 11/20] networkxml2conftest: Allow regenerating more in one run
Posted by Michal Privoznik via Devel 4 days, 15 hours ago
From: Michal Privoznik <mprivozn@redhat.com>

Currently, there are two calls to virTestCompareToFile() inside
of testCompareXMLToConfFiles(). If the first one fails the
control jumps directly onto the fail label and skips the second
one. This means that When regenerating test case output
(VIR_TEST_REGENERATE_OUTPUT) the test binary has to be called
twice to regenerate all the files. Suboptimal. Try harder to call
both compare helpers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/networkxml2conftest.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index cb2cafa918..c7534773a3 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -29,6 +29,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
     g_autofree char *pidfile = NULL;
     g_autoptr(dnsmasqContext) dctx = NULL;
     g_autoptr(virNetworkXMLOption) xmlopt = NULL;
+    bool compareFailed = false;
 
     if (!(xmlopt = networkDnsmasqCreateXMLConf()))
         goto fail;
@@ -73,20 +74,23 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
 #endif
 
     if (virTestCompareToFile(confactual, outconf) < 0)
-        goto fail;
+        compareFailed = true;
 
     if (hostsfileactual) {
         if (virTestCompareToFile(hostsfileactual, outhostsfile) < 0) {
-            goto fail;
+            compareFailed = true;
         }
     } else {
         if (virFileExists(outhostsfile)) {
             VIR_TEST_DEBUG("%s: hostsfile exists but the configuration did not specify any host",
                            outhostsfile);
-            goto fail;
+            compareFailed = true;
         }
     }
 
+    if (compareFailed)
+        goto fail;
+
     ret = 0;
 
  fail:
-- 
2.52.0