From nobody Sun Feb 8 22:50:29 2026 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 1552924574829834.9880944185588; Mon, 18 Mar 2019 08:56:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 266C4308425B; Mon, 18 Mar 2019 15:56:13 +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 F0C7660C4C; Mon, 18 Mar 2019 15:56:12 +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 A9FAC181A278; Mon, 18 Mar 2019 15:56:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2IFtljG022795 for ; Mon, 18 Mar 2019 11:55:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id A66151001E6A; Mon, 18 Mar 2019 15:55:47 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D46B1001E61 for ; Mon, 18 Mar 2019 15:55:47 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 18 Mar 2019 16:55:12 +0100 Message-Id: <793dcd29907d231dde8477c4be26aa7e52db3c73.1552924270.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/34] tests: qemublock: Use new source formatter and parser in testBackingXMLjsonXML 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 18 Mar 2019 15:56:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is part of the effort to minimize use of virDomainDiskSourceParse. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 130 ++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 69 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 96c70e381a..48cec2869b 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -34,15 +34,10 @@ VIR_LOG_INIT("tests.storagetest"); -struct testBackingXMLjsonXMLdata { - int type; - const char *xml; -}; - static int testBackingXMLjsonXML(const void *args) { - const struct testBackingXMLjsonXMLdata *data =3D args; + const char *xmlstr =3D args; VIR_AUTOPTR(xmlDoc) xml =3D NULL; VIR_AUTOPTR(xmlXPathContext) ctxt =3D NULL; VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -57,12 +52,13 @@ testBackingXMLjsonXML(const void *args) if (!(xmlsrc =3D virStorageSourceNew())) return -1; - xmlsrc->type =3D data->type; - - if (!(xml =3D virXMLParseStringCtxt(data->xml, "(test storage source X= ML)", &ctxt))) + if (!(xml =3D virXMLParseStringCtxt(xmlstr, "(test storage source XML)= ", &ctxt))) return -1; - if (virDomainDiskSourceParse(ctxt->node, ctxt, xmlsrc, 0, NULL) < 0) { + if (!(xmlsrc =3D virDomainStorageSourceParseFull("string(./@type)", + "string(./@format)", + ".", NULL, false, + ctxt, 0, NULL))) { fprintf(stderr, "failed to parse disk source xml\n"); return -1; } @@ -86,17 +82,19 @@ testBackingXMLjsonXML(const void *args) return -1; } - if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, 0, true, false, false,= NULL) < 0 || + jsonsrc->format =3D VIR_STORAGE_FILE_RAW; + + if (virDomainStorageSourceFormatFull(&buf, jsonsrc, "source", false, f= alse, NULL) < 0 || !(actualxml =3D virBufferContentAndReset(&buf))) { fprintf(stderr, "failed to format disk source xml\n"); return -1; } - if (STRNEQ(actualxml, data->xml)) { + if (STRNEQ(actualxml, xmlstr)) { fprintf(stderr, "\n expected storage source xml:\n'%s'\n" "actual storage source xml:\n%s\n" "intermediate json:\n%s\n", - data->xml, actualxml, protocolwrapper); + xmlstr, actualxml, protocolwrapper); return -1; } @@ -317,7 +315,6 @@ mymain(void) { int ret =3D 0; virQEMUDriver driver; - struct testBackingXMLjsonXMLdata xmljsonxmldata; struct testQemuDiskXMLToJSONData diskxmljsondata; char *capslatest_x86_64 =3D NULL; virQEMUCapsPtr caps_x86_64 =3D NULL; @@ -341,70 +338,65 @@ mymain(void) virTestCounterReset("qemu storage source xml->json->xml "); -# define TEST_JSON_FORMAT(tpe, xmlstr) \ +# define TEST_JSON_FORMAT(xmlstr) \ do { \ - xmljsonxmldata.type =3D tpe; \ - xmljsonxmldata.xml =3D xmlstr; \ if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, \ - &xmljsonxmldata) < 0) \ + xmlstr) < 0) \ ret =3D -1; \ } while (0) -# define TEST_JSON_FORMAT_NET(xmlstr) \ - TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NETWORK, xmlstr) - - TEST_JSON_FORMAT(VIR_STORAGE_TYPE_FILE, "\n"); + TEST_JSON_FORMAT("\n"); /* type VIR_STORAGE_TYPE_BLOCK is not tested since it parses back to '= file' */ /* type VIR_STORAGE_TYPE_DIR it is a 'format' driver in qemu */ - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\= n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - " \n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\= n" - " \n" - " \n" - " \n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); - TEST_JSON_FORMAT_NET("\n" - " \n" - "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + " = \n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + " \n" + " \n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); + TEST_JSON_FORMAT("\n" + " \n" + "\n"); # define TEST_DISK_TO_JSON_FULL(nme, fl) \ do { \ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list