]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
networkxml2conftest: Allow regenerating hosts file
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 17 Dec 2025 12:14:08 +0000 (13:14 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 29 Jan 2026 12:38:55 +0000 (13:38 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/networkxml2conftest.c

index d089ff38b17909ddb88aa407caf27605fe51e2d0..cb2cafa918431fc8b65e8558b3b29f5caac1b3da 100644 (file)
@@ -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;