From: Jiri Denemark Date: Thu, 17 Apr 2014 13:23:21 +0000 (+0200) Subject: tests: More output options for xml2xml tests X-Git-Tag: v1.2.4-rc1~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=022ccd3d6226a3830b1f293f4271de2b01194f52;p=thirdparty%2Flibvirt.git 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 --- diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index bf9d736561..abad2f4934 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -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 (testCompareXMLToXMLFiles(xml_in, out, false) < 0) + goto cleanup; + } - if ((info->when & WHEN_ACTIVE) && - testCompareXMLToXMLFiles(xml_in, - info->different ? xml_out : xml_in, - true) < 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; }