static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
virDomainDefPtr def = NULL;
int ret = -1;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
-
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
- if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE)))
+ if (!(def = virDomainDefParseFile(inxml, driver.caps, driver.xmlopt,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail;
if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE)))
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virDomainDefFree(def);
static int testGetFilesystem(const void *opaque)
{
int ret = -1;
- char *xmlData = NULL;
virDomainDefPtr def = NULL;
char *filename = NULL;
const struct testGetFilesystemData *data = opaque;
abs_srcdir, data->filename) < 0)
goto cleanup;
- if (virtTestLoadFile(filename, &xmlData) < 0)
- goto cleanup;
-
- if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 0)))
+ if (!(def = virDomainDefParseFile(filename, caps, xmlopt, 0)))
goto cleanup;
fsdef = virDomainGetFilesystemForTarget(def,
cleanup:
virDomainDefFree(def);
- VIR_FREE(xmlData);
VIR_FREE(filename);
return ret;
}
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
{
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virDomainDefPtr def = NULL;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
- if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt,
- live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE)))
+ if (!(def = virDomainDefParseFile(inxml, caps, xmlopt,
+ live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virDomainDefFree(def);
static int
testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr caps)
{
- char *inXmlData = NULL;
char *outConfData = NULL;
char *actual = NULL;
int ret = -1;
char *pidfile = NULL;
dnsmasqContext *dctx = NULL;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
-
if (virtTestLoadFile(outconf, &outConfData) < 0)
goto fail;
- if (!(dev = virNetworkDefParseString(inXmlData)))
+ if (!(dev = virNetworkDefParseFile(inxml)))
goto fail;
if (!(obj = virNetworkObjNew()))
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outConfData);
VIR_FREE(actual);
VIR_FREE(pidfile);
testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
unsigned int flags)
{
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virNetworkDefPtr dev = NULL;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
- if (!(dev = virNetworkDefParseString(inXmlData)))
+ if (!(dev = virNetworkDefParseFile(inxml)))
goto fail;
if (!(actual = virNetworkDefFormat(dev, flags)))
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virNetworkDefFree(dev);
unsigned int command, unsigned int section,
int parentIndex, bool expectFailure)
{
- char *netXmlData = NULL;
char *updateXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virNetworkDefPtr def = NULL;
- if (virtTestLoadFile(netxml, &netXmlData) < 0)
- goto error;
if (virtTestLoadFile(updatexml, &updateXmlData) < 0)
goto error;
- if (!(def = virNetworkDefParseString(netXmlData)))
+ if (!(def = virNetworkDefParseFile(netxml)))
goto fail;
if (virNetworkDefUpdateSection(def, command, section, parentIndex,
}
}
error:
- VIR_FREE(netXmlData);
VIR_FREE(updateXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
bool expect_error)
{
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virNWFilterDefPtr dev = NULL;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
virResetLastError();
- if (!(dev = virNWFilterDefParseString(inXmlData))) {
+ if (!(dev = virNWFilterDefParseFile(inxml))) {
if (expect_error) {
virResetLastError();
goto done;
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virNWFilterDefFree(dev);
virCapsPtr caps = testQemuCapsInit();
qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
char *domain_filename = NULL;
- char *domain_xml = NULL;
virDomainDefPtr def = NULL;
virDomainFSInfoPtr *info = NULL;
int ret = -1, ninfo = 0, i;
abs_srcdir) < 0)
goto cleanup;
- if (virtTestLoadFile(domain_filename, &domain_xml) < 0)
- goto cleanup;
-
- if (!(def = virDomainDefParseString(domain_xml, caps, xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE)))
+ if (!(def = virDomainDefParseFile(domain_filename, caps, xmlopt,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto cleanup;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
virDomainFSInfoFree(info[i]);
VIR_FREE(info);
VIR_FREE(domain_filename);
- VIR_FREE(domain_xml);
virObjectUnref(caps);
virDomainDefFree(def);
qemuMonitorTestFree(test);
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virSecretDefPtr secret = NULL;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
- if (!(secret = virSecretDefParseString(inXmlData)))
+ if (!(secret = virSecretDefParseFile(inxml)))
goto fail;
if (!(actual = virSecretDefFormat(secret)))
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virSecretDefFree(secret);
testSELinuxLoadDef(const char *testname)
{
char *xmlfile = NULL;
- char *xmlstr = NULL;
virDomainDefPtr def = NULL;
size_t i;
abs_srcdir, testname) < 0)
goto cleanup;
- if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0)
- goto cleanup;
-
- if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, 0)))
+ if (!(def = virDomainDefParseFile(xmlfile, caps, xmlopt, 0)))
goto cleanup;
for (i = 0; i < def->ndisks; i++) {
cleanup:
VIR_FREE(xmlfile);
- VIR_FREE(xmlstr);
return def;
}
{
int ret = -1;
char *output = NULL;
- char *poolXmlData = NULL;
virStoragePoolDefPtr pool = NULL;
- if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
- goto cleanup;
-
- if (!(pool = virStoragePoolDefParseString(poolXmlData)))
+ if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
if (VIR_STRDUP(output, test.output) < 0)
cleanup:
VIR_FREE(output);
- VIR_FREE(poolXmlData);
virStoragePoolDefFree(pool);
return ret;
}
test_vdi_list_parser(collie_test test, char *poolxml, char *volxml)
{
int ret = -1;
- char *poolXmlData = NULL;
- char *volXmlData = NULL;
char *output = NULL;
virStoragePoolDefPtr pool = NULL;
virStorageVolDefPtr vol = NULL;
- if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
- goto cleanup;
- if (virtTestLoadFile(volxml, &volXmlData) < 0)
- goto cleanup;
-
- if (!(pool = virStoragePoolDefParseString(poolXmlData)))
+ if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
- if (!(vol = virStorageVolDefParseString(pool, volXmlData, 0)))
+ if (!(vol = virStorageVolDefParseFile(pool, volxml, 0)))
goto cleanup;
if (VIR_STRDUP(output, test.output) < 0)
cleanup:
VIR_FREE(output);
- VIR_FREE(poolXmlData);
- VIR_FREE(volXmlData);
virStoragePoolDefFree(pool);
virStorageVolDefFree(vol);
return ret;
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virStoragePoolDefPtr dev = NULL;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
- if (!(dev = virStoragePoolDefParseString(inXmlData)))
+ if (!(dev = virStoragePoolDefParseFile(inxml)))
goto fail;
if (!(actual = virStoragePoolDefFormat(dev)))
ret = 0;
fail:
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virStoragePoolDefFree(dev);
int imgformat,
unsigned long parse_flags)
{
- char *volXmlData = NULL;
- char *poolXmlData = NULL;
- char *inputpoolXmlData = NULL;
- char *inputvolXmlData = NULL;
char *expectedCmdline = NULL;
char *actualCmdline = NULL;
int ret = -1;
if (!(conn = virGetConnect()))
goto cleanup;
- if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
- goto cleanup;
- if (virtTestLoadFile(volxml, &volXmlData) < 0)
- goto cleanup;
- if (inputvolxml &&
- virtTestLoadFile(inputvolxml, &inputvolXmlData) < 0)
- goto cleanup;
-
- if (!(pool = virStoragePoolDefParseString(poolXmlData)))
+ if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
poolobj.def = pool;
if (inputpoolxml) {
- if (virtTestLoadFile(inputpoolxml, &inputpoolXmlData) < 0)
- goto cleanup;
- if (!(inputpool = virStoragePoolDefParseString(inputpoolXmlData)))
+ if (!(inputpool = virStoragePoolDefParseFile(inputpoolxml)))
goto cleanup;
}
if (inputvolxml)
parse_flags |= VIR_VOL_XML_PARSE_NO_CAPACITY;
- if (!(vol = virStorageVolDefParseString(pool, volXmlData, parse_flags)))
+ if (!(vol = virStorageVolDefParseFile(pool, volxml, parse_flags)))
goto cleanup;
if (inputvolxml &&
- !(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData, 0)))
+ !(inputvol = virStorageVolDefParseFile(inputpool, inputvolxml, 0)))
goto cleanup;
testSetVolumeType(vol, pool);
virCommandFree(cmd);
VIR_FREE(actualCmdline);
VIR_FREE(expectedCmdline);
- VIR_FREE(inputpoolXmlData);
- VIR_FREE(poolXmlData);
- VIR_FREE(volXmlData);
- VIR_FREE(inputvolXmlData);
virObjectUnref(conn);
return ret;
}
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
const char *outxml, unsigned int flags)
{
- char *poolXmlData = NULL;
- char *inXmlData = NULL;
char *outXmlData = NULL;
char *actual = NULL;
int ret = -1;
virStoragePoolDefPtr pool = NULL;
virStorageVolDefPtr dev = NULL;
- if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
- goto fail;
- if (virtTestLoadFile(inxml, &inXmlData) < 0)
- goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail;
- if (!(pool = virStoragePoolDefParseString(poolXmlData)))
+ if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto fail;
- if (!(dev = virStorageVolDefParseString(pool, inXmlData, flags)))
+ if (!(dev = virStorageVolDefParseFile(pool, inxml, flags)))
goto fail;
if (!(actual = virStorageVolDefFormat(pool, dev)))
ret = 0;
fail:
- VIR_FREE(poolXmlData);
- VIR_FREE(inXmlData);
VIR_FREE(outXmlData);
VIR_FREE(actual);
virStoragePoolDefFree(pool);
static int
testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
{
- char *xmlData = NULL;
char *xmcfgData = NULL;
char *gotxmcfgData = NULL;
virConfPtr conf = NULL;
conn = virGetConnect();
if (!conn) goto fail;
- if (virtTestLoadFile(xml, &xmlData) < 0)
- goto fail;
-
if (virtTestLoadFile(xmcfg, &xmcfgData) < 0)
goto fail;
- if (!(def = virDomainDefParseString(xmlData, caps, xmlopt,
- VIR_DOMAIN_XML_INACTIVE)))
+ if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
+ VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
ret = 0;
fail:
- VIR_FREE(xmlData);
VIR_FREE(xmcfgData);
VIR_FREE(gotxmcfgData);
if (conf)
static int
testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
{
- char *xmlData = NULL;
char *xmcfgData = NULL;
char *gotxmcfgData = NULL;
virConfPtr conf = NULL;
conn = virGetConnect();
if (!conn) goto fail;
- if (virtTestLoadFile(xml, &xmlData) < 0)
- goto fail;
-
if (virtTestLoadFile(xmcfg, &xmcfgData) < 0)
goto fail;
priv.caps = caps;
conn->privateData = &priv;
- if (!(def = virDomainDefParseString(xmlData, caps, xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE)))
+ if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
ret = 0;
fail:
- VIR_FREE(xmlData);
VIR_FREE(xmcfgData);
VIR_FREE(gotxmcfgData);
if (conf)
static int
testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
{
- char *xmlData = NULL;
char *sexprData = NULL;
char *gotsexpr = NULL;
int ret = -1;
virDomainDefPtr def = NULL;
- if (virtTestLoadFile(xml, &xmlData) < 0)
- goto fail;
-
if (virtTestLoadFile(sexpr, &sexprData) < 0)
goto fail;
- if (!(def = virDomainDefParseString(xmlData, caps, xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE)))
+ if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail;
if (!virDomainDefCheckABIStability(def, def)) {
ret = 0;
fail:
- VIR_FREE(xmlData);
VIR_FREE(sexprData);
VIR_FREE(gotsexpr);
virDomainDefFree(def);
testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
{
int result = -1;
- char *xmlData = NULL;
char *vmxData = NULL;
char *formatted = NULL;
virDomainDefPtr def = NULL;
- if (virtTestLoadFile(xml, &xmlData) < 0)
- goto failure;
-
if (virtTestLoadFile(vmx, &vmxData) < 0)
goto failure;
- def = virDomainDefParseString(xmlData, caps, xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE);
+ def = virDomainDefParseFile(xml, caps, xmlopt,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE);
if (def == NULL)
goto failure;
result = 0;
failure:
- VIR_FREE(xmlData);
VIR_FREE(vmxData);
VIR_FREE(formatted);
virDomainDefFree(def);