From nobody Mon Feb 9 23:39:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1608819456; cv=none; d=zohomail.com; s=zohoarc; b=aMHKy3LNXH+6rpD/s70d4Dnl7qAOC/PU4nKGt2HQHnplUv2UyAL2xucpEPSMq4LUrhprbVK8oxxvttCvzxr1uvoObbRhXxzVaTXSEuX5YZqJPIWWARb8Siv5ZPC8IcUWRuW5p52r/mqLX6PF9+ckxu0DAaaUQ+D9EQwBDciy650= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608819456; h=Content-Type:Content-Transfer-Encoding:Cc: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=mXZ1QBrb+x+fZbNzKDMIAcPEEvRpCugTZMn9zwUVkEk=; b=dOs8wnxUWbyEcU9dzL/bBfXuKWrloi9Nv4AExpuRXV+6AJlTJOm8s9RqSJrctiTlSREW+FJSBzwzA9YEhwq5BZvZVKh9oaponUtQaW2dJ6V7/rTZKU6FxC11k94QIGFwh94uFz8D9Tis+MuvRn5JmGsLPVvMhI/RWz+qu6LZ/gI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608819456855299.2961932434134; Thu, 24 Dec 2020 06:17:36 -0800 (PST) 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-335-YsQRnPmNMi-Xa7OCWadtFA-1; Thu, 24 Dec 2020 09:15:33 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8C9D8030AF; Thu, 24 Dec 2020 14:15:24 +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 9832E5C1A3; Thu, 24 Dec 2020 14:15:24 +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 6327D5003F; Thu, 24 Dec 2020 14:15:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BOEEubx005705 for ; Thu, 24 Dec 2020 09:14:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1998171C8D; Thu, 24 Dec 2020 14:14:56 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-112-15.phx2.redhat.com [10.3.112.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5DC55C1A3; Thu, 24 Dec 2020 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608819455; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=mXZ1QBrb+x+fZbNzKDMIAcPEEvRpCugTZMn9zwUVkEk=; b=dIebGfIdbffsgdAPYIOg6VRqKzv+vtCb8rsuIcfJ9b9Adr6TOoVezr1YW+QvajRdklQH0K z6fUMxGadXaKfM/2DrwYRcm9HdjUK2RGbpzlwi9m1oLmAlqdsjyuvCCpsMgiqwTXaBMG9n 9HNeS5VseZqAicKn87MOW2y50rG/5vE= X-MC-Unique: YsQRnPmNMi-Xa7OCWadtFA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v3 15/21] nodedev: refactor tests to support mdev undefine Date: Thu, 24 Dec 2020 08:14:39 -0600 Message-Id: <20201224141445.163819-16-jjongsma@redhat.com> In-Reply-To: <20201224141445.163819-1-jjongsma@redhat.com> References: <20201224141445.163819-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: eskultet@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.16 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" mdevctl 'stop' and 'undefine' commands take the same uuid parameter, so refactor the test infrastructure to share common implementation for both of these commands. The 'undefine' command will be introduced in a following patch. Signed-off-by: Jonathon Jongsma --- tests/nodedevmdevctltest.c | 48 +++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 981276d180..56265cfaea 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -12,7 +12,9 @@ =20 typedef enum { MDEVCTL_CMD_START, + MDEVCTL_CMD_STOP, MDEVCTL_CMD_DEFINE, + MDEVCTL_CMD_UNDEFINE } MdevctlCmd; =20 struct startTestInfo { @@ -134,19 +136,21 @@ testMdevctlStartHelper(const void *data) mdevxml, cmdlinefile, jsonfile); } =20 +typedef virCommandPtr (*GetStopUndefineCmdFunc)(const char *uuid); +struct UuidCommandTestInfo { + const char *uuid; + MdevctlCmd command; +}; + static int -testMdevctlStop(const void *data) +testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, cons= t char *outfile) { - const char *uuid =3D data; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; g_autoptr(virCommand) cmd =3D NULL; - g_autofree char *cmdlinefile =3D - g_strdup_printf("%s/nodedevmdevctldata/mdevctl-stop.argv", - abs_srcdir); =20 - cmd =3D nodeDeviceGetMdevctlStopCommand(uuid); + cmd =3D func(uuid); =20 if (!cmd) goto cleanup; @@ -158,7 +162,7 @@ testMdevctlStop(const void *data) if (!(actualCmdline =3D virBufferCurrentContent(&buf))) goto cleanup; =20 - if (nodedevCompareToFile(actualCmdline, cmdlinefile) < 0) + if (nodedevCompareToFile(actualCmdline, outfile) < 0) goto cleanup; =20 ret =3D 0; @@ -168,6 +172,27 @@ testMdevctlStop(const void *data) return ret; } =20 +static int +testMdevctlUuidCommandHelper(const void *data) +{ + const struct UuidCommandTestInfo *info =3D data; + GetStopUndefineCmdFunc func; + const char *cmd; + g_autofree char *cmdlinefile =3D NULL; + + if (info->command =3D=3D MDEVCTL_CMD_STOP) { + cmd =3D "stop"; + func =3D nodeDeviceGetMdevctlStopCommand; + } else { + return -1; + } + + cmdlinefile =3D g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv= ", + abs_srcdir, cmd); + + return testMdevctlUuidCommand(info->uuid, func, cmdlinefile); +} + static int testMdevctlListDefined(const void *data G_GNUC_UNUSED) { @@ -385,8 +410,15 @@ mymain(void) #define DO_TEST_DEFINE(filename) \ DO_TEST_START_FULL("mdevctl define " filename, "QEMU", CREATE_DEVICE, = filename, MDEVCTL_CMD_DEFINE) =20 +#define DO_TEST_UUID_COMMAND_FULL(desc, uuid, command) \ + do { \ + struct UuidCommandTestInfo info =3D { uuid, command }; \ + DO_TEST_FULL(desc, testMdevctlUuidCommandHelper, &info); \ + } \ + while (0) + #define DO_TEST_STOP(uuid) \ - DO_TEST_FULL("mdevctl stop " uuid, testMdevctlStop, uuid) + DO_TEST_UUID_COMMAND_FULL("mdevctl stop " uuid, uuid, MDEVCTL_CMD_STOP) =20 #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL) --=20 2.26.2