From patchwork Tue Feb 9 15:59:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 61564 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2127541lbl; Tue, 9 Feb 2016 08:02:03 -0800 (PST) X-Received: by 10.194.240.66 with SMTP id vy2mr34795885wjc.28.1455033713898; Tue, 09 Feb 2016 08:01:53 -0800 (PST) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id 140si11235199wmb.65.2016.02.09.08.01.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 08:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 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 mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u19FxHcj028632; Tue, 9 Feb 2016 10:59:17 -0500 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 u19FxAYn011113 for ; Tue, 9 Feb 2016 10:59:10 -0500 Received: from colepc.redhat.com (ovpn-113-172.phx2.redhat.com [10.3.113.172]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u19Fx6LP027336; Tue, 9 Feb 2016 10:59:09 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 9 Feb 2016 10:59:00 -0500 Message-Id: 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 Cc: mkletzan@redhat.com Subject: [libvirt] [PATCH v2 4/6] tests: utils: Add PreFormat callback for CompareXML2XML helper 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 This allows individual driver tests to hook in their own code before the def is formatted and compared. We will eventually use this in the qemuxml2xml --- tests/bhyvexml2xmltest.c | 3 ++- tests/genericxml2xmltest.c | 3 ++- tests/lxcxml2xmltest.c | 3 ++- tests/qemuxml2xmltest.c | 6 ++++-- tests/testutils.c | 7 ++++++- tests/testutils.h | 6 +++++- 6 files changed, 21 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 d860a41..2d34a00 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -32,7 +32,8 @@ testCompareXMLToXMLHelper(const void *data) ret = testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, xml_in, info->different ? xml_out : xml_in, - false); + false, + NULL, NULL); cleanup: VIR_FREE(xml_in); diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 7f79896..aa3a570 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -39,7 +39,8 @@ testCompareXMLToXMLHelper(const void *data) ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in, info->different ? xml_out : xml_in, - !info->inactive_only); + !info->inactive_only, + NULL, NULL); cleanup: VIR_FREE(xml_in); VIR_FREE(xml_out); diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index e460d0a..aafebb4 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -44,7 +44,8 @@ testCompareXMLToXMLHelper(const void *data) ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in, info->different ? xml_out : xml_in, - !info->inactive_only); + !info->inactive_only, + NULL, NULL); cleanup: VIR_FREE(xml_in); VIR_FREE(xml_out); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index d4e94f0..e3b61c0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -42,7 +42,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, + NULL, NULL); } @@ -52,7 +53,8 @@ testXML2XMLInactive(const void *opaque) const struct testInfo *info = opaque; return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, info->inName, - info->outInactiveName, false); + info->outInactiveName, false, + NULL, NULL); } diff --git a/tests/testutils.c b/tests/testutils.c index 506eee7..c4f1616 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1097,7 +1097,9 @@ 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, + testCompareDomXML2XMLPreFormatCallback cb, + const void *opaque) { char *actual = NULL; int ret = -1; @@ -1115,6 +1117,9 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, goto fail; } + if (cb && cb(def, opaque) < 0) + goto fail; + if (!(actual = virDomainDefFormat(def, caps, format_flags))) goto fail; diff --git a/tests/testutils.h b/tests/testutils.h index b1d7397..df2b2a6 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -137,10 +137,14 @@ int virtTestMain(int argc, virCapsPtr virTestGenericCapsInit(void); virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void); +typedef int (*testCompareDomXML2XMLPreFormatCallback)(virDomainDefPtr def, + const void *opaque); int testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, const char *inxml, const char *outfile, - bool live); + bool live, + testCompareDomXML2XMLPreFormatCallback cb, + const void *opaque); #endif /* __VIT_TEST_UTILS_H__ */