diff mbox

[1/4] test: Introduce testOpenParse

Message ID 537eae2719711bc61cf3626dc05b9e21624c9205.1467373028.git.crobinso@redhat.com
State Accepted
Commit 4b8e07fc7d93af2c7f1840bb25619d0a739b04ad
Headers show

Commit Message

Cole Robinson July 1, 2016, 11:37 a.m. UTC
---
 src/test/test_driver.c | 51 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 19 deletions(-)

-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index baff085..53901d6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1296,6 +1296,37 @@  testParseAuthUsers(testDriverPtr privconn,
     return ret;
 }
 
+static int
+testOpenParse(testDriverPtr privconn,
+              const char *file,
+              xmlXPathContextPtr ctxt)
+{
+    if (!xmlStrEqual(ctxt->node->name, BAD_CAST "node")) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("Root element is not 'node'"));
+        goto error;
+    }
+
+    if (testParseNodeInfo(&privconn->nodeInfo, ctxt) < 0)
+        goto error;
+    if (testParseDomains(privconn, file, ctxt) < 0)
+        goto error;
+    if (testParseNetworks(privconn, file, ctxt) < 0)
+        goto error;
+    if (testParseInterfaces(privconn, file, ctxt) < 0)
+        goto error;
+    if (testParseStorage(privconn, file, ctxt) < 0)
+        goto error;
+    if (testParseNodedevs(privconn, file, ctxt) < 0)
+        goto error;
+    if (testParseAuthUsers(privconn, ctxt) < 0)
+        goto error;
+
+    return 0;
+ error:
+    return -1;
+}
+
 /* No shared state between simultaneous test connections initialized
  * from a file.  */
 static int
@@ -1317,28 +1348,10 @@  testOpenFromFile(virConnectPtr conn, const char *file)
     if (!(doc = virXMLParseFileCtxt(file, &ctxt)))
         goto error;
 
-    if (!xmlStrEqual(ctxt->node->name, BAD_CAST "node")) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("Root element is not 'node'"));
-        goto error;
-    }
-
     privconn->numCells = 0;
     memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo));
 
-    if (testParseNodeInfo(&privconn->nodeInfo, ctxt) < 0)
-        goto error;
-    if (testParseDomains(privconn, file, ctxt) < 0)
-        goto error;
-    if (testParseNetworks(privconn, file, ctxt) < 0)
-        goto error;
-    if (testParseInterfaces(privconn, file, ctxt) < 0)
-        goto error;
-    if (testParseStorage(privconn, file, ctxt) < 0)
-        goto error;
-    if (testParseNodedevs(privconn, file, ctxt) < 0)
-        goto error;
-    if (testParseAuthUsers(privconn, ctxt) < 0)
+    if (testOpenParse(privconn, file, ctxt) < 0)
         goto error;
 
     xmlXPathFreeContext(ctxt);