From: Michal Privoznik <[email protected]>

Inside of testCompareXMLToConfFiles() the
networkDnsmasqConfContents() is called. This may also produce
contents of corresponding hosts file. This is then compared to
expected contents stored on disk as ${testname}.hostsfile. But
due to additional checks virTestCompareToFile() might not even be
called. Problem with that is when there's actual content but the
file doesn't exist the compare helper is not called and thus
VIR_TEST_REGENERATE_OUTPUT trick doesn't work. Let's call the
helper more often as it is perfectly capable of handling this
edge case. What it is not capable of handling is when the file
shouldn't exist at all. So handling of that case is kept.

Signed-off-by: Michal Privoznik <[email protected]>
---
 tests/networkxml2conftest.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index d089ff38b1..cb2cafa918 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -75,18 +75,16 @@ testCompareXMLToConfFiles(const char *inxml, const char 
*outconf,
     if (virTestCompareToFile(confactual, outconf) < 0)
         goto fail;
 
-    if (virFileExists(outhostsfile)) {
-        if (!hostsfileactual) {
-            VIR_TEST_DEBUG("%s: hostsfile exists but the configuration did "
-                           "not specify any host", outhostsfile);
+    if (hostsfileactual) {
+        if (virTestCompareToFile(hostsfileactual, outhostsfile) < 0) {
             goto fail;
-        } else if (virTestCompareToFile(hostsfileactual, outhostsfile) < 0) {
+        }
+    } else {
+        if (virFileExists(outhostsfile)) {
+            VIR_TEST_DEBUG("%s: hostsfile exists but the configuration did not 
specify any host",
+                           outhostsfile);
             goto fail;
         }
-    } else if (hostsfileactual) {
-        VIR_TEST_DEBUG("%s: file does not exist but actual data was expected",
-                       outhostsfile);
-        goto fail;
     }
 
     ret = 0;
-- 
2.52.0

Reply via email to