From nobody Mon Feb 9 19:25:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618346409; cv=none; d=zohomail.com; s=zohoarc; b=fwRw5mkU9gBmDZWpWA83E+tFg/oiNhef6XBHXFYJ+oYYEHK4eW1+5+vCE5SOLQgY4ipINDSm9Ho/cpow5QYJ27gthYLNQmukHmKz3uiDx/0xEpB9tv/vftH75rSWPLJl7TU9P3t97gYOjDkcc0aUytUVQXfR2apvR/gKsyG5+js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346409; 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=i2XJR/Qr89mA1ayPOVUdwTqJfVGyBLj7fPUtVmi7To4=; b=eqxEFs6DuxL6RCEMun9eg1imQJVIw11if4io9kjerrhWvYGh3k8Zsss3pEz22qoHH+eLIcRnxKods+DLxcahu6QDSv9pfqDn/+niUiekV3bjQQGm0mQvy7NHwPkKREypoKeWNY+Yj64dZnDOA2t9vUYoYdcQtnrDxhPw9rTurGU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618346409133455.95644521029453; Tue, 13 Apr 2021 13:40:09 -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-451-cg8A7L--MFyoM6LGLKU1xQ-1; Tue, 13 Apr 2021 16:40:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FF1B1922962; Tue, 13 Apr 2021 20:39:59 +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 612216A037; Tue, 13 Apr 2021 20:39:58 +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 E40A044A5B; Tue, 13 Apr 2021 20:39:57 +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 13DKdr4M011676 for ; Tue, 13 Apr 2021 16:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id EAF1019744; Tue, 13 Apr 2021 20:39:53 +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 BC5291972B for ; Tue, 13 Apr 2021 20:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346408; 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=i2XJR/Qr89mA1ayPOVUdwTqJfVGyBLj7fPUtVmi7To4=; b=U4s7T4YxTBMsEktt0aXJ5xhZcIS9PIYG5+fl//q4h+6i5aIsCTYwkRskgbrBQT8Ry5RbrA 0EyLSUlhblCEcKK2CbpkpIAZ+Do+x24nctnaFuB6pfv6VAp5kLd7Ap+qYL5W9OHje5kICB g9OVKWVtOupjqphzVJLyc4jEfV8ip60= X-MC-Unique: cg8A7L--MFyoM6LGLKU1xQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/12] tests: nodedev: switch all test macros to accept a filename Date: Tue, 13 Apr 2021 15:39:39 -0500 Message-Id: <20210413203948.71864-4-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.79 on 10.5.11.13 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" Rather than specifying a UUID string to some test macros, just pass a filename to an xml definition. This helps work toward unifying the test macros and making it more maintainable. Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- tests/nodedevmdevctldata/mdevctl-create.argv | 2 +- tests/nodedevmdevctldata/mdevctl-stop.argv | 2 +- .../nodedevmdevctldata/mdevctl-undefine.argv | 2 +- tests/nodedevmdevctltest.c | 38 +++++++++++-------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/tests/nodedevmdevctldata/mdevctl-create.argv b/tests/nodedevmd= evctldata/mdevctl-create.argv index f19c9780dc..ccb8e2992c 100644 --- a/tests/nodedevmdevctldata/mdevctl-create.argv +++ b/tests/nodedevmdevctldata/mdevctl-create.argv @@ -1,3 +1,3 @@ mdevctl \ start \ --u 8a05ad83-3472-497d-8631-8142f31460e8 +-u d069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdev= ctldata/mdevctl-stop.argv index cc621191d6..a07d339e47 100644 --- a/tests/nodedevmdevctldata/mdevctl-stop.argv +++ b/tests/nodedevmdevctldata/mdevctl-stop.argv @@ -1,3 +1,3 @@ mdevctl \ stop \ --u e2451f73-c95b-4124-b900-e008af37c576 +-u d069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdevctl-undefine.argv b/tests/nodedev= mdevctldata/mdevctl-undefine.argv index f1a59c5242..dbde32e2a8 100644 --- a/tests/nodedevmdevctldata/mdevctl-undefine.argv +++ b/tests/nodedevmdevctldata/mdevctl-undefine.argv @@ -1,3 +1,3 @@ mdevctl \ undefine \ --u d76a6b78-45ed-4149-a325-005f9abc5281 +-u d069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 99e79c18a5..df4185b5f8 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -125,13 +125,15 @@ testMdevctlStartOrDefineHelper(const void *data) =20 typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **err= buf); struct UuidCommandTestInfo { - const char *uuid; + const char *filename; MdevctlCmd command; }; =20 static int -testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, cons= t char *outfile) +testMdevctlUuidCommand(GetStopUndefineCmdFunc func, + const char *mdevxml, const char *outfile) { + g_autoptr(virNodeDeviceDef) def =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; @@ -139,7 +141,10 @@ testMdevctlUuidCommand(const char *uuid, GetStopUndefi= neCmdFunc func, const char g_autofree char *errmsg =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 - cmd =3D func(uuid, &errmsg); + if (!(def =3D virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEM= U"))) + goto cleanup; + + cmd =3D func(def->caps->data.mdev.uuid, &errmsg); =20 if (!cmd) goto cleanup; @@ -167,6 +172,7 @@ testMdevctlUuidCommandHelper(const void *data) GetStopUndefineCmdFunc func; const char *cmd; g_autofree char *cmdlinefile =3D NULL; + g_autofree char *mdevxml =3D NULL; =20 if (info->command =3D=3D MDEVCTL_CMD_STOP) { cmd =3D "stop"; @@ -181,10 +187,12 @@ testMdevctlUuidCommandHelper(const void *data) return -1; } =20 + mdevxml =3D g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, + info->filename); cmdlinefile =3D g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv= ", abs_srcdir, cmd); =20 - return testMdevctlUuidCommand(info->uuid, func, cmdlinefile); + return testMdevctlUuidCommand(func, mdevxml, cmdlinefile); } =20 static int @@ -405,21 +413,21 @@ mymain(void) #define DO_TEST_DEFINE(filename) \ DO_TEST_CMD("mdevctl define " filename, "QEMU", CREATE_DEVICE, filenam= e, MDEVCTL_CMD_DEFINE) =20 -#define DO_TEST_UUID_COMMAND_FULL(desc, uuid, command) \ +#define DO_TEST_UUID_COMMAND_FULL(desc, filename, command) \ do { \ - struct UuidCommandTestInfo info =3D { uuid, command }; \ + struct UuidCommandTestInfo info =3D { filename, command }; \ DO_TEST_FULL(desc, testMdevctlUuidCommandHelper, &info); \ } \ while (0) =20 -#define DO_TEST_STOP(uuid) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl stop " uuid, uuid, MDEVCTL_CMD_STOP) +#define DO_TEST_STOP(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl stop " filename, filename, MDEVCTL_= CMD_STOP) =20 -#define DO_TEST_UNDEFINE(uuid) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " uuid, uuid, MDEVCTL_CMD_= UNDEFINE) +#define DO_TEST_UNDEFINE(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " filename, filename, MDEV= CTL_CMD_UNDEFINE) =20 -#define DO_TEST_CREATE(uuid) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl create " uuid, uuid, MDEVCTL_CMD_CR= EATE) +#define DO_TEST_CREATE(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl create " filename, filename, MDEVCT= L_CMD_CREATE) =20 #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL) @@ -433,7 +441,7 @@ mymain(void) DO_TEST_START("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); =20 /* Test mdevctl stop command, pass an arbitrary uuid */ - DO_TEST_STOP("e2451f73-c95b-4124-b900-e008af37c576"); + DO_TEST_STOP("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 DO_TEST_LIST_DEFINED(); =20 @@ -443,9 +451,9 @@ mymain(void) DO_TEST_DEFINE("mdev_fedc4916_1ca8_49ac_b176_871d16c13076"); DO_TEST_DEFINE("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); =20 - DO_TEST_UNDEFINE("d76a6b78-45ed-4149-a325-005f9abc5281"); + DO_TEST_UNDEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 - DO_TEST_CREATE("8a05ad83-3472-497d-8631-8142f31460e8"); + DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 done: nodedevTestDriverFree(driver); --=20 2.26.3