From nobody Mon Feb 9 13:57:33 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 155197350184523.569986807277814; Thu, 7 Mar 2019 07:45:01 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0027930D78B5; Thu, 7 Mar 2019 15:45:00 +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 CB7941001E79; Thu, 7 Mar 2019 15:44:59 +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 947173FA4C; Thu, 7 Mar 2019 15:44:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x27FimB0018684 for ; Thu, 7 Mar 2019 10:44:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7CB191F2; Thu, 7 Mar 2019 15:44:48 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00D5B19C69 for ; Thu, 7 Mar 2019 15:44:47 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 7 Mar 2019 16:44:37 +0100 Message-Id: <20190307154437.1405-9-abologna@redhat.com> In-Reply-To: <20190307154437.1405-1-abologna@redhat.com> References: <20190307154437.1405-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] tests: Use testQemuCapsIterate() 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 07 Mar 2019 15:45:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With only a couple minor tweaks, we can make the existing doCapsTest() functions with testQemuCapsIterate() and finally remove the need to manually adjust the test programs every time a new input file is introduced; moreover, this means that the two lists can't possibly get out of sync anymore. Signed-off-by: Andrea Bolognani --- tests/qemucapabilitiestest.c | 48 +++--------------------------------- tests/qemucaps2xmltest.c | 48 +++--------------------------------- 2 files changed, 8 insertions(+), 88 deletions(-) diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index b4ed081d3e..16c2832ffb 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -179,8 +179,9 @@ testQemuCapsCopy(const void *opaque) static int doCapsTest(const char *base, const char *archName, - testQemuDataPtr data) + void *opaque) { + testQemuDataPtr data =3D (testQemuDataPtr) opaque; VIR_AUTOFREE(char *) title =3D NULL; VIR_AUTOFREE(char *) copyTitle =3D NULL; =20 @@ -220,49 +221,8 @@ mymain(void) if (testQemuDataInit(&data) < 0) return EXIT_FAILURE; =20 -#define DO_TEST(arch, name) \ - do { \ - if (doCapsTest(name, arch, &data) < 0) \ - return EXIT_FAILURE; \ - } while (0) - - /* Keep this in sync with qemucaps2xmltest */ - DO_TEST("x86_64", "caps_1.5.3"); - DO_TEST("x86_64", "caps_1.6.0"); - DO_TEST("x86_64", "caps_1.7.0"); - DO_TEST("x86_64", "caps_2.1.1"); - DO_TEST("x86_64", "caps_2.4.0"); - DO_TEST("x86_64", "caps_2.5.0"); - DO_TEST("x86_64", "caps_2.6.0"); - DO_TEST("x86_64", "caps_2.7.0"); - DO_TEST("x86_64", "caps_2.8.0"); - DO_TEST("x86_64", "caps_2.9.0"); - DO_TEST("x86_64", "caps_2.10.0"); - DO_TEST("x86_64", "caps_2.11.0"); - DO_TEST("x86_64", "caps_2.12.0"); - DO_TEST("x86_64", "caps_3.0.0"); - DO_TEST("x86_64", "caps_3.1.0"); - DO_TEST("x86_64", "caps_4.0.0"); - DO_TEST("aarch64", "caps_2.6.0"); - DO_TEST("aarch64", "caps_2.10.0"); - DO_TEST("aarch64", "caps_2.12.0"); - DO_TEST("ppc64", "caps_2.6.0"); - DO_TEST("ppc64", "caps_2.9.0"); - DO_TEST("ppc64", "caps_2.10.0"); - DO_TEST("ppc64", "caps_2.12.0"); - DO_TEST("ppc64", "caps_3.0.0"); - DO_TEST("ppc64", "caps_3.1.0"); - DO_TEST("s390x", "caps_2.7.0"); - DO_TEST("s390x", "caps_2.8.0"); - DO_TEST("s390x", "caps_2.9.0"); - DO_TEST("s390x", "caps_2.10.0"); - DO_TEST("s390x", "caps_2.11.0"); - DO_TEST("s390x", "caps_2.12.0"); - DO_TEST("s390x", "caps_3.0.0"); - DO_TEST("riscv32", "caps_3.0.0"); - DO_TEST("riscv32", "caps_4.0.0"); - DO_TEST("riscv64", "caps_3.0.0"); - DO_TEST("riscv64", "caps_4.0.0"); + if (testQemuCapsIterate(data.dataDir, ".replies", doCapsTest, &data) <= 0) + return EXIT_FAILURE; =20 /* * Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies" diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index dff4e2a884..e21fde7e0b 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -182,8 +182,9 @@ testQemuCapsXML(const void *opaque) static int doCapsTest(const char *base, const char *archName, - testQemuDataPtr data) + void *opaque) { + testQemuDataPtr data =3D (testQemuDataPtr) opaque; VIR_AUTOFREE(char *) title =3D NULL; =20 if (virAsprintf(&title, "%s (%s)", base, archName) < 0) @@ -216,49 +217,8 @@ mymain(void) if (testQemuDataInit(&data) < 0) return EXIT_FAILURE; =20 -#define DO_TEST(arch, name) \ - do { \ - if (doCapsTest(name, arch, &data) < 0) \ - return EXIT_FAILURE; \ - } while (0) - - /* Keep this in sync with qemucapabilitiestest */ - DO_TEST("x86_64", "caps_1.5.3"); - DO_TEST("x86_64", "caps_1.6.0"); - DO_TEST("x86_64", "caps_1.7.0"); - DO_TEST("x86_64", "caps_2.1.1"); - DO_TEST("x86_64", "caps_2.4.0"); - DO_TEST("x86_64", "caps_2.5.0"); - DO_TEST("x86_64", "caps_2.6.0"); - DO_TEST("x86_64", "caps_2.7.0"); - DO_TEST("x86_64", "caps_2.8.0"); - DO_TEST("x86_64", "caps_2.9.0"); - DO_TEST("x86_64", "caps_2.10.0"); - DO_TEST("x86_64", "caps_2.11.0"); - DO_TEST("x86_64", "caps_2.12.0"); - DO_TEST("x86_64", "caps_3.0.0"); - DO_TEST("x86_64", "caps_3.1.0"); - DO_TEST("x86_64", "caps_4.0.0"); - DO_TEST("aarch64", "caps_2.6.0"); - DO_TEST("aarch64", "caps_2.10.0"); - DO_TEST("aarch64", "caps_2.12.0"); - DO_TEST("ppc64", "caps_2.6.0"); - DO_TEST("ppc64", "caps_2.9.0"); - DO_TEST("ppc64", "caps_2.10.0"); - DO_TEST("ppc64", "caps_2.12.0"); - DO_TEST("ppc64", "caps_3.0.0"); - DO_TEST("ppc64", "caps_3.1.0"); - DO_TEST("s390x", "caps_2.7.0"); - DO_TEST("s390x", "caps_2.8.0"); - DO_TEST("s390x", "caps_2.9.0"); - DO_TEST("s390x", "caps_2.10.0"); - DO_TEST("s390x", "caps_2.11.0"); - DO_TEST("s390x", "caps_2.12.0"); - DO_TEST("s390x", "caps_3.0.0"); - DO_TEST("riscv32", "caps_3.0.0"); - DO_TEST("riscv32", "caps_4.0.0"); - DO_TEST("riscv64", "caps_3.0.0"); - DO_TEST("riscv64", "caps_4.0.0"); + if (testQemuCapsIterate(data.inputDir, ".xml", doCapsTest, &data) < 0) + return EXIT_FAILURE; =20 testQemuDataReset(&data); =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list