From patchwork Tue Mar 8 16:36:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 63690 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2130463lbc; Tue, 8 Mar 2016 08:39:45 -0800 (PST) X-Received: by 10.31.160.6 with SMTP id j6mr27374582vke.87.1457455185746; Tue, 08 Mar 2016 08:39:45 -0800 (PST) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id s74si2453329vks.1.2016.03.08.08.39.44 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Mar 2016 08:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 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 mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u28GbBAE017765; Tue, 8 Mar 2016 11:37:11 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u28GapXv012383 for ; Tue, 8 Mar 2016 11:36:51 -0500 Received: from colepc.redhat.com (ovpn-113-126.phx2.redhat.com [10.3.113.126]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u28GalpT004012; Tue, 8 Mar 2016 11:36:51 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 8 Mar 2016 11:36:36 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Andrea Bolognani Subject: [libvirt] [PATCH 5/8] tests: Add failure flags to CompareDomainXML2XML 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 Will be used in future patches --- tests/bhyvexml2xmltest.c | 2 +- tests/genericxml2xmltest.c | 2 +- tests/lxcxml2xmltest.c | 2 +- tests/qemuxml2xmltest.c | 5 +++-- tests/testutils.c | 10 ++++++++-- tests/testutils.h | 4 ++++ 6 files changed, 18 insertions(+), 7 deletions(-) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 8f556ee..87bc39c 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -32,7 +32,7 @@ testCompareXMLToXMLHelper(const void *data) ret = testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, xml_in, info->different ? xml_out : xml_in, - false, + false, 0, NULL, NULL, 0); cleanup: diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index bf9b11d..666fc86 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -39,7 +39,7 @@ testCompareXMLToXMLHelper(const void *data) ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in, info->different ? xml_out : xml_in, - !info->inactive_only, + !info->inactive_only, 0, NULL, NULL, 0); cleanup: VIR_FREE(xml_in); diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 0b51340..c2140bc 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -45,7 +45,7 @@ testCompareXMLToXMLHelper(const void *data) ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in, info->different ? xml_out : xml_in, - !info->inactive_only, + !info->inactive_only, 0, NULL, NULL, info->parse_flags); cleanup: VIR_FREE(xml_in); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 251effd..b3568df 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -52,7 +52,8 @@ testXML2XMLActive(const void *opaque) const struct testInfo *info = opaque; return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, - info->inName, info->outActiveName, true, + info->inName, info->outActiveName, + true, 0, qemuXML2XMLPreFormatCallback, opaque, 0); } @@ -63,7 +64,7 @@ testXML2XMLInactive(const void *opaque) const struct testInfo *info = opaque; return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, info->inName, - info->outInactiveName, false, + info->outInactiveName, false, 0, qemuXML2XMLPreFormatCallback, opaque, 0); } diff --git a/tests/testutils.c b/tests/testutils.c index b1bd4e8..ec1ee38 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1052,7 +1052,8 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void) int testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - const char *infile, const char *outfile, bool live, + const char *infile, const char *outfile, + bool live, testCompareDomXML2XMLFlags flags, testCompareDomXML2XMLPreFormatCallback cb, const void *opaque, unsigned int parseFlags) { @@ -1067,8 +1068,12 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, if (!live) format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE; - if (!(def = virDomainDefParseFile(infile, caps, xmlopt, parse_flags))) + if (!(def = virDomainDefParseFile(infile, caps, xmlopt, parse_flags))) { + if (!virtTestOOMActive() && + (flags & TEST_COMPARE_DOM_XML2XML_FLAG_EXPECT_PARSE_ERROR)) + goto ok; goto fail; + } if (!virDomainDefCheckABIStability(def, def)) { VIR_TEST_DEBUG("ABI stability check failed on %s", infile); @@ -1084,6 +1089,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, if (virtTestCompareToFile(actual, outfile) < 0) goto fail; + ok: ret = 0; fail: VIR_FREE(actual); diff --git a/tests/testutils.h b/tests/testutils.h index 752fa52..a09fd58 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -134,6 +134,9 @@ int virtTestMain(int argc, virCapsPtr virTestGenericCapsInit(void); virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void); +typedef enum { + TEST_COMPARE_DOM_XML2XML_FLAG_EXPECT_PARSE_ERROR = 1 << 0, +} testCompareDomXML2XMLFlags; typedef int (*testCompareDomXML2XMLPreFormatCallback)(virDomainDefPtr def, const void *opaque); int testCompareDomXML2XMLFiles(virCapsPtr caps, @@ -141,6 +144,7 @@ int testCompareDomXML2XMLFiles(virCapsPtr caps, const char *inxml, const char *outfile, bool live, + testCompareDomXML2XMLFlags flags, testCompareDomXML2XMLPreFormatCallback cb, const void *opaque, unsigned int parseFlags);