From nobody Tue Feb 10 12:40:13 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=1629498919; cv=none; d=zohomail.com; s=zohoarc; b=gPo2fZOtIiV/6n/pgimDkjd7q9mC8Utps6gpZMd++nfYmGFfhgywwVnDCb8haYE+K1ZX0kPkT4d2VZO8lOK5C9/JwjDhet1oWuWQfFL9ZFyrx3bRdUykD0OLxFGvJh0X/RpGNHe9BCZtoTADbVevB6v2+vcM1nyJTW7MQ2WKx6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629498919; 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=lhHDeF+VML76Y20EQiEVyYAz8gcltG4ezpT6xtYNohA=; b=Lw/9lMKjBAAfdqh5VQFcnyB+rFxvxI/GjouuOdsK1Jj+Ki1FfPzZhZwrHnIcSty4zdtG+OMabJHPluVKnvYnfkImaIUlOCqeCM6+34WDP9jBi0vnUNWtUlnuejDXZQmnFJqnAwHmaxRWHpkmlibNO6k2pr9FSX1YRj10NspsNmk= 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) 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 1629498919601104.3628571662972; Fri, 20 Aug 2021 15:35:19 -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-496-sLwKngzdOfK9AfGUnNkFFg-1; Fri, 20 Aug 2021 18:35:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34FB28015C7; Fri, 20 Aug 2021 22:35:11 +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 9927A6A905; Fri, 20 Aug 2021 22:35:10 +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 5C5844A7C9; Fri, 20 Aug 2021 22:35:10 +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 17KMTfCG028154 for ; Fri, 20 Aug 2021 18:29:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id B00371F5; Fri, 20 Aug 2021 22:29:41 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-57.phx2.redhat.com [10.3.114.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7060F1971B; Fri, 20 Aug 2021 22:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629498918; 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=lhHDeF+VML76Y20EQiEVyYAz8gcltG4ezpT6xtYNohA=; b=cJsMXEoowy1BEYilnoQAMm0zJwccD1edyDrfSY1jWu6tnXSR9dyVo7VShcn4VRqyPpZpjT 7HG6aHLv25v3Arev6t+nIMFkAUxJ2T+ilTv/nBm4fWM6OugNr53X7GmSjHSuLkXoVUhSQC f4YfHFcUWKYrDzTHSPrkVfRnmXSk8RA= X-MC-Unique: sLwKngzdOfK9AfGUnNkFFg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v3 3/7] nodedev: Add tests for mdevctl autostart command Date: Fri, 20 Aug 2021 17:29:31 -0500 Message-Id: <20210820222935.3414029-4-jjongsma@redhat.com> In-Reply-To: <20210820222935.3414029-1-jjongsma@redhat.com> References: <20210820222935.3414029-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.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629498919964100001 Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 --- .../nodedevmdevctldata/mdevctl-autostart.argv | 8 +++ tests/nodedevmdevctltest.c | 55 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/nodedevmdevctldata/mdevctl-autostart.argv diff --git a/tests/nodedevmdevctldata/mdevctl-autostart.argv b/tests/nodede= vmdevctldata/mdevctl-autostart.argv new file mode 100644 index 0000000000..9b441e9466 --- /dev/null +++ b/tests/nodedevmdevctldata/mdevctl-autostart.argv @@ -0,0 +1,8 @@ +mdevctl \ +modify \ +--uuid d069d019-36ea-4111-8f0a-8c9a70e21366 \ +--auto +mdevctl \ +modify \ +--uuid d069d019-36ea-4111-8f0a-8c9a70e21366 \ +--manual diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 3d1a7e4b6c..92d3c75766 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -124,6 +124,56 @@ testMdevctlHelper(const void *data) } =20 =20 +static int +testMdevctlAutostart(const void *data G_GNUC_UNUSED) +{ + g_autoptr(virNodeDeviceDef) def =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + const char *actualCmdline =3D NULL; + int ret =3D -1; + g_autoptr(virCommand) enablecmd =3D NULL; + g_autoptr(virCommand) disablecmd =3D NULL; + g_autofree char *errmsg =3D NULL; + /* just concatenate both calls into the same output file */ + g_autofree char *cmdlinefile =3D + g_strdup_printf("%s/nodedevmdevctldata/mdevctl-autostart.argv", + abs_srcdir); + g_autofree char *mdevxml =3D + g_strdup_printf("%s/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a= _8c9a70e21366.xml", + abs_srcdir); + g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + + if (!(def =3D virNodeDeviceDefParseFile(mdevxml, CREATE_DEVICE, VIRT_T= YPE, + &parser_callbacks, NULL))) + return -1; + + virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); + + if (!(enablecmd =3D nodeDeviceGetMdevctlSetAutostartCommand(def, true,= &errmsg))) + goto cleanup; + + if (virCommandRun(enablecmd, NULL) < 0) + goto cleanup; + + if (!(disablecmd =3D nodeDeviceGetMdevctlSetAutostartCommand(def, fals= e, &errmsg))) + goto cleanup; + + if (virCommandRun(disablecmd, NULL) < 0) + goto cleanup; + + if (!(actualCmdline =3D virBufferCurrentContent(&buf))) + goto cleanup; + + if (virTestCompareToFileFull(actualCmdline, cmdlinefile, false) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virBufferFreeAndReset(&buf); + return ret; +} + static int testMdevctlListDefined(const void *data G_GNUC_UNUSED) { @@ -378,6 +428,9 @@ mymain(void) #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("list defined mdevs", testMdevctlListDefined, NULL) =20 +#define DO_TEST_AUTOSTART() \ + DO_TEST_FULL("autostart mdevs", testMdevctlAutostart, NULL) + #define DO_TEST_PARSE_JSON(filename) \ DO_TEST_FULL("parse mdevctl json " filename, testMdevctlParse, filenam= e) =20 @@ -401,6 +454,8 @@ mymain(void) =20 DO_TEST_START("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 + DO_TEST_AUTOSTART(); + done: nodedevTestDriverFree(driver); =20 --=20 2.31.1