From nobody Mon Feb 9 20:36:32 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1711195855222202.37466873501853; Sat, 23 Mar 2024 05:10:55 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0650B2148; Sat, 23 Mar 2024 08:10:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 63FE721A0; Sat, 23 Mar 2024 07:40:40 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 65B5E1D2D; Sat, 23 Mar 2024 07:40:33 -0400 (EDT) Received: from mx1.osci.io (polly.osci.io [8.43.85.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4C8611D82 for ; Sat, 23 Mar 2024 07:32:55 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 7829A223E3; Fri, 22 Mar 2024 13:56:47 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by mx1.osci.io (Postfix) with ESMTPS id 78546223E3 for ; Fri, 22 Mar 2024 13:56:46 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-Y0M0yIXiOTuje2HJYbZ4bg-1; Fri, 22 Mar 2024 13:56:43 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7EE0D3C0D7B6 for ; Fri, 22 Mar 2024 17:56:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA956492BDA for ; Fri, 22 Mar 2024 17:56:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: Y0M0yIXiOTuje2HJYbZ4bg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 25/35] virshtest: Adapt 'virsh-start' and 'virsh-undefine' tests as 'lifecycle' case Date: Fri, 22 Mar 2024 18:56:03 +0100 Message-ID: <71e52c159d09de1e3b54ea8c0e7b3541108b3ff3.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BXMQSWBB74LW4ORR43SVGA42TD2OFH5A X-Message-ID-Hash: BXMQSWBB74LW4ORR43SVGA42TD2OFH5A X-MailFrom: SRS0=Xa5W=K4=redhat.com=pkrempa@osci.io X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1711195856070100001 The 'virsh-start' case simply tried to start an already running VM. This can be easily tested together with the tests for undefining a VM. For this test the test driver config with multiple VMs comes handy as we need to test 3 situations when we undefine and stop the VM. Signed-off-by: Peter Krempa --- tests/meson.build | 2 - tests/virsh-start | 41 ------------ tests/virsh-undefine | 76 --------------------- tests/virshtest.c | 1 + tests/virshtestdata/lifecycle.in | 23 +++++++ tests/virshtestdata/lifecycle.out | 106 ++++++++++++++++++++++++++++++ 6 files changed, 130 insertions(+), 119 deletions(-) delete mode 100755 tests/virsh-start delete mode 100755 tests/virsh-undefine create mode 100644 tests/virshtestdata/lifecycle.in create mode 100644 tests/virshtestdata/lifecycle.out diff --git a/tests/meson.build b/tests/meson.build index 8392778a76..5a2a499461 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -696,8 +696,6 @@ if conf.has('WITH_LIBVIRTD') 'virsh-read-non-seekable', 'virsh-self-test', 'virsh-snapshot', - 'virsh-start', - 'virsh-undefine', 'virsh-uriprecedence', 'virt-admin-self-test', ] diff --git a/tests/virsh-start b/tests/virsh-start deleted file mode 100755 index cb58c3b09c..0000000000 --- a/tests/virsh-start +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# ensure that virsh start works properly - -# Copyright (C) 2008 Red Hat, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see -# . - -. "$(dirname $0)/test-lib.sh" - -if test "$VERBOSE" =3D yes; then - set -x - $abs_top_builddir/tools/virsh --version -fi - -fail=3D0 - -test_url=3Dtest:///default - -# expect this to fail -$abs_top_builddir/tools/virsh -c $test_url start test > out 2> err && fail= =3D1 - -# stdout gets a newline -echo > exp || fail=3D1 -compare exp out || fail=3D1 - -echo 'error: Domain is already active' > exp || fail=3D1 -compare exp err || fail=3D1 - -(exit $fail); exit $fail diff --git a/tests/virsh-undefine b/tests/virsh-undefine deleted file mode 100755 index dbbb367391..0000000000 --- a/tests/virsh-undefine +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -# exercise virsh's "undefine" command - -# Copyright (C) 2008-2009, 2011 Red Hat, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see -# . - -. "$(dirname $0)/test-lib.sh" - -if test "$VERBOSE" =3D yes; then - set -x - $abs_top_builddir/tools/virsh --version -fi - -fail=3D0 - -# Attempt to undefine a running domain, by domain name. Every time a new -# connection is opened to the test driver, it starts life with a new -# persistent running domain named 'test' with a different uuid, so -# testing this command requires batch mode use of virsh. -$abs_top_builddir/tools/virsh -c test:///default \ - 'dominfo test; undefine test; dominfo test' > out1 2>&1 -test $? =3D 0 || fail=3D1 -sed '/^Persistent/n; /:/d' < out1 > out -cat <<\EOF > exp || fail=3D1 -Persistent: yes - -Domain 'test' has been undefined - -Persistent: no - -EOF -compare exp out || fail=3D1 - -# A similar diagnostic when specifying a domain ID -$abs_top_builddir/tools/virsh -c test:///default \ - 'dominfo 1; undefine 1; dominfo 1' > out1 2>&1 -test $? =3D 0 || fail=3D1 -sed '/^Persistent/n; /:/d' < out1 > out -cat <<\EOF > exp || fail=3D1 -Persistent: yes - -Domain '1' has been undefined - -Persistent: no - -EOF -compare exp out || fail=3D1 - -# Succeed, now: first shut down, then undefine, both via name. -$abs_top_builddir/tools/virsh -c test:///default \ - 'shutdown test; undefine test; dominfo test' > out 2>&1 -test $? =3D 1 || fail=3D1 -cat <<\EOF > expout || fail=3D1 -Domain 'test' is being shutdown - -Domain 'test' has been undefined - -error: failed to get domain 'test' - -EOF -compare expout out || fail=3D1 - -(exit $fail); exit $fail diff --git a/tests/virshtest.c b/tests/virshtest.c index f4c41fca46..9cad18cf58 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -213,6 +213,7 @@ mymain(void) DO_TEST_SCRIPT_FULL("numeric-parsing-event", true, NULL, VIRSH_DEFAULT= , "-q"); DO_TEST_SCRIPT("attach-disk", NULL, VIRSH_DEFAULT); DO_TEST_SCRIPT("vcpupin", NULL, VIRSH_DEFAULT); + DO_TEST_SCRIPT("lifecycle", "\nCPU time:", VIRSH_CUSTOM); DO_TEST_FULL("domain-id-overflow", NULL, VIRSH_CUSTOM, "-q", "domname"= , "4294967298"); DO_TEST_FULL("schedinfo-invalid-argument", NULL, VIRSH_DEFAULT, "sched= info", "1", "--set", "j=3Dk"); diff --git a/tests/virshtestdata/lifecycle.in b/tests/virshtestdata/lifecyc= le.in new file mode 100644 index 0000000000..e585ad08e1 --- /dev/null +++ b/tests/virshtestdata/lifecycle.in @@ -0,0 +1,23 @@ +list --all + +echo test failure when starting already running guest +start fv0 + +echo undefine a running domain - by domain name +dominfo fc4 +undefine fc4 +dominfo fc4 +shutdown fc4 +dominfo fc4 + +echo undefine a running domain - by domain id +dominfo 3 +undefine 3 +dominfo 3 +shutdown 3 +dominfo fc5 + +echo shutdown then undefine +shutdown fv0 +undefine fv0 +dominfo fv0 diff --git a/tests/virshtestdata/lifecycle.out b/tests/virshtestdata/lifecy= cle.out new file mode 100644 index 0000000000..1d87cb44f6 --- /dev/null +++ b/tests/virshtestdata/lifecycle.out @@ -0,0 +1,106 @@ + Id Name State +---------------------- + 1 fv0 running + 2 fc4 running + 3 fc5 running + +test failure when starting already running guest +error: Domain is already active + +undefine a running domain - by domain name +Id: 2 +Name: fc4 +UUID: ef861801-45b9-11cb-88e3-afbfe5370493 +OS Type: linux +State: running +CPU(s): 1 +Max memory: 261072 KiB +Used memory: 131072 KiB +Persistent: yes +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: network configuration using opaque shell scripts + +Domain 'fc4' has been undefined + +Id: 2 +Name: fc4 +UUID: ef861801-45b9-11cb-88e3-afbfe5370493 +OS Type: linux +State: running +CPU(s): 1 +Max memory: 261072 KiB +Used memory: 131072 KiB +Persistent: no +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: network configuration using opaque shell scripts + +Domain 'fc4' is being shutdown + +error: failed to get domain 'fc4' + +undefine a running domain - by domain id +Id: 3 +Name: fc5 +UUID: 08721f99-3d1d-4aec-96eb-97803297bb36 +OS Type: linux +State: running +CPU(s): 4 +Max memory: 2097152 KiB +Used memory: 2097152 KiB +Persistent: yes +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: running with undesirable elevated privileges + tainted: network configuration using opaque shell scripts + tainted: use of host cdrom passthrough + tainted: custom device tree blob used + tainted: use of deprecated configuration settings + deprecated configuration: CPU model Deprecated-Test + +Domain '3' has been undefined + +Id: 3 +Name: fc5 +UUID: 08721f99-3d1d-4aec-96eb-97803297bb36 +OS Type: linux +State: running +CPU(s): 4 +Max memory: 2097152 KiB +Used memory: 2097152 KiB +Persistent: no +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: running with undesirable elevated privileges + tainted: network configuration using opaque shell scripts + tainted: use of host cdrom passthrough + tainted: custom device tree blob used + tainted: use of deprecated configuration settings + deprecated configuration: CPU model Deprecated-Test + +Domain '3' is being shutdown + +error: failed to get domain 'fc5' + +shutdown then undefine +Domain 'fv0' is being shutdown + +Domain 'fv0' has been undefined + +error: failed to get domain 'fv0' + + +## Exit code: 1 --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org