From nobody Mon Feb 9 23:00:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571827424; cv=none; d=zoho.com; s=zohoarc; b=mF9RlbNCLPdzI/ieb+svZbbeBywD2DfNE4HKYM+zmsUA1HyfVjGg9wR3HwYpczHUoVAp9swpW/HaDcv4cudFaEvUw+HclVpHeLGJweE3MxO8jei1FRDNXel8FKNN+C7iHINzsrKZwUfzkLcYRfsskCsEeyC6hTRBvuh7ZIWGa0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571827424; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s8seQ/ULa7im47BlkL0S26wASDovLG9qY3sS5aYEBGs=; b=L/9KqcwdlD8OynUmfy5PBG20FxN+tlxYNwrf0UvUVsnSff7MEJNO6fWF6n4f+y6RYU33VoeCHVhEi49XrCcGHGepNwW1YeCvftzZWIOx3NB1v0Qga8+hiNulMLl34GuCgEnnsm6EuAApG6vu+6cjQiRLuB/A/WNfWOTDOU0QJIk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571827424057804.1300388971376; Wed, 23 Oct 2019 03:43:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-4314XAtdNz-D4i91-uu98g-1; Wed, 23 Oct 2019 06:43:39 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 279D3107AD3C; Wed, 23 Oct 2019 10:43:34 +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 EF1221001DF0; Wed, 23 Oct 2019 10:43:33 +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 AD94F180BA9F; Wed, 23 Oct 2019 10:43:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9NAhMoj020304 for ; Wed, 23 Oct 2019 06:43:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD01EBA79; Wed, 23 Oct 2019 10:43:22 +0000 (UTC) Received: from kinshicho.redhat.com (unknown [10.40.205.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B3E860E1C for ; Wed, 23 Oct 2019 10:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571827422; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=s8seQ/ULa7im47BlkL0S26wASDovLG9qY3sS5aYEBGs=; b=B/r4qA79rw5DD7Og4zQwvpmu91bjEJMQmhIzIN0sNZ1iHGDUwnAGGdPFwR0C5bRyj3jYrr r2yJgv/YpAuy70j8JydYfITXHwwu3VLNBhVRNXR1vcC/TZdNtnr0pQnPU99bEDmC/pRz1M b3fEOCb17W5XivZFi1kPuH4M146WYoY= From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 23 Oct 2019 12:42:59 +0200 Message-Id: <20191023104302.26669-10-abologna@redhat.com> In-Reply-To: <20191023104302.26669-1-abologna@redhat.com> References: <20191023104302.26669-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/12] tests/domaincaps: Move most of DO_TEST_QEMU() into a function 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: , 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-MC-Unique: 4314XAtdNz-D4i91-uu98g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Macros become less and less appealing the more work you perform inside them: DO_TEST_QEMU() has arguably already crossed that threshold, and we're going to add even more code later on. While factoring the code out of the macro, convert it to use the GLib string manipulation functions and take advantage of autofree. Signed-off-by: Andrea Bolognani --- tests/domaincapstest.c | 50 ++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index f38f5fb047..e35eddc659 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -266,6 +266,36 @@ test_virDomainCapsFormat(const void *opaque) return ret; } =20 +static int +doTestQemu(const char *partialName, + const char *capsName, + const char *emulator, + const char *machine, + const char *arch, + virDomainVirtType type, + void *opaque) +{ + g_autofree char *name =3D NULL; + + name =3D g_strdup_printf("qemu_%s.%s", partialName, arch); + + struct testData data =3D { + .name =3D name, + .emulator =3D emulator, + .machine =3D machine, + .arch =3D arch, + .type =3D type, + .capsType =3D CAPS_QEMU, + .capsName =3D capsName, + .capsOpaque =3D opaque, + }; + + if (virTestRun(name, test_virDomainCapsFormat, &data) < 0) + return -1; + + return 0; +} + static int mymain(void) { @@ -298,26 +328,8 @@ mymain(void) =20 #define DO_TEST_QEMU(Name, CapsName, Emulator, Machine, Arch, Type) \ do { \ - char *name =3D NULL; \ - if (virAsprintf(&name, "qemu_%s.%s", \ - Name, \ - Arch) < 0) { \ + if (doTestQemu(Name, CapsName, Emulator, Machine, Arch, Type, cfg)= < 0) \ ret =3D -1; \ - break; \ - } \ - struct testData data =3D { \ - .name =3D name, \ - .emulator =3D Emulator, \ - .machine =3D Machine, \ - .arch =3D Arch, \ - .type =3D Type, \ - .capsType =3D CAPS_QEMU, \ - .capsName =3D CapsName, \ - .capsOpaque =3D cfg, \ - }; \ - if (virTestRun(name, test_virDomainCapsFormat, &data) < 0) \ - ret =3D -1; \ - VIR_FREE(name); \ } while (0) =20 #define DO_TEST_LIBXL(Name, Emulator, Machine, Arch, Type) \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list