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; }
static int testCompareXMLToArgvFiles(const char *xmlfile, const char *cmdfile, virQemuXML2ArgvTestFlags flags) { char *actualxml = NULL; char *cmd = NULL; char *log = NULL; int ret = -1; virDomainDefPtr vmdef = NULL; if (virtTestLoadFile(cmdfile, &cmd) < 0) goto fail; if (!(vmdef = qemuParseCommandLineString(driver.caps, driver.xmlopt, cmd, NULL, NULL, NULL))) goto fail; if (!virtTestOOMActive()) { if ((log = virtTestLogContentAndReset()) == NULL) goto fail; if (flags & FLAG_EXPECT_WARNING) { if (*log) { VIR_TEST_DEBUG("Got expected warning from " "qemuParseCommandLineString:\n%s", log); } else { VIR_TEST_DEBUG("qemuParseCommandLineString " "should have logged a warning\n"); goto fail; } } else { /* didn't expect a warning */ if (*log) { VIR_TEST_DEBUG("Got unexpected warning from " "qemuParseCommandLineString:\n%s", log); goto fail; } } } if (testSanitizeDef(vmdef) < 0) goto fail; if (!virDomainDefCheckABIStability(vmdef, vmdef)) { VIR_TEST_DEBUG("ABI stability check failed on %s", xmlfile); goto fail; } if (!(actualxml = virDomainDefFormat(vmdef, driver.caps, 0))) goto fail; if (virtTestCompareToFile(actualxml, xmlfile) < 0) goto fail; ret = 0; fail: VIR_FREE(actualxml); VIR_FREE(cmd); VIR_FREE(log); virDomainDefFree(vmdef); return ret; }