From nobody Tue Feb 10 09:24:21 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=1618004021; cv=none; d=zohomail.com; s=zohoarc; b=HCP7d08u6V4kZDWeqzcISdTtvmEyO4igO8ZOKftDZFPT1ePt0D3PnQ/vcFTqtmC2Yo2lJIuM8wWe4FBAGCXxl9UWGacOplGKrm+wgUqZ/VXyg1I5sUBO1J2iRNd6Y9v+7IIXPYNO3JQqe/Zb7IpaCVUOTX3qOBp7neQAWAgZ+HU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618004021; 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=NikI/TbeTy1Uvi+BNyekm9+Pu+JjkxALCLqcVSScN/w=; b=ePvmbVYx8IdSAHuTbIga6NqlsYgk8K4N6JJ0aXe6k/3c40HCZ90fVFDULeABbPcCZs/JfVhAuhnpHA+FoY/qSKiSuQ02U8EwtrPMvbR2dSwdanBJU/JR//YvI/49Gm1wnY3AfG9BuG6RGlLQ0IuEl+jl4dF3s+cO0OQtTsfgbmA= 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 1618004021823595.0882402387568; Fri, 9 Apr 2021 14:33:41 -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-342-Lrcl1sH7OAqqrRIxIF-5tg-1; Fri, 09 Apr 2021 17:33:38 -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 0A1F681747D; Fri, 9 Apr 2021 21:33:34 +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 D637F1043276; Fri, 9 Apr 2021 21:33: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 994E41C98; Fri, 9 Apr 2021 21:33:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 139LXFbO032663 for ; Fri, 9 Apr 2021 17:33:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E3205D6AD; Fri, 9 Apr 2021 21:33:15 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D43685D6A1 for ; Fri, 9 Apr 2021 21:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618004020; 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=NikI/TbeTy1Uvi+BNyekm9+Pu+JjkxALCLqcVSScN/w=; b=AVaF/QepLVRpaxFoUvQKsZc2EYvlLJjMP/EbXAtrrLZe+1MncyYukiQ13pMUc7C38VG05e Hz64E1PjMPyGS6NGUgqcalahKzvEQB0m4Jg1rRYTMEvLyJc8OiLqBWyd/AzwqW69/r/obg ZzXQo6b47peHyLAaO0RjCzLQ8eLASlk= X-MC-Unique: Lrcl1sH7OAqqrRIxIF-5tg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 10/11] tests: nodedev: simplify test macros Date: Fri, 9 Apr 2021 16:33:05 -0500 Message-Id: <20210409213306.3971286-11-jjongsma@redhat.com> In-Reply-To: <20210409213306.3971286-1-jjongsma@redhat.com> References: <20210409213306.3971286-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.22 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 --- tests/nodedevmdevctltest.c | 43 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 7e192ce118..3a53254195 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; }; @@ -51,9 +51,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) @@ -67,8 +65,24 @@ testMdevctlCmd(const char *virt_type, g_autofree char *errbuf =3D NULL; g_autofree char *stdinbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; + 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 @@ -120,8 +134,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 @@ -330,27 +343,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