From nobody Wed May 14 16:58:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520009884195416.6271713848631; Fri, 2 Mar 2018 08:58:04 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFBDC81E1A; Fri, 2 Mar 2018 16:58:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CD656178D; Fri, 2 Mar 2018 16:58:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1803F4A477; Fri, 2 Mar 2018 16:57:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w22Gvcs3008909 for ; Fri, 2 Mar 2018 11:57:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 89B61AB584; Fri, 2 Mar 2018 16:57:38 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB0EF946AB; Fri, 2 Mar 2018 16:57:37 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 2 Mar 2018 17:56:47 +0100 Message-Id: <41e697c1641415800794faf3f3b0b1c69003abbb.1520009664.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/7] tests: qemuxml2xml: Add proper domain status XML testing 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 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 02 Mar 2018 16:58:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add new approach to properly test status XML files by supplying a full XML file rather than generating synthetic test cases by prepending the status header. The two tests introduced here are copies of existing cases using the synthetic header so that current level of testing is kept. The files are chosen to excercise the vcpu and blockjob quirks present in the current testing. Signed-off-by: Peter Krempa --- tests/Makefile.am | 1 + tests/qemustatusxml2xmldata/blockjob-mirror-in.xml | 96 ++++++ .../qemustatusxml2xmldata/blockjob-mirror-out.xml | 96 ++++++ tests/qemustatusxml2xmldata/vcpus-multi-in.xml | 343 +++++++++++++++++= ++++ tests/qemustatusxml2xmldata/vcpus-multi-out.xml | 343 +++++++++++++++++= ++++ tests/qemuxml2xmltest.c | 109 ++++++- 6 files changed, 981 insertions(+), 7 deletions(-) create mode 100644 tests/qemustatusxml2xmldata/blockjob-mirror-in.xml create mode 100644 tests/qemustatusxml2xmldata/blockjob-mirror-out.xml create mode 100644 tests/qemustatusxml2xmldata/vcpus-multi-in.xml create mode 100644 tests/qemustatusxml2xmldata/vcpus-multi-out.xml diff --git a/tests/Makefile.am b/tests/Makefile.am index d794df3e5c..1f60ee0393 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -128,6 +128,7 @@ EXTRA_DIST =3D \ qemumonitorjsondata \ qemuxml2argvdata \ qemuxml2xmloutdata \ + qemustatusxml2xmloutdata \ qemumemlockdata \ secretxml2xmlin \ securityselinuxhelperdata \ diff --git a/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml b/tests/qem= ustatusxml2xmldata/blockjob-mirror-in.xml new file mode 100644 index 0000000000..a22d2173e7 --- /dev/null +++ b/tests/qemustatusxml2xmldata/blockjob-mirror-in.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ + +
+ + +
+ + + + + +
+ + + + diff --git a/tests/qemustatusxml2xmldata/blockjob-mirror-out.xml b/tests/qe= mustatusxml2xmldata/blockjob-mirror-out.xml new file mode 100644 index 0000000000..a22d2173e7 --- /dev/null +++ b/tests/qemustatusxml2xmldata/blockjob-mirror-out.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ + +
+ + +
+ + + + + +
+ + + + diff --git a/tests/qemustatusxml2xmldata/vcpus-multi-in.xml b/tests/qemusta= tusxml2xmldata/vcpus-multi-in.xml new file mode 100644 index 0000000000..c99046ce8d --- /dev/null +++ b/tests/qemustatusxml2xmldata/vcpus-multi-in.xml @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 288 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + +
+ + + + + + + + + + diff --git a/tests/qemustatusxml2xmldata/vcpus-multi-out.xml b/tests/qemust= atusxml2xmldata/vcpus-multi-out.xml new file mode 100644 index 0000000000..c99046ce8d --- /dev/null +++ b/tests/qemustatusxml2xmldata/vcpus-multi-out.xml @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 288 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4279a88c2e..cf9288db72 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -184,7 +184,7 @@ testProcessStatusXML(virDomainObjPtr vm) static int -testCompareStatusXMLToXMLFiles(const void *opaque) +testCompareStatusXMLToXMLOldFiles(const void *opaque) { const struct testInfo *data =3D opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; @@ -277,6 +277,44 @@ testCompareStatusXMLToXMLFiles(const void *opaque) } +static int +testCompareStatusXMLToXMLFiles(const void *opaque) +{ + const struct testInfo *data =3D opaque; + virDomainObjPtr obj =3D NULL; + char *actual =3D NULL; + int ret =3D -1; + + if (!(obj =3D virDomainObjParseFile(data->inName, driver.caps, driver.= xmlopt, + VIR_DOMAIN_DEF_PARSE_STATUS | + VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | + VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= | + VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHE= CKS | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) + goto cleanup; + + if (!(actual =3D virDomainObjFormat(driver.xmlopt, obj, NULL, + VIR_DOMAIN_DEF_FORMAT_SECURE | + VIR_DOMAIN_DEF_FORMAT_STATUS | + VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET | + VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATE= S | + VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST))) + + goto cleanup; + + if (virTestCompareToFile(actual, data->outActiveName) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virObjectUnref(obj); + VIR_FREE(actual); + return ret; +} + + static void testInfoClear(struct testInfo *info) { @@ -292,10 +330,8 @@ testInfoClear(struct testInfo *info) static int -testInfoSet(struct testInfo *info, - const char *name, - int when, - int gic) +testInfoSetCommon(struct testInfo *info, + int gic) { if (!(info->qemuCaps =3D virQEMUCapsNew())) goto error; @@ -306,6 +342,23 @@ testInfoSet(struct testInfo *info, if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0) goto error; + return 0; + + error: + testInfoClear(info); + return -1; +} + + +static int +testInfoSet(struct testInfo *info, + const char *name, + int when, + int gic) +{ + if (testInfoSetCommon(info, gic) < 0) + return -1; + if (virAsprintf(&info->inName, "%s/qemuxml2argvdata/%s.xml", abs_srcdir, name) < 0) goto error; @@ -349,6 +402,29 @@ testInfoSet(struct testInfo *info, return -1; } + +static const char *statusPath =3D abs_srcdir "/qemustatusxml2xmldata/"; + +static int +testInfoSetStatus(struct testInfo *info, + const char *name, + int gic) +{ + if (testInfoSetCommon(info, gic) < 0) + return -1; + + if (virAsprintf(&info->inName, "%s%s-in.xml", statusPath, name) < 0 || + virAsprintf(&info->outActiveName, "%s%s-out.xml", statusPath, name= ) < 0) + goto error; + + return 0; + + error: + testInfoClear(info); + return -1; +} + + # define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" static int @@ -397,8 +473,8 @@ mymain(void) testXML2XMLActive, &info) < 0) \ ret =3D -1; \ \ - if (virTestRun("QEMU XML-2-XML-status " name, \ - testCompareStatusXMLToXMLFiles, &info) < 0) \ + if (virTestRun("QEMU XML-2-XML-status (old)" name, \ + testCompareStatusXMLToXMLOldFiles, &info) < 0)= \ ret =3D -1; \ } \ testInfoClear(&info); \ @@ -1341,6 +1417,25 @@ mymain(void) DO_TEST("user-aliases", NONE); + +# define DO_TEST_STATUS(name) \ + do { \ + if (testInfoSetStatus(&info, name, GIC_NONE) < 0) { \ + VIR_TEST_DEBUG("Failed to generate status test data for '%s'",= name); \ + return -1; \ + } \ + \ + if (virTestRun("QEMU status XML-2-XML " name, \ + testCompareStatusXMLToXMLFiles, &info) < 0) \ + ret =3D -1; \ +\ + testInfoClear(&info); \ + } while (0) + + + DO_TEST_STATUS("blockjob-mirror"); + DO_TEST_STATUS("vcpus-multi"); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list