All instances of disabled_if are used to prevent the test from running with kvmtool. Make that explicit, just making target. Signed-off-by: Paolo Bonzini --- arm/unittests.cfg | 14 +++++++------- docs/unittests.txt | 16 +++++----------- scripts/common.bash | 12 ++++++------ scripts/runtime.bash | 8 ++++---- scripts/s390x/func.bash | 5 +++-- 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 12fc4468..df6f6d4e 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -43,7 +43,7 @@ groups = selftest [pci-test] file = pci-test.flat groups = pci -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu # Test PMU support [pmu-cycle-counter] @@ -220,7 +220,7 @@ test_args = its-migration qemu_params = -machine gic-version=3 kvmtool_params = --irqchip=gicv3 groups = its migration -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu arch = arm64 [its-pending-migration] @@ -230,7 +230,7 @@ test_args = its-pending-migration qemu_params = -machine gic-version=3 kvmtool_params = --irqchip=gicv3 groups = its migration -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu arch = arm64 [its-migrate-unmapped-collection] @@ -240,7 +240,7 @@ test_args = its-migrate-unmapped-collection qemu_params = -machine gic-version=3 kvmtool_params = --irqchip=gicv3 groups = its migration -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu arch = arm64 # Test PSCI emulation @@ -282,7 +282,7 @@ file = debug.flat arch = arm64 test_args = bp-migration groups = debug migration -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu [debug-wp] file = debug.flat @@ -295,7 +295,7 @@ file = debug.flat arch = arm64 test_args = wp-migration groups = debug migration -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu [debug-sstep] file = debug.flat @@ -308,7 +308,7 @@ file = debug.flat arch = arm64 test_args = ss-migration groups = debug migration -disabled_if = [[ "$TARGET" != qemu ]] +target = qemu # FPU/SIMD test [fpu-context] diff --git a/docs/unittests.txt b/docs/unittests.txt index 921318a6..fa0eb03d 100644 --- a/docs/unittests.txt +++ b/docs/unittests.txt @@ -125,15 +125,9 @@ 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 = +target +------ +target = ... -Do not run the test if is met. 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 ]] +Restrict the test to the listed VMM targets, such as `qemu` or `kvmtool`. +By default, the test can run with either target. diff --git a/scripts/common.bash b/scripts/common.bash index 47c45660..0f8ae5d6 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -16,7 +16,7 @@ function for_each_unittest() local check local accel local timeout - local disabled_if + local test_target local rematch local raw local current @@ -50,7 +50,7 @@ function for_each_unittest() if [[ "$line" =~ ^\[(.*)\]$ ]]; then rematch=${BASH_REMATCH[1]} if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$disabled_if" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$test_target" fi testname=$rematch smp="$(vmm_optname_nr_cpus) 1" @@ -67,7 +67,7 @@ function for_each_unittest() check="" accel="" timeout="" - disabled_if="" + test_target="" continue fi @@ -97,8 +97,8 @@ function for_each_unittest() elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then current=check value=${BASH_REMATCH[1]} - elif [[ $line =~ ^disabled_if\ *=\ *(.*)$ ]]; then - current=disabled_if + elif [[ $line =~ ^target\ *=\ *(.*)$ ]]; then + current=test_target value=${BASH_REMATCH[1]} elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then current=accel @@ -114,7 +114,7 @@ function for_each_unittest() [ -n "$current" ] && eval "$current=\$value" done if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$test_target" fi exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index bf5e2125..67518ca3 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -82,7 +82,7 @@ function run() local check="${CHECK:-$9}" local accel="${10}" local timeout="${TIMEOUT:-${11:-90s}}" # TIMEOUT env var overrides unittests.cfg - local disabled_if="${12}" + local test_target="${12}" if [ "${CONFIG_EFI}" == "y" ]; then kernel=${kernel/%.flat/.efi} @@ -130,9 +130,9 @@ function run() accel="$ACCEL" fi - if [[ "$disabled_if" ]] && (eval $disabled_if); then - print_result "SKIP" $testname "" "disabled because: $disabled_if" - return 2 + if [ -n "$test_target" ] && ! find_word "$(vmm_get_target)" "$test_target"; then + print_result "SKIP" $testname "" "$test_target only, but TARGET=$(vmm_get_target)" + return 2 fi # check a file for a particular value before running a test diff --git a/scripts/s390x/func.bash b/scripts/s390x/func.bash index 28c3a70c..d5e132ef 100644 --- a/scripts/s390x/func.bash +++ b/scripts/s390x/func.bash @@ -18,9 +18,10 @@ function arch_cmd_s390x() local check=${10} local accel=${11} local timeout=${12} + local test_target=${13} # run the normal test case - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$test_target" # run PV test case if [ "$accel" = 'tcg' ] || grep -q "migration" <<< "$groups"; then @@ -36,5 +37,5 @@ function arch_cmd_s390x() print_result 'SKIP' $testname '' 'PVM image was not created' return 2 fi - "$cmd" "$testname" "$groups pv" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" + "$cmd" "$testname" "$groups pv" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" "$test_target" } -- 2.56.1