提交 bdbe26b5 编写于 作者: C Cole Robinson

tests: Use *DefParseFile more

上级 01f2f6c6
...@@ -14,20 +14,16 @@ static bhyveConn driver; ...@@ -14,20 +14,16 @@ static bhyveConn driver;
static int static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml) testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{ {
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt, if (!(def = virDomainDefParseFile(inxml, driver.caps, driver.xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE))) VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail; goto fail;
if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE))) if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE)))
...@@ -41,7 +37,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) ...@@ -41,7 +37,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virDomainDefFree(def); virDomainDefFree(def);
......
...@@ -43,7 +43,6 @@ struct testGetFilesystemData { ...@@ -43,7 +43,6 @@ struct testGetFilesystemData {
static int testGetFilesystem(const void *opaque) static int testGetFilesystem(const void *opaque)
{ {
int ret = -1; int ret = -1;
char *xmlData = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *filename = NULL; char *filename = NULL;
const struct testGetFilesystemData *data = opaque; const struct testGetFilesystemData *data = opaque;
...@@ -53,10 +52,7 @@ static int testGetFilesystem(const void *opaque) ...@@ -53,10 +52,7 @@ static int testGetFilesystem(const void *opaque)
abs_srcdir, data->filename) < 0) abs_srcdir, data->filename) < 0)
goto cleanup; goto cleanup;
if (virtTestLoadFile(filename, &xmlData) < 0) if (!(def = virDomainDefParseFile(filename, caps, xmlopt, 0)))
goto cleanup;
if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 0)))
goto cleanup; goto cleanup;
fsdef = virDomainGetFilesystemForTarget(def, fsdef = virDomainGetFilesystemForTarget(def,
...@@ -79,7 +75,6 @@ static int testGetFilesystem(const void *opaque) ...@@ -79,7 +75,6 @@ static int testGetFilesystem(const void *opaque)
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
VIR_FREE(xmlData);
VIR_FREE(filename); VIR_FREE(filename);
return ret; return ret;
} }
......
...@@ -25,19 +25,16 @@ static virDomainXMLOptionPtr xmlopt; ...@@ -25,19 +25,16 @@ static virDomainXMLOptionPtr xmlopt;
static int static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
{ {
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt, if (!(def = virDomainDefParseFile(inxml, caps, xmlopt,
live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE))) live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) { if (!virDomainDefCheckABIStability(def, def)) {
...@@ -55,7 +52,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) ...@@ -55,7 +52,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virDomainDefFree(def); virDomainDefFree(def);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
static int static int
testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr caps) testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr caps)
{ {
char *inXmlData = NULL;
char *outConfData = NULL; char *outConfData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
...@@ -31,13 +30,10 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr ...@@ -31,13 +30,10 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
char *pidfile = NULL; char *pidfile = NULL;
dnsmasqContext *dctx = NULL; dnsmasqContext *dctx = NULL;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outconf, &outConfData) < 0) if (virtTestLoadFile(outconf, &outConfData) < 0)
goto fail; goto fail;
if (!(dev = virNetworkDefParseString(inXmlData))) if (!(dev = virNetworkDefParseFile(inxml)))
goto fail; goto fail;
if (!(obj = virNetworkObjNew())) if (!(obj = virNetworkObjNew()))
...@@ -61,7 +57,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr ...@@ -61,7 +57,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outConfData); VIR_FREE(outConfData);
VIR_FREE(actual); VIR_FREE(actual);
VIR_FREE(pidfile); VIR_FREE(pidfile);
......
...@@ -20,18 +20,15 @@ static int ...@@ -20,18 +20,15 @@ static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml, testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
unsigned int flags) unsigned int flags)
{ {
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virNetworkDefPtr dev = NULL; virNetworkDefPtr dev = NULL;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
if (!(dev = virNetworkDefParseString(inXmlData))) if (!(dev = virNetworkDefParseFile(inxml)))
goto fail; goto fail;
if (!(actual = virNetworkDefFormat(dev, flags))) if (!(actual = virNetworkDefFormat(dev, flags)))
...@@ -45,7 +42,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, ...@@ -45,7 +42,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virNetworkDefFree(dev); virNetworkDefFree(dev);
......
...@@ -22,19 +22,16 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml, ...@@ -22,19 +22,16 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
unsigned int command, unsigned int section, unsigned int command, unsigned int section,
int parentIndex, bool expectFailure) int parentIndex, bool expectFailure)
{ {
char *netXmlData = NULL;
char *updateXmlData = NULL; char *updateXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virNetworkDefPtr def = NULL; virNetworkDefPtr def = NULL;
if (virtTestLoadFile(netxml, &netXmlData) < 0)
goto error;
if (virtTestLoadFile(updatexml, &updateXmlData) < 0) if (virtTestLoadFile(updatexml, &updateXmlData) < 0)
goto error; goto error;
if (!(def = virNetworkDefParseString(netXmlData))) if (!(def = virNetworkDefParseFile(netxml)))
goto fail; goto fail;
if (virNetworkDefUpdateSection(def, command, section, parentIndex, if (virNetworkDefUpdateSection(def, command, section, parentIndex,
...@@ -67,7 +64,6 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml, ...@@ -67,7 +64,6 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
} }
} }
error: error:
VIR_FREE(netXmlData);
VIR_FREE(updateXmlData); VIR_FREE(updateXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
......
...@@ -23,20 +23,17 @@ static int ...@@ -23,20 +23,17 @@ static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml, testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
bool expect_error) bool expect_error)
{ {
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virNWFilterDefPtr dev = NULL; virNWFilterDefPtr dev = NULL;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
virResetLastError(); virResetLastError();
if (!(dev = virNWFilterDefParseString(inXmlData))) { if (!(dev = virNWFilterDefParseFile(inxml))) {
if (expect_error) { if (expect_error) {
virResetLastError(); virResetLastError();
goto done; goto done;
...@@ -56,7 +53,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, ...@@ -56,7 +53,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virNWFilterDefFree(dev); virNWFilterDefFree(dev);
......
...@@ -170,7 +170,6 @@ testQemuAgentGetFSInfo(const void *data) ...@@ -170,7 +170,6 @@ testQemuAgentGetFSInfo(const void *data)
virCapsPtr caps = testQemuCapsInit(); virCapsPtr caps = testQemuCapsInit();
qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
char *domain_filename = NULL; char *domain_filename = NULL;
char *domain_xml = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
virDomainFSInfoPtr *info = NULL; virDomainFSInfoPtr *info = NULL;
int ret = -1, ninfo = 0, i; int ret = -1, ninfo = 0, i;
...@@ -182,11 +181,8 @@ testQemuAgentGetFSInfo(const void *data) ...@@ -182,11 +181,8 @@ testQemuAgentGetFSInfo(const void *data)
abs_srcdir) < 0) abs_srcdir) < 0)
goto cleanup; goto cleanup;
if (virtTestLoadFile(domain_filename, &domain_xml) < 0) if (!(def = virDomainDefParseFile(domain_filename, caps, xmlopt,
goto cleanup; VIR_DOMAIN_DEF_PARSE_INACTIVE)))
if (!(def = virDomainDefParseString(domain_xml, caps, xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto cleanup; goto cleanup;
if (qemuMonitorTestAddAgentSyncResponse(test) < 0) if (qemuMonitorTestAddAgentSyncResponse(test) < 0)
...@@ -297,7 +293,6 @@ testQemuAgentGetFSInfo(const void *data) ...@@ -297,7 +293,6 @@ testQemuAgentGetFSInfo(const void *data)
virDomainFSInfoFree(info[i]); virDomainFSInfoFree(info[i]);
VIR_FREE(info); VIR_FREE(info);
VIR_FREE(domain_filename); VIR_FREE(domain_filename);
VIR_FREE(domain_xml);
virObjectUnref(caps); virObjectUnref(caps);
virDomainDefFree(def); virDomainDefFree(def);
qemuMonitorTestFree(test); qemuMonitorTestFree(test);
......
...@@ -11,18 +11,15 @@ ...@@ -11,18 +11,15 @@
static int static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml) testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{ {
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virSecretDefPtr secret = NULL; virSecretDefPtr secret = NULL;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
if (!(secret = virSecretDefParseString(inXmlData))) if (!(secret = virSecretDefParseFile(inxml)))
goto fail; goto fail;
if (!(actual = virSecretDefFormat(secret))) if (!(actual = virSecretDefFormat(secret)))
...@@ -36,7 +33,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) ...@@ -36,7 +33,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virSecretDefFree(secret); virSecretDefFree(secret);
......
...@@ -182,7 +182,6 @@ static virDomainDefPtr ...@@ -182,7 +182,6 @@ static virDomainDefPtr
testSELinuxLoadDef(const char *testname) testSELinuxLoadDef(const char *testname)
{ {
char *xmlfile = NULL; char *xmlfile = NULL;
char *xmlstr = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
size_t i; size_t i;
...@@ -190,10 +189,7 @@ testSELinuxLoadDef(const char *testname) ...@@ -190,10 +189,7 @@ testSELinuxLoadDef(const char *testname)
abs_srcdir, testname) < 0) abs_srcdir, testname) < 0)
goto cleanup; goto cleanup;
if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0) if (!(def = virDomainDefParseFile(xmlfile, caps, xmlopt, 0)))
goto cleanup;
if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, 0)))
goto cleanup; goto cleanup;
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
...@@ -230,7 +226,6 @@ testSELinuxLoadDef(const char *testname) ...@@ -230,7 +226,6 @@ testSELinuxLoadDef(const char *testname)
cleanup: cleanup:
VIR_FREE(xmlfile); VIR_FREE(xmlfile);
VIR_FREE(xmlstr);
return def; return def;
} }
......
...@@ -50,13 +50,9 @@ test_node_info_parser(collie_test test, char *poolxml) ...@@ -50,13 +50,9 @@ test_node_info_parser(collie_test test, char *poolxml)
{ {
int ret = -1; int ret = -1;
char *output = NULL; char *output = NULL;
char *poolXmlData = NULL;
virStoragePoolDefPtr pool = NULL; virStoragePoolDefPtr pool = NULL;
if (virtTestLoadFile(poolxml, &poolXmlData) < 0) if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
goto cleanup; goto cleanup;
if (VIR_STRDUP(output, test.output) < 0) if (VIR_STRDUP(output, test.output) < 0)
...@@ -77,7 +73,6 @@ test_node_info_parser(collie_test test, char *poolxml) ...@@ -77,7 +73,6 @@ test_node_info_parser(collie_test test, char *poolxml)
cleanup: cleanup:
VIR_FREE(output); VIR_FREE(output);
VIR_FREE(poolXmlData);
virStoragePoolDefFree(pool); virStoragePoolDefFree(pool);
return ret; return ret;
} }
...@@ -86,21 +81,14 @@ static int ...@@ -86,21 +81,14 @@ static int
test_vdi_list_parser(collie_test test, char *poolxml, char *volxml) test_vdi_list_parser(collie_test test, char *poolxml, char *volxml)
{ {
int ret = -1; int ret = -1;
char *poolXmlData = NULL;
char *volXmlData = NULL;
char *output = NULL; char *output = NULL;
virStoragePoolDefPtr pool = NULL; virStoragePoolDefPtr pool = NULL;
virStorageVolDefPtr vol = NULL; virStorageVolDefPtr vol = NULL;
if (virtTestLoadFile(poolxml, &poolXmlData) < 0) if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
if (virtTestLoadFile(volxml, &volXmlData) < 0)
goto cleanup;
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
goto cleanup; goto cleanup;
if (!(vol = virStorageVolDefParseString(pool, volXmlData, 0))) if (!(vol = virStorageVolDefParseFile(pool, volxml, 0)))
goto cleanup; goto cleanup;
if (VIR_STRDUP(output, test.output) < 0) if (VIR_STRDUP(output, test.output) < 0)
...@@ -121,8 +109,6 @@ test_vdi_list_parser(collie_test test, char *poolxml, char *volxml) ...@@ -121,8 +109,6 @@ test_vdi_list_parser(collie_test test, char *poolxml, char *volxml)
cleanup: cleanup:
VIR_FREE(output); VIR_FREE(output);
VIR_FREE(poolXmlData);
VIR_FREE(volXmlData);
virStoragePoolDefFree(pool); virStoragePoolDefFree(pool);
virStorageVolDefFree(vol); virStorageVolDefFree(vol);
return ret; return ret;
......
...@@ -19,18 +19,15 @@ ...@@ -19,18 +19,15 @@
static int static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml) testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{ {
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virStoragePoolDefPtr dev = NULL; virStoragePoolDefPtr dev = NULL;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
if (!(dev = virStoragePoolDefParseString(inXmlData))) if (!(dev = virStoragePoolDefParseFile(inxml)))
goto fail; goto fail;
if (!(actual = virStoragePoolDefFormat(dev))) if (!(actual = virStoragePoolDefFormat(dev)))
...@@ -44,7 +41,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) ...@@ -44,7 +41,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virStoragePoolDefFree(dev); virStoragePoolDefFree(dev);
......
...@@ -43,10 +43,6 @@ testCompareXMLToArgvFiles(bool shouldFail, ...@@ -43,10 +43,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
int imgformat, int imgformat,
unsigned long parse_flags) unsigned long parse_flags)
{ {
char *volXmlData = NULL;
char *poolXmlData = NULL;
char *inputpoolXmlData = NULL;
char *inputvolXmlData = NULL;
char *expectedCmdline = NULL; char *expectedCmdline = NULL;
char *actualCmdline = NULL; char *actualCmdline = NULL;
int ret = -1; int ret = -1;
...@@ -65,34 +61,24 @@ testCompareXMLToArgvFiles(bool shouldFail, ...@@ -65,34 +61,24 @@ testCompareXMLToArgvFiles(bool shouldFail,
if (!(conn = virGetConnect())) if (!(conn = virGetConnect()))
goto cleanup; goto cleanup;
if (virtTestLoadFile(poolxml, &poolXmlData) < 0) if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
if (virtTestLoadFile(volxml, &volXmlData) < 0)
goto cleanup;
if (inputvolxml &&
virtTestLoadFile(inputvolxml, &inputvolXmlData) < 0)
goto cleanup;
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
goto cleanup; goto cleanup;
poolobj.def = pool; poolobj.def = pool;
if (inputpoolxml) { if (inputpoolxml) {
if (virtTestLoadFile(inputpoolxml, &inputpoolXmlData) < 0) if (!(inputpool = virStoragePoolDefParseFile(inputpoolxml)))
goto cleanup;
if (!(inputpool = virStoragePoolDefParseString(inputpoolXmlData)))
goto cleanup; goto cleanup;
} }
if (inputvolxml) if (inputvolxml)
parse_flags |= VIR_VOL_XML_PARSE_NO_CAPACITY; parse_flags |= VIR_VOL_XML_PARSE_NO_CAPACITY;
if (!(vol = virStorageVolDefParseString(pool, volXmlData, parse_flags))) if (!(vol = virStorageVolDefParseFile(pool, volxml, parse_flags)))
goto cleanup; goto cleanup;
if (inputvolxml && if (inputvolxml &&
!(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData, 0))) !(inputvol = virStorageVolDefParseFile(inputpool, inputvolxml, 0)))
goto cleanup; goto cleanup;
testSetVolumeType(vol, pool); testSetVolumeType(vol, pool);
...@@ -133,10 +119,6 @@ testCompareXMLToArgvFiles(bool shouldFail, ...@@ -133,10 +119,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
virCommandFree(cmd); virCommandFree(cmd);
VIR_FREE(actualCmdline); VIR_FREE(actualCmdline);
VIR_FREE(expectedCmdline); VIR_FREE(expectedCmdline);
VIR_FREE(inputpoolXmlData);
VIR_FREE(poolXmlData);
VIR_FREE(volXmlData);
VIR_FREE(inputvolXmlData);
virObjectUnref(conn); virObjectUnref(conn);
return ret; return ret;
} }
......
...@@ -20,25 +20,19 @@ static int ...@@ -20,25 +20,19 @@ static int
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml, testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
const char *outxml, unsigned int flags) const char *outxml, unsigned int flags)
{ {
char *poolXmlData = NULL;
char *inXmlData = NULL;
char *outXmlData = NULL; char *outXmlData = NULL;
char *actual = NULL; char *actual = NULL;
int ret = -1; int ret = -1;
virStoragePoolDefPtr pool = NULL; virStoragePoolDefPtr pool = NULL;
virStorageVolDefPtr dev = NULL; virStorageVolDefPtr dev = NULL;
if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
goto fail;
if (virtTestLoadFile(inxml, &inXmlData) < 0)
goto fail;
if (virtTestLoadFile(outxml, &outXmlData) < 0) if (virtTestLoadFile(outxml, &outXmlData) < 0)
goto fail; goto fail;
if (!(pool = virStoragePoolDefParseString(poolXmlData))) if (!(pool = virStoragePoolDefParseFile(poolxml)))
goto fail; goto fail;
if (!(dev = virStorageVolDefParseString(pool, inXmlData, flags))) if (!(dev = virStorageVolDefParseFile(pool, inxml, flags)))
goto fail; goto fail;
if (!(actual = virStorageVolDefFormat(pool, dev))) if (!(actual = virStorageVolDefFormat(pool, dev)))
...@@ -52,8 +46,6 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml, ...@@ -52,8 +46,6 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
ret = 0; ret = 0;
fail: fail:
VIR_FREE(poolXmlData);
VIR_FREE(inXmlData);
VIR_FREE(outXmlData); VIR_FREE(outXmlData);
VIR_FREE(actual); VIR_FREE(actual);
virStoragePoolDefFree(pool); virStoragePoolDefFree(pool);
......
...@@ -48,7 +48,6 @@ static virDomainXMLOptionPtr xmlopt; ...@@ -48,7 +48,6 @@ static virDomainXMLOptionPtr xmlopt;
static int static int
testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
{ {
char *xmlData = NULL;
char *xmcfgData = NULL; char *xmcfgData = NULL;
char *gotxmcfgData = NULL; char *gotxmcfgData = NULL;
virConfPtr conf = NULL; virConfPtr conf = NULL;
...@@ -63,14 +62,11 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) ...@@ -63,14 +62,11 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
conn = virGetConnect(); conn = virGetConnect();
if (!conn) goto fail; if (!conn) goto fail;
if (virtTestLoadFile(xml, &xmlData) < 0)
goto fail;
if (virtTestLoadFile(xmcfg, &xmcfgData) < 0) if (virtTestLoadFile(xmcfg, &xmcfgData) < 0)
goto fail; goto fail;
if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
VIR_DOMAIN_XML_INACTIVE))) VIR_DOMAIN_XML_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) { if (!virDomainDefCheckABIStability(def, def)) {
...@@ -93,7 +89,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) ...@@ -93,7 +89,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(xmlData);
VIR_FREE(xmcfgData); VIR_FREE(xmcfgData);
VIR_FREE(gotxmcfgData); VIR_FREE(gotxmcfgData);
if (conf) if (conf)
......
...@@ -45,7 +45,6 @@ static virDomainXMLOptionPtr xmlopt; ...@@ -45,7 +45,6 @@ static virDomainXMLOptionPtr xmlopt;
static int static int
testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
{ {
char *xmlData = NULL;
char *xmcfgData = NULL; char *xmcfgData = NULL;
char *gotxmcfgData = NULL; char *gotxmcfgData = NULL;
virConfPtr conf = NULL; virConfPtr conf = NULL;
...@@ -61,9 +60,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) ...@@ -61,9 +60,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
conn = virGetConnect(); conn = virGetConnect();
if (!conn) goto fail; if (!conn) goto fail;
if (virtTestLoadFile(xml, &xmlData) < 0)
goto fail;
if (virtTestLoadFile(xmcfg, &xmcfgData) < 0) if (virtTestLoadFile(xmcfg, &xmcfgData) < 0)
goto fail; goto fail;
...@@ -72,8 +68,8 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) ...@@ -72,8 +68,8 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
priv.caps = caps; priv.caps = caps;
conn->privateData = &priv; conn->privateData = &priv;
if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE))) VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) { if (!virDomainDefCheckABIStability(def, def)) {
...@@ -96,7 +92,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) ...@@ -96,7 +92,6 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(xmlData);
VIR_FREE(xmcfgData); VIR_FREE(xmcfgData);
VIR_FREE(gotxmcfgData); VIR_FREE(gotxmcfgData);
if (conf) if (conf)
......
...@@ -23,20 +23,16 @@ static virDomainXMLOptionPtr xmlopt; ...@@ -23,20 +23,16 @@ static virDomainXMLOptionPtr xmlopt;
static int static int
testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
{ {
char *xmlData = NULL;
char *sexprData = NULL; char *sexprData = NULL;
char *gotsexpr = NULL; char *gotsexpr = NULL;
int ret = -1; int ret = -1;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
if (virtTestLoadFile(xml, &xmlData) < 0)
goto fail;
if (virtTestLoadFile(sexpr, &sexprData) < 0) if (virtTestLoadFile(sexpr, &sexprData) < 0)
goto fail; goto fail;
if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE))) VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail; goto fail;
if (!virDomainDefCheckABIStability(def, def)) { if (!virDomainDefCheckABIStability(def, def)) {
...@@ -55,7 +51,6 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) ...@@ -55,7 +51,6 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
ret = 0; ret = 0;
fail: fail:
VIR_FREE(xmlData);
VIR_FREE(sexprData); VIR_FREE(sexprData);
VIR_FREE(gotsexpr); VIR_FREE(gotsexpr);
virDomainDefFree(def); virDomainDefFree(def);
......
...@@ -73,19 +73,15 @@ static int ...@@ -73,19 +73,15 @@ static int
testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
{ {
int result = -1; int result = -1;
char *xmlData = NULL;
char *vmxData = NULL; char *vmxData = NULL;
char *formatted = NULL; char *formatted = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
if (virtTestLoadFile(xml, &xmlData) < 0)
goto failure;
if (virtTestLoadFile(vmx, &vmxData) < 0) if (virtTestLoadFile(vmx, &vmxData) < 0)
goto failure; goto failure;
def = virDomainDefParseString(xmlData, caps, xmlopt, def = virDomainDefParseFile(xml, caps, xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE); VIR_DOMAIN_DEF_PARSE_INACTIVE);
if (def == NULL) if (def == NULL)
goto failure; goto failure;
...@@ -108,7 +104,6 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) ...@@ -108,7 +104,6 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
result = 0; result = 0;
failure: failure:
VIR_FREE(xmlData);
VIR_FREE(vmxData); VIR_FREE(vmxData);
VIR_FREE(formatted); VIR_FREE(formatted);
virDomainDefFree(def); virDomainDefFree(def);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册