static int testCompareXMLToConfigFiles(const char *xml, const char *configfile, bool expectError) { int ret = -1; char *config = NULL; char *expectxml = NULL; char *actualxml = NULL; virDomainDefPtr vmdef = NULL; if (virtTestLoadFile(configfile, &config) < 0) goto fail; vmdef = lxcParseConfigString(config, caps, xmlopt); if ((vmdef && expectError) || (!vmdef && !expectError)) goto fail; if (vmdef) { if (!(actualxml = virDomainDefFormat(vmdef, 0))) goto fail; if (virtTestLoadFile(xml, &expectxml) < 0) goto fail; if (blankProblemElements(expectxml) < 0 || blankProblemElements(actualxml) < 0) goto fail; if (STRNEQ(expectxml, actualxml)) { virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL); goto fail; } } ret = 0; fail: VIR_FREE(expectxml); VIR_FREE(actualxml); VIR_FREE(config); virDomainDefFree(vmdef); return ret; }
static int testCompareXMLToConfigFiles(const char *xmlfile, const char *configfile, bool expectError) { int ret = -1; char *config = NULL; char *actualxml = NULL; virDomainDefPtr vmdef = NULL; if (virTestLoadFile(configfile, &config) < 0) goto fail; vmdef = lxcParseConfigString(config, caps, xmlopt); if ((vmdef && expectError) || (!vmdef && !expectError)) goto fail; if (vmdef) { if (testSanitizeDef(vmdef) < 0) goto fail; if (!(actualxml = virDomainDefFormat(vmdef, caps, 0))) goto fail; if (virTestCompareToFile(actualxml, xmlfile) < 0) goto fail; } ret = 0; fail: VIR_FREE(actualxml); VIR_FREE(config); virDomainDefFree(vmdef); return ret; }