diff options
author | Eric Blake <eblake@redhat.com> | 2011-08-18 15:37:14 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2011-08-19 09:13:55 -0600 |
commit | d89dd42d51679cd73932f8dc9472549bb1265ac4 (patch) | |
tree | c99271bbb4d5caf92809167853863fa89ab51b86 /src/test | |
parent | xml: add another convenience function (diff) | |
download | libvirt-d89dd42d51679cd73932f8dc9472549bb1265ac4.tar.gz libvirt-d89dd42d51679cd73932f8dc9472549bb1265ac4.tar.bz2 libvirt-d89dd42d51679cd73932f8dc9472549bb1265ac4.zip |
maint: simplify lots of libxml2 clients
Repetitive patterns should be factored. The sign of a good
factorization is a change that kills 5x more lines than it adds :)
* src/conf/domain_conf.c (virDomainDeviceDefParse)
(virDomainSnapshotDefParseString): Use new convenience macros.
* src/conf/storage_conf.c (virStoragePoolDefParseSourceString):
Likewise.
* src/cpu/cpu.c (cpuCompareXML, cpuBaselineXML): Likewise.
* src/esx/esx_vi.c (esxVI_Context_Execute): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationCookieXMLParseStr):
Likewise.
* src/security/virt-aa-helper.c (caps_mockup): Likewise.
* src/test/test_driver.c (testOpenFromFile): Likewise.
* tests/cputest.c (cpuTestLoadXML, cpuTestLoadMultiXML):
Likewise.
* tools/virsh.c (cmdFreecell, makeCloneXML, cmdVNCDisplay)
(cmdTTYConsole, cmdDetachInterface, cmdDetachDisk)
(cmdSnapshotCreate, cmdSnapshotCreateAs, cmdSnapshotCurrent)
(cmdSnapshotList, cmdSnapshotParent): Likewise.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_driver.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ec2bd75f4..b3e24b451 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -742,7 +742,6 @@ static int testOpenFromFile(virConnectPtr conn, long l; char *str; xmlDocPtr xml = NULL; - xmlNodePtr root = NULL; xmlNodePtr *domains = NULL, *networks = NULL, *ifaces = NULL, *pools = NULL, *devs = NULL; xmlXPathContextPtr ctxt = NULL; @@ -771,24 +770,16 @@ static int testOpenFromFile(virConnectPtr conn, if (!(privconn->caps = testBuildCapabilities(conn))) goto error; - if (!(xml = virXMLParseFile(file))) { + if (!(xml = virXMLParseFileCtxt(file, &ctxt))) { goto error; } - root = xmlDocGetRootElement(xml); - if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) { + if (!xmlStrEqual(ctxt->node->name, BAD_CAST "node")) { testError(VIR_ERR_XML_ERROR, "%s", _("Root element is not 'node'")); goto error; } - ctxt = xmlXPathNewContext(xml); - if (ctxt == NULL) { - testError(VIR_ERR_INTERNAL_ERROR, "%s", - _("creating xpath context")); - goto error; - } - privconn->nextDomID = 1; privconn->numCells = 0; if ((privconn->path = strdup(file)) == NULL) { |