From patchwork Tue Feb 16 17:44:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 62072 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1807829lbl; Tue, 16 Feb 2016 09:48:03 -0800 (PST) X-Received: by 10.194.81.103 with SMTP id z7mr23351282wjx.25.1455644883016; Tue, 16 Feb 2016 09:48:03 -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 hg1si2122828wjb.19.2016.02.16.09.48.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Feb 2016 09:48:02 -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 u1GHjHl9061922; Tue, 16 Feb 2016 12:45: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 u1GHibtq015523 for ; Tue, 16 Feb 2016 12:44:37 -0500 Received: from colepc.redhat.com (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1GHiX46011999; Tue, 16 Feb 2016 12:44:37 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 16 Feb 2016 12:44:32 -0500 Message-Id: <2dc5c766c10be02d62aef58661f4215403391a16.1455644471.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 5/5] tests: lxcconf2xml: Drop XML blanking 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 Hardcode a UUID like we did for qemuargv2xml, so we can use standard comparison helpers, which gives us VIR_TEST_REGENERATE_OUTPUT support --- tests/lxcconf2xmltest.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index fc071f7..83895cd 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -13,22 +13,21 @@ static virCapsPtr caps; static virDomainXMLOptionPtr xmlopt; -static int -blankProblemElements(char *data) +static int testSanitizeDef(virDomainDefPtr vmdef) { - if (virtTestClearLineRegex("([[:alnum:]]|-)+", data) < 0) + /* Remove UUID randomness */ + if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", vmdef->uuid) < 0) return -1; return 0; } static int -testCompareXMLToConfigFiles(const char *xml, +testCompareXMLToConfigFiles(const char *xmlfile, const char *configfile, bool expectError) { int ret = -1; char *config = NULL; - char *expectxml = NULL; char *actualxml = NULL; virDomainDefPtr vmdef = NULL; @@ -40,26 +39,19 @@ testCompareXMLToConfigFiles(const char *xml, goto fail; if (vmdef) { - if (!(actualxml = virDomainDefFormat(vmdef, caps, 0))) + if (testSanitizeDef(vmdef) < 0) goto fail; - if (virtTestLoadFile(xml, &expectxml) < 0) - goto fail; - - if (blankProblemElements(expectxml) < 0 || - blankProblemElements(actualxml) < 0) + if (!(actualxml = virDomainDefFormat(vmdef, caps, 0))) goto fail; - if (STRNEQ(expectxml, actualxml)) { - virtTestDifferenceFull(stderr, expectxml, xml, actualxml, NULL); + if (virtTestCompareToFile(actualxml, xmlfile) < 0) goto fail; - } } ret = 0; fail: - VIR_FREE(expectxml); VIR_FREE(actualxml); VIR_FREE(config); virDomainDefFree(vmdef);