From nobody Mon Feb 9 23:14:54 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 1551973493875344.0105116192709; Thu, 7 Mar 2019 07:44:53 -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 159C8307E064; Thu, 7 Mar 2019 15:44:52 +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 DD4D65C545; Thu, 7 Mar 2019 15:44: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 9DD9E3FA4B; Thu, 7 Mar 2019 15:44:51 +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 x27Fijn6018659 for ; Thu, 7 Mar 2019 10:44:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id F089F19C69; Thu, 7 Mar 2019 15:44:45 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7354119C72 for ; Thu, 7 Mar 2019 15:44:45 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 7 Mar 2019 16:44:34 +0100 Message-Id: <20190307154437.1405-6-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 5/8] tests: Move code from DO_TEST() to doCapsTest() 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 07 Mar 2019 15:44:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This removes the awkard escaping and will allow us to perform some interesting refactoring later on. Signed-off-by: Andrea Bolognani --- tests/qemucapabilitiestest.c | 40 +++++++++++++++++++++++++----------- tests/qemucaps2xmltest.c | 28 ++++++++++++++++++------- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 222ac05d79..b4ed081d3e 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -176,6 +176,32 @@ testQemuCapsCopy(const void *opaque) } =20 =20 +static int +doCapsTest(const char *base, + const char *archName, + testQemuDataPtr data) +{ + VIR_AUTOFREE(char *) title =3D NULL; + VIR_AUTOFREE(char *) copyTitle =3D NULL; + + if (virAsprintf(&title, "%s (%s)", base, archName) < 0 || + virAsprintf(©Title, "copy %s (%s)", base, archName) < 0) { + return -1; + } + + data->base =3D base; + data->archName =3D archName; + + if (virTestRun(title, testQemuCaps, data) < 0) + data->ret =3D -1; + + if (virTestRun(copyTitle, testQemuCapsCopy, data) < 0) + data->ret =3D -1; + + return 0; +} + + static int mymain(void) { @@ -196,18 +222,8 @@ mymain(void) =20 #define DO_TEST(arch, name) \ do { \ - VIR_AUTOFREE(char *) title =3D NULL; \ - VIR_AUTOFREE(char *) copyTitle =3D NULL; \ - if (virAsprintf(&title, "%s (%s)", name, arch) < 0 || \ - virAsprintf(©Title, "copy %s (%s)", name, arch) < 0) { \ - return -EXIT_FAILURE; \ - } \ - data.archName =3D arch; \ - data.base =3D name; \ - if (virTestRun(title, testQemuCaps, &data) < 0) \ - data.ret =3D -1; \ - if (virTestRun(copyTitle, testQemuCapsCopy, &data) < 0) \ - data.ret =3D -1; \ + if (doCapsTest(name, arch, &data) < 0) \ + return EXIT_FAILURE; \ } while (0) =20 /* Keep this in sync with qemucaps2xmltest */ diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index be460b42f8..4f9cfc459e 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -178,6 +178,25 @@ testQemuCapsXML(const void *opaque) return ret; } =20 +static int +doCapsTest(const char *base, + const char *archName, + testQemuDataPtr data) +{ + VIR_AUTOFREE(char *) title =3D NULL; + + if (virAsprintf(&title, "%s (%s)", base, archName) < 0) + return -1; + + data->base =3D base; + data->archName =3D archName; + + if (virTestRun(title, testQemuCapsXML, data) < 0) + data->ret =3D -1; + + return 0; +} + static int mymain(void) { @@ -198,13 +217,8 @@ mymain(void) =20 #define DO_TEST(arch, name) \ do { \ - VIR_AUTOFREE(char *) title =3D NULL; \ - if (virAsprintf(&title, "%s (%s)", name, arch) < 0) \ - return -EXIT_FAILURE; \ - data.archName =3D arch; \ - data.base =3D name; \ - if (virTestRun(title, testQemuCapsXML, &data) < 0) \ - data.ret =3D -1; \ + if (doCapsTest(name, arch, &data) < 0) \ + return EXIT_FAILURE; \ } while (0) =20 /* Keep this in sync with qemucapabilitiestest */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list