From nobody Wed May 14 16:51:18 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 1520009873101410.6408948503389; Fri, 2 Mar 2018 08:57:53 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BF425AFC4; Fri, 2 Mar 2018 16:57:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5ABB42AE62; Fri, 2 Mar 2018 16:57:51 +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 0AC6118033F9; Fri, 2 Mar 2018 16:57:48 +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 w22GvdF4008918 for ; Fri, 2 Mar 2018 11:57:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 44450946AB; Fri, 2 Mar 2018 16:57:39 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2DAFA9FB8; Fri, 2 Mar 2018 16:57:38 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 2 Mar 2018 17:56:48 +0100 Message-Id: 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 4/7] tests: qemuxml2xml: Remove fake 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 02 Mar 2018 16:57:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that the better approach is in place we can remove the old functions doing the fake formatting. Signed-off-by: Peter Krempa --- tests/qemuxml2xmltest.c | 218 +-------------------------------------------= ---- 1 file changed, 1 insertion(+), 217 deletions(-) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index cf9288db72..980d7fb0b3 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -39,29 +39,6 @@ struct testInfo { virQEMUCapsPtr qemuCaps; }; -static int -qemuXML2XMLActivePreFormatCallback(virDomainDefPtr def, - const void *opaque) -{ - struct testInfo *info =3D (struct testInfo *) opaque; - size_t i; - - /* store vCPU bitmap so that the status XML can be created faithfully = */ - if (!info->activeVcpus) - info->activeVcpus =3D virDomainDefGetOnlineVcpumap(def); - - info->blockjobs =3D false; - - /* remember whether we have mirror jobs */ - for (i =3D 0; i < def->ndisks; i++) { - if (def->disks[i]->mirror) { - info->blockjobs =3D true; - break; - } - } - - return 0; -} static int testXML2XMLActive(const void *opaque) @@ -70,7 +47,7 @@ testXML2XMLActive(const void *opaque) return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, info->inName, info->outActiveName, t= rue, - qemuXML2XMLActivePreFormatCallback, + NULL, opaque, 0, TEST_COMPARE_DOM_XML2XML_RESULT_SUCC= ESS); } @@ -88,195 +65,6 @@ testXML2XMLInactive(const void *opaque) } -static const char testStatusXMLPrefixHeader[] =3D -"\n" -" \n" -" \n"; - -static const char testStatusXMLPrefixBodyStatic[] =3D -"\n" -" \n" -" \n" -" \n" -" \n" -"\n" -"\n" -" \n" -" \n" -" \n" -" \n" -" \n" -"\n" -"\n" -"\n" -"\n" -"\n"; - -static const char testStatusXMLSuffix[] =3D -"\n"; - - -static void -testGetStatuXMLPrefixVcpus(virBufferPtr buf, - const struct testInfo *data) -{ - ssize_t vcpuid =3D -1; - - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - - /* Make sure we can format the fake vcpu list. The test will fail rega= rdles. */ - if (data->activeVcpus) { - while ((vcpuid =3D virBitmapNextSetBit(data->activeVcpus, vcpuid))= >=3D 0) - virBufferAsprintf(buf, "\n", - vcpuid, vcpuid + 3803519); - } - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); -} - - -static void -testGetStatusXMLAddBlockjobs(virBufferPtr buf, - const struct testInfo *data) -{ - virBufferAsprintf(buf, "\n", - virTristateBoolTypeToString(virTristateBoolFromBool(= data->blockjobs))); -} - - -static char * -testGetStatusXMLPrefix(const struct testInfo *data) -{ - virBuffer buf =3D VIR_BUFFER_INITIALIZER; - - virBufferAdd(&buf, testStatusXMLPrefixHeader, -1); - virBufferAdjustIndent(&buf, 2); - - testGetStatuXMLPrefixVcpus(&buf, data); - - virBufferAddStr(&buf, testStatusXMLPrefixBodyStatic); - - testGetStatusXMLAddBlockjobs(&buf, data); - - virBufferAdjustIndent(&buf, -2); - - return virBufferContentAndReset(&buf); -} - - -static int -testProcessStatusXML(virDomainObjPtr vm) -{ - size_t i; - - /* fix the private 'blockjob' flag for disks */ - for (i =3D 0; i < vm->def->ndisks; i++) { - virDomainDiskDefPtr disk =3D vm->def->disks[i]; - qemuDomainDiskPrivatePtr diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(dis= k); - - diskPriv->blockjob =3D !!disk->mirror; - } - - return 0; -} - - -static int -testCompareStatusXMLToXMLOldFiles(const void *opaque) -{ - const struct testInfo *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; - xmlDocPtr xml =3D NULL; - virDomainObjPtr obj =3D NULL; - char *expect =3D NULL; - char *actual =3D NULL; - char *source =3D NULL; - char *header =3D NULL; - char *inFile =3D NULL, *outActiveFile =3D NULL; - int ret =3D -1; - int keepBlanksDefault =3D xmlKeepBlanksDefault(0); - - if (virTestLoadFile(data->inName, &inFile) < 0) - goto cleanup; - if (virTestLoadFile(data->outActiveName, &outActiveFile) < 0) - goto cleanup; - - if (!(header =3D testGetStatusXMLPrefix(data))) - goto cleanup; - - /* construct faked source status XML */ - virBufferAdd(&buf, header, -1); - virBufferAdjustIndent(&buf, 2); - virBufferAddStr(&buf, inFile); - virBufferAdjustIndent(&buf, -2); - virBufferAdd(&buf, testStatusXMLSuffix, -1); - - if (!(source =3D virBufferContentAndReset(&buf))) { - VIR_TEST_DEBUG("Failed to create the source XML"); - goto cleanup; - } - - /* construct the expect string */ - virBufferAdd(&buf, header, -1); - virBufferAdjustIndent(&buf, 2); - virBufferAddStr(&buf, outActiveFile); - virBufferAdjustIndent(&buf, -2); - virBufferAdd(&buf, testStatusXMLSuffix, -1); - - if (!(expect =3D virBufferContentAndReset(&buf))) { - VIR_TEST_DEBUG("Failed to create the expect XML"); - goto cleanup; - } - - /* parse the fake source status XML */ - if (!(xml =3D virXMLParseString(source, "(domain_status_test_XML)")) || - !(obj =3D virDomainObjParseNode(xml, xmlDocGetRootElement(xml), - driver.caps, driver.xmlopt, - VIR_DOMAIN_DEF_PARSE_STATUS | - VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | - VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= ))) { - VIR_TEST_DEBUG("Failed to parse domain status XML:\n%s", source); - goto cleanup; - } - - /* process the definition if necessary */ - if (testProcessStatusXML(obj) < 0) - goto cleanup; - - /* format it back */ - if (!(actual =3D virDomainObjFormat(driver.xmlopt, obj, NULL, - VIR_DOMAIN_DEF_FORMAT_SECURE))) { - VIR_TEST_DEBUG("Failed to format domain status XML"); - goto cleanup; - } - - if (STRNEQ(actual, expect)) { - /* For status test we don't want to regenerate output to not - * add the status data.*/ - virTestDifferenceFullNoRegenerate(stderr, - expect, data->outActiveName, - actual, data->inName); - goto cleanup; - } - - ret =3D 0; - - cleanup: - xmlKeepBlanksDefault(keepBlanksDefault); - xmlFreeDoc(xml); - virObjectUnref(obj); - VIR_FREE(expect); - VIR_FREE(actual); - VIR_FREE(source); - VIR_FREE(inFile); - VIR_FREE(header); - VIR_FREE(outActiveFile); - return ret; -} - - static int testCompareStatusXMLToXMLFiles(const void *opaque) { @@ -472,10 +260,6 @@ mymain(void) if (virTestRun("QEMU XML-2-XML-active " name, \ testXML2XMLActive, &info) < 0) \ ret =3D -1; \ - \ - if (virTestRun("QEMU XML-2-XML-status (old)" name, \ - testCompareStatusXMLToXMLOldFiles, &info) < 0)= \ - ret =3D -1; \ } \ testInfoClear(&info); \ } while (0) --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list