mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
tests: More output options for xml2xml tests
So far, qemuxml2xml test was only able to check if the result matches the original or the appropriate XML in qemuxml2xmloutdata regardless on flags used to format the XML. Since the result can be different depending on VIR_DOMAIN_XML_INACTIVE flag being used or not, this patch adds support for qemuxml2xmlout-%s-active.xml and qemuxml2xmlout-%s-inactive.xml output files. If the file specific to the flag used exists, it is used in preference to the generic qemuxml2xmlout-%s.xml file when reading the expected output. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
546154e3d4
commit
022ccd3d62
@ -81,31 +81,55 @@ testCompareXMLToXMLHelper(const void *data)
|
||||
const struct testInfo *info = data;
|
||||
char *xml_in = NULL;
|
||||
char *xml_out = NULL;
|
||||
char *xml_out_active = NULL;
|
||||
char *xml_out_inactive = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (virAsprintf(&xml_in, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
|
||||
abs_srcdir, info->name) < 0 ||
|
||||
virAsprintf(&xml_out, "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s.xml",
|
||||
abs_srcdir, info->name) < 0 ||
|
||||
virAsprintf(&xml_out_active,
|
||||
"%s/qemuxml2xmloutdata/qemuxml2xmlout-%s-active.xml",
|
||||
abs_srcdir, info->name) < 0 ||
|
||||
virAsprintf(&xml_out_inactive,
|
||||
"%s/qemuxml2xmloutdata/qemuxml2xmlout-%s-inactive.xml",
|
||||
abs_srcdir, info->name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((info->when & WHEN_INACTIVE) &&
|
||||
testCompareXMLToXMLFiles(xml_in,
|
||||
info->different ? xml_out : xml_in,
|
||||
false) < 0)
|
||||
goto cleanup;
|
||||
if ((info->when & WHEN_INACTIVE)) {
|
||||
char *out;
|
||||
if (!info->different)
|
||||
out = xml_in;
|
||||
else if (virFileExists(xml_out_inactive))
|
||||
out = xml_out_inactive;
|
||||
else
|
||||
out = xml_out;
|
||||
|
||||
if ((info->when & WHEN_ACTIVE) &&
|
||||
testCompareXMLToXMLFiles(xml_in,
|
||||
info->different ? xml_out : xml_in,
|
||||
true) < 0)
|
||||
goto cleanup;
|
||||
if (testCompareXMLToXMLFiles(xml_in, out, false) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((info->when & WHEN_ACTIVE)) {
|
||||
char *out;
|
||||
if (!info->different)
|
||||
out = xml_in;
|
||||
else if (virFileExists(xml_out_active))
|
||||
out = xml_out_active;
|
||||
else
|
||||
out = xml_out;
|
||||
|
||||
if (testCompareXMLToXMLFiles(xml_in, out, true) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(xml_in);
|
||||
VIR_FREE(xml_out);
|
||||
VIR_FREE(xml_out_active);
|
||||
VIR_FREE(xml_out_inactive);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user