From: Michal Privoznik Date: Wed, 17 Dec 2025 12:14:08 +0000 (+0100) Subject: networkxml2conftest: Allow regenerating hosts file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30baa494549124855e5e20bc8823f87e22ef1092;p=thirdparty%2Flibvirt.git networkxml2conftest: Allow regenerating hosts file 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 Reviewed-by: Ján Tomko --- 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;