From nobody Mon Feb 9 19:53:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1618346431; cv=none; d=zohomail.com; s=zohoarc; b=DA5NDGUR8w1UdDDklQzYR+xOu2RWGiW7z66eRPX2p6aaOBxugMdaiatihWIa51nXUDvKfOffZFopBlOtT2Iyek67s6C94JI3GObUIlCoti4g0dUL8oGyMlg3eoSxfZeiYEqSwpRwEdTwvkmswa7p2Kn0hpFIAzi51Xlct+0cV60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346431; 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=5+Yx8nMe25AR+YvThmZya6qaYblk9Qbw0ljbMM7asZY=; b=FA74AEJjv4/5b87fHO2iTt6Z8HCo0mWNoY3JnIZueKoRvHarHEiTCmxRyijGTMXMcUSL/8GrMvZ8u3WgOSBgLQ2OYQM6NcPwpqHkHgfm8BFTuo24mQM9YfXQemC8siUsadOcUhalgRFhA2Uv5EMwwKiTTBE1rn8nAyO9p4WA34k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 161834643195038.98553043593495; Tue, 13 Apr 2021 13:40:31 -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-276-l7Quns0LPhSeGm_smcL9yA-1; Tue, 13 Apr 2021 16:40:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F758C73A4; Tue, 13 Apr 2021 20:40:23 +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 6579119744; Tue, 13 Apr 2021 20:40:23 +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 220131806D20; Tue, 13 Apr 2021 20:40:23 +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 13DKdufl011729 for ; Tue, 13 Apr 2021 16:39:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E48F19744; Tue, 13 Apr 2021 20:39:56 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4ED071972B for ; Tue, 13 Apr 2021 20:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346430; 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=5+Yx8nMe25AR+YvThmZya6qaYblk9Qbw0ljbMM7asZY=; b=M1KiTbkRGuokZWVEkGJF3awsox1yF6AGM/+UiqOqNpv91N0WKtwEveZ52PHy5NahWylkjB ltm5JsHXkNNEMpU8PdJ/L1yDtn8gsDZunxRtBuV2Qw/G75zfv+jNUrIpju5OBVSCWpG8Lt ht73nWxhoASHrs3Ec+yucRYZb3YjZls= X-MC-Unique: l7Quns0LPhSeGm_smcL9yA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/12] tests: nodedev: simplify test macros Date: Tue, 13 Apr 2021 15:39:46 -0500 Message-Id: <20210413203948.71864-11-jjongsma@redhat.com> In-Reply-To: <20210413203948.71864-1-jjongsma@redhat.com> References: <20210413203948.71864-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We only use the virt_type "QEMU" in this tests, so simply hard-code it in the test function rather than specifying it in the test macro. In addition, we can figure out the appropriate value for 'create' from the command type, so push that into the test function rather than specifying it in the test macro. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- tests/nodedevmdevctltest.c | 43 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index bba521e563..4c316e3ed0 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -10,9 +10,9 @@ =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 +#define VIRT_TYPE "QEMU" + struct TestInfo { - const char *virt_type; - int create; const char *filename; virMdevctlCommand command; }; @@ -36,9 +36,7 @@ typedef virCommand * (*MdevctlCmdFunc)(virNodeDeviceDef *= , char **, char **); =20 =20 static int -testMdevctlCmd(const char *virt_type, - int create, - virMdevctlCommand cmd_type, +testMdevctlCmd(virMdevctlCommand cmd_type, const char *mdevxml, const char *cmdfile, const char *jsonfile) @@ -53,8 +51,24 @@ testMdevctlCmd(const char *virt_type, g_autofree char *stdinbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + int create; + + switch (cmd_type) { + case MDEVCTL_CMD_CREATE: + case MDEVCTL_CMD_DEFINE: + create =3D CREATE_DEVICE; + break; + case MDEVCTL_CMD_START: + case MDEVCTL_CMD_STOP: + case MDEVCTL_CMD_UNDEFINE: + create =3D EXISTING_DEVICE; + break; + case MDEVCTL_CMD_LAST: + default: + goto cleanup; + } =20 - if (!(def =3D virNodeDeviceDefParseFile(mdevxml, create, virt_type))) + if (!(def =3D virNodeDeviceDefParseFile(mdevxml, create, VIRT_TYPE))) goto cleanup; =20 /* this function will set a stdin buffer containing the json configura= tion @@ -106,8 +120,7 @@ testMdevctlHelper(const void *data) jsonfile =3D g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_s= rcdir, info->filename, cmd); =20 - return testMdevctlCmd(info->virt_type, info->create, info->command, - mdevxml, cmdlinefile, jsonfile); + return testMdevctlCmd(info->command, mdevxml, cmdlinefile, jsonfile); } =20 =20 @@ -316,27 +329,27 @@ mymain(void) if (virTestRun(desc, func, info) < 0) \ ret =3D -1; =20 -#define DO_TEST_CMD(desc, virt_type, create, filename, command) \ +#define DO_TEST_CMD(desc, filename, command) \ do { \ - struct TestInfo info =3D { virt_type, create, filename, command };= \ + struct TestInfo info =3D { filename, command }; \ DO_TEST_FULL(desc, testMdevctlHelper, &info); \ } \ while (0) =20 #define DO_TEST_CREATE(filename) \ - DO_TEST_CMD("create mdev " filename, "QEMU", CREATE_DEVICE, filename, = MDEVCTL_CMD_CREATE) + DO_TEST_CMD("create mdev " filename, filename, MDEVCTL_CMD_CREATE) =20 #define DO_TEST_DEFINE(filename) \ - DO_TEST_CMD("define mdev " filename, "QEMU", CREATE_DEVICE, filename, = MDEVCTL_CMD_DEFINE) + DO_TEST_CMD("define mdev " filename, filename, MDEVCTL_CMD_DEFINE) =20 #define DO_TEST_STOP(filename) \ - DO_TEST_CMD("stop mdev " filename, "QEMU", EXISTING_DEVICE, filename, = MDEVCTL_CMD_STOP) + DO_TEST_CMD("stop mdev " filename, filename, MDEVCTL_CMD_STOP) =20 #define DO_TEST_UNDEFINE(filename) \ - DO_TEST_CMD("undefine mdev" filename, "QEMU", EXISTING_DEVICE, filenam= e, MDEVCTL_CMD_UNDEFINE) + DO_TEST_CMD("undefine mdev" filename, filename, MDEVCTL_CMD_UNDEFINE) =20 #define DO_TEST_START(filename) \ - DO_TEST_CMD("start mdev " filename, "QEMU", EXISTING_DEVICE, filename,= MDEVCTL_CMD_START) + DO_TEST_CMD("start mdev " filename, filename, MDEVCTL_CMD_START) =20 #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("list defined mdevs", testMdevctlListDefined, NULL) --=20 2.26.3