From patchwork Fri Jul 1 11:37:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 71303 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp255654qgy; Fri, 1 Jul 2016 04:42:05 -0700 (PDT) X-Received: by 10.200.48.46 with SMTP id f43mr5423051qte.10.1467373325235; Fri, 01 Jul 2016 04:42:05 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id g67si2101242qkh.329.2016.07.01.04.42.04 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jul 2016 04:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u61BcnAC006316; Fri, 1 Jul 2016 07:38:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u61BcJPb032570 for ; Fri, 1 Jul 2016 07:38:19 -0400 Received: from colepc.redhat.com (ovpn-116-79.rdu2.redhat.com [10.10.116.79]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u61BcIbU004609; Fri, 1 Jul 2016 07:38:19 -0400 From: Cole Robinson To: libvir-list@redhat.com Date: Fri, 1 Jul 2016 07:37:59 -0400 Message-Id: <537eae2719711bc61cf3626dc05b9e21624c9205.1467373028.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] test: Introduce testOpenParse X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com --- 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 --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);