From: Andrew Jones <andrew.jones@linux.dev>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com,
frankja@linux.ibm.com, imbrenda@linux.ibm.com,
nrb@linux.ibm.com, david@redhat.com, pbonzini@redhat.com,
kvm@vger.kernel.org, kvmarm@lists.linux.dev,
linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org,
linux-s390@vger.kernel.org, will@kernel.org,
julien.thierry.kdev@gmail.com, maz@kernel.org,
oliver.upton@linux.dev, suzuki.poulose@arm.com,
yuzenghui@huawei.com, joey.gouly@arm.com,
andre.przywara@arm.com
Subject: Re: [kvm-unit-tests PATCH v2 17/18] unittest: Add disabled_if parameter and use it for kvmtool
Date: Thu, 23 Jan 2025 17:08:54 +0100 [thread overview]
Message-ID: <20250123-3eda2c10fdce584bdfb14971@orel> (raw)
In-Reply-To: <20250120164316.31473-18-alexandru.elisei@arm.com>
On Mon, Jan 20, 2025 at 04:43:15PM +0000, Alexandru Elisei wrote:
> The pci-test is qemu specific. Other tests perform migration, which
> isn't supported by kvmtool. In general, kvmtool is not as feature-rich
> as qemu, so add a new unittest parameter, disabled_if, that causes a
> test to be skipped if the condition evaluates to true.
>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
> arm/unittests.cfg | 7 +++++++
> docs/unittests.txt | 13 +++++++++++++
> scripts/common.bash | 8 ++++++--
> scripts/runtime.bash | 6 ++++++
> 4 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/arm/unittests.cfg b/arm/unittests.cfg
> index 974a5a9e4113..9b1df5e02a58 100644
> --- a/arm/unittests.cfg
> +++ b/arm/unittests.cfg
> @@ -44,6 +44,7 @@ groups = selftest
> # Test PCI emulation
> [pci-test]
> file = pci-test.flat
> +disabled_if = [[ "$TARGET" != qemu ]]
> groups = pci
>
> # Test PMU support
> @@ -208,6 +209,7 @@ file = gic.flat
> smp = $MAX_SMP
> extra_params = -machine gic-version=3 -append 'its-migration'
> groups = its migration
> +disabled_if = [[ "$TARGET" != qemu ]]
> arch = arm64
>
> [its-pending-migration]
> @@ -215,6 +217,7 @@ file = gic.flat
> smp = $MAX_SMP
> extra_params = -machine gic-version=3 -append 'its-pending-migration'
> groups = its migration
> +disabled_if = [[ "$TARGET" != qemu ]]
> arch = arm64
>
> [its-migrate-unmapped-collection]
> @@ -222,6 +225,7 @@ file = gic.flat
> smp = $MAX_SMP
> extra_params = -machine gic-version=3 -append 'its-migrate-unmapped-collection'
> groups = its migration
> +disabled_if = [[ "$TARGET" != qemu ]]
> arch = arm64
>
> # Test PSCI emulation
> @@ -263,6 +267,7 @@ groups = debug
> file = debug.flat
> arch = arm64
> extra_params = -append 'bp-migration'
> +disabled_if = [[ "$TARGET" != qemu ]]
> groups = debug migration
>
> [debug-wp]
> @@ -276,6 +281,7 @@ groups = debug
> file = debug.flat
> arch = arm64
> extra_params = -append 'wp-migration'
> +disabled_if = [[ "$TARGET" != qemu ]]
> groups = debug migration
>
> [debug-sstep]
> @@ -289,6 +295,7 @@ groups = debug
> file = debug.flat
> arch = arm64
> extra_params = -append 'ss-migration'
> +disabled_if = [[ "$TARGET" != qemu ]]
> groups = debug migration
>
> # FPU/SIMD test
> diff --git a/docs/unittests.txt b/docs/unittests.txt
> index ebb6994cab77..58d1a29146a3 100644
> --- a/docs/unittests.txt
> +++ b/docs/unittests.txt
> @@ -115,3 +115,16 @@ parameter needs to be of the form <path>=<value>
> The path and value cannot contain space, =, or shell wildcard characters.
>
> Can be overwritten with the CHECK environment variable with the same syntax.
> +
> +disabled_if
> +------
> +disabled_if = <condition>
> +
> +Do not run the test if <condition> is met. <condition> will be fed unmodified
> +to a bash 'if' statement and follows the same syntax.
> +
> +This can be used to prevent running a test when kvm-unit-tests is configured a
> +certain way. For example, it can be used to skip a qemu specific test when
> +using another VMM and using UEFI:
> +
> +disabled_if = [[ "$TARGET" != qemu ]] && [[ "$CONFIG_EFI" = y ]]
> diff --git a/scripts/common.bash b/scripts/common.bash
> index f54ffbd7a87b..c0ea2eabeda6 100644
> --- a/scripts/common.bash
> +++ b/scripts/common.bash
> @@ -38,6 +38,7 @@ function for_each_unittest()
> local accel
> local timeout
> local kvmtool_opts
> + local disabled_cond
> local rematch
>
> exec {fd}<"$unittests"
> @@ -46,7 +47,7 @@ function for_each_unittest()
> if [[ "$line" =~ ^\[(.*)\]$ ]]; then
> rematch=${BASH_REMATCH[1]}
> if [ -n "${testname}" ]; then
> - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts"
> + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" "$disabled_cond"
> fi
> testname=$rematch
> smp=1
> @@ -59,6 +60,7 @@ function for_each_unittest()
> accel=""
> timeout=""
> kvmtool_opts=""
> + disabled_cond=""
> elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
> kernel=$TEST_DIR/${BASH_REMATCH[1]}
> elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
> @@ -79,6 +81,8 @@ function for_each_unittest()
> machine=${BASH_REMATCH[1]}
> elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
> check=${BASH_REMATCH[1]}
> + elif [[ $line =~ ^disabled_if\ *=\ *(.*)$ ]]; then
> + disabled_cond=${BASH_REMATCH[1]}
> elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then
> accel=${BASH_REMATCH[1]}
> elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then
> @@ -86,7 +90,7 @@ function for_each_unittest()
> fi
> done
> if [ -n "${testname}" ]; then
> - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts"
> + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$qemu_opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$kvmtool_opts" "$disabled_cond"
> fi
> exec {fd}<&-
> }
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index abfd1e67b2ef..002bd2744d6b 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -108,6 +108,7 @@ function run()
> local accel="$9"
> local timeout="${10:-$TIMEOUT}" # unittests.cfg overrides the default
> local kvmtool_opts="${11}"
> + local disabled_cond="${12}"
>
> case "$TARGET" in
> qemu)
> @@ -186,6 +187,11 @@ function run()
> done
> fi
>
> + if [[ "$disabled_cond" ]] && (eval $disabled_cond); then
> + print_result "SKIP" $testname "" "disabled because: $disabled_cond"
> + return 2
> + fi
> +
> log=$(premature_failure) && {
> skip=true
> if [ "${CONFIG_EFI}" == "y" ]; then
> --
> 2.47.1
>
I like disabled_if because I like the lambda-like thing it's doing, but I
wonder if it wouldn't be better to make TARGET a first class citizen by
adding a 'targets' unittest parameter which allows listing all targets the
test can run on, e.g.
[selftest-setup]
file = selftest.flat
smp = 2
extra_params = -m 256 -append 'setup smp=2 mem=256'
targets = qemu,kvmtool
groups = selftest
[pci-test]
file = pci-test.flat
targets = qemu
groups = pci
If targets isn't present then the default is only qemu.
Thanks,
drew
next prev parent reply other threads:[~2025-01-23 16:09 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 16:42 [kvm-unit-tests PATCH v2 00/18] arm/arm64: Add kvmtool to the runner script Alexandru Elisei
2025-01-20 16:42 ` [kvm-unit-tests PATCH v2 01/18] run_tests: Document --probe-maxsmp argument Alexandru Elisei
2025-01-21 14:41 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 02/18] Document environment variables Alexandru Elisei
2025-01-21 14:41 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 03/18] scripts: Refuse to run the tests if not configured for qemu Alexandru Elisei
2025-01-21 14:48 ` Andrew Jones
2025-01-21 15:54 ` Alexandru Elisei
2025-01-21 16:17 ` Andrew Jones
2025-01-21 16:20 ` Alexandru Elisei
2025-02-10 10:41 ` Alexandru Elisei
2025-02-10 13:56 ` Andrew Jones
2025-02-10 18:04 ` Alexandru Elisei
2025-02-17 16:02 ` Al Dunsmuir
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 04/18] run_tests: Introduce unittest parameter 'qemu_params' Alexandru Elisei
2025-01-21 15:46 ` Andrew Jones
2025-02-12 13:40 ` Alexandru Elisei
2025-02-12 15:48 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 05/18] scripts: Rename run_qemu_status -> run_test_status Alexandru Elisei
2025-01-21 15:55 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 06/18] scripts: Merge the qemu parameter -smp into $qemu_opts Alexandru Elisei
2025-01-21 16:12 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 07/18] scripts: Introduce kvmtool_opts Alexandru Elisei
2025-01-21 16:24 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 08/18] scripts/runtime: Detect kvmtool failure in premature_failure() Alexandru Elisei
2025-01-21 16:29 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 09/18] scripts/runtime: Skip test when kvmtool and $accel is not KVM Alexandru Elisei
2025-01-21 16:30 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 10/18] scripts/arch-run: Add support for kvmtool Alexandru Elisei
2025-01-21 16:46 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 11/18] arm/run: " Alexandru Elisei
2025-01-21 16:50 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 12/18] scripts/runtime: Add default arguments " Alexandru Elisei
2025-01-23 14:07 ` Andrew Jones
2025-01-23 14:20 ` Alexandru Elisei
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 13/18] run_tests: Do not probe for maximum number of VCPUs when using kvmtool Alexandru Elisei
2025-01-23 15:36 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 14/18] run_tests: Add KVMTOOL environment variable for kvmtool binary path Alexandru Elisei
2025-01-23 15:43 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 15/18] Add kvmtool_params to test specification Alexandru Elisei
2025-01-23 15:53 ` Andrew Jones
2025-02-11 15:03 ` Alexandru Elisei
2025-02-12 15:56 ` Andrew Jones
2025-02-12 16:34 ` Alexandru Elisei
2025-02-13 13:59 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 16/18] scripts/mkstandalone: Export $TARGET Alexandru Elisei
2025-01-23 15:53 ` Andrew Jones
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 17/18] unittest: Add disabled_if parameter and use it for kvmtool Alexandru Elisei
2025-01-23 16:08 ` Andrew Jones [this message]
2025-01-20 16:43 ` [kvm-unit-tests PATCH v2 18/18] run_tests: Enable kvmtool Alexandru Elisei
2025-01-23 16:12 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250123-3eda2c10fdce584bdfb14971@orel \
--to=andrew.jones@linux.dev \
--cc=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=david@redhat.com \
--cc=eric.auger@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=joey.gouly@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lvivier@redhat.com \
--cc=maz@kernel.org \
--cc=nrb@linux.ibm.com \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=suzuki.poulose@arm.com \
--cc=thuth@redhat.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).