From nobody Mon Feb 9 17:58:28 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=1622751135; cv=none; d=zohomail.com; s=zohoarc; b=h/8xDZC9xR8EhGxNgyu52cJQBEzVQuw6Ofi2QoEwB4cnjyh9F9tOMKZBkV9WQW/euCUnGjRy9EDZTheRC7dH8JybSCoY4Y1ouNZ/lJfY6syeB3HIRrCemkbV8QUmT85woE+vgJgVNFDvnZxuhKMq9ovxjZhpZLfGWtXaAdgs2FY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622751135; 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=YMCZftYmR7hboq71RLMl61vzQGWM/lkAwmCCd/z9T3g=; b=WDccyiNP5fq6GQzebJXOWxdMZj7xomlO7p3+lzgTipbFYrhL8VGWiv3qcqmAT5itDSlSipzzWel8eyxPcrG/OJjDGwRHEBMliUDw7IidfkSah6W31Ox7GUWmEwS6ZhiviPY/A9hyuOMS1XiRVuNulRgosjCDiTfyv41+oOF7uAo= 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 1622751135953518.1467398796457; Thu, 3 Jun 2021 13:12:15 -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-280-5yKSEZ71O5mtAPdO1ViSAQ-1; Thu, 03 Jun 2021 16:12:13 -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 F02148189C3; Thu, 3 Jun 2021 20:12:06 +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 3B9915D6AB; Thu, 3 Jun 2021 20:12:06 +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 BC0191801264; Thu, 3 Jun 2021 20:12:02 +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 153KC10W000738 for ; Thu, 3 Jun 2021 16:12:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F55919D7D; Thu, 3 Jun 2021 20:12:01 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-235.phx2.redhat.com [10.3.114.235]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4082019C44 for ; Thu, 3 Jun 2021 20:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622751135; 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=YMCZftYmR7hboq71RLMl61vzQGWM/lkAwmCCd/z9T3g=; b=LhJPFfxGRGDWL0a+5QXEGK9GpM23xq6Ch6NCzzM5SJpi3GJwTAST/DT0aSeBd7iBEWcHSn qHNMFeY6I9jYf6naE7F7WD62kvslq+jlWiv/0qFjQLzhOS45MHbhPiTbt6HIzHYIuC7Hm6 JVqXz3kqHQp1zDr1ZdKrH3WGTpbZG+I= X-MC-Unique: 5yKSEZ71O5mtAPdO1ViSAQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 3/7] nodedev: Add tests for mdevctl autostart command Date: Thu, 3 Jun 2021 15:11:52 -0500 Message-Id: <20210603201156.3571972-4-jjongsma@redhat.com> In-Reply-To: <20210603201156.3571972-1-jjongsma@redhat.com> References: <20210603201156.3571972-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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 --- .../nodedevmdevctldata/mdevctl-autostart.argv | 8 +++ tests/nodedevmdevctltest.c | 54 +++++++++++++++++++ 2 files changed, 62 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 8ba1d2da70..3f9d4c84b9 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -118,6 +118,55 @@ 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))) + 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) { @@ -348,6 +397,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 @@ -370,6 +422,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