On Wed, Oct 26, 2022, Po-Hsu Lin wrote: > This test can take about 7 minutes to run on VM.DenseIO2.8 instance > from Oracle cloud with Ubuntu Oracle cloud kernel (CONFIG_DEBUG_VM > was not enabled): > * Ubuntu Focal 5.4 Oracle kernel: 6m42s / 6m46s / 6m42s > * Ubuntu Jammy 5.15 Oracle kernel: 6m26s / 6m27s / 6m26s > > Bump the timeout for this test again to 10 minutes. This test isn't all that interesting for a doubly-nested scenario, i.e. those 6+ minutes are almost always going to be a waste of time. Rather than bumping the timeout, what about skipping the the test by default if KVM-unit-tests detects that it's running in a VM? (I apologize for my horrific bash skills) --- scripts/common.bash | 8 ++++++-- scripts/runtime.bash | 23 +++++++++++++++++++++-- scripts/s390x/func.bash | 9 +++++---- x86/unittests.cfg | 1 + 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/scripts/common.bash b/scripts/common.bash index 7b983f7d..88738e39 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -11,6 +11,7 @@ function for_each_unittest() local groups local arch local check + local grep local accel local timeout local rematch @@ -21,7 +22,7 @@ function for_each_unittest() if [[ "$line" =~ ^\[(.*)\]$ ]]; then rematch=${BASH_REMATCH[1]} if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$grep" "$accel" "$timeout" fi testname=$rematch smp=1 @@ -30,6 +31,7 @@ function for_each_unittest() groups="" arch="" check="" + grep="" accel="" timeout="" elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then @@ -44,6 +46,8 @@ function for_each_unittest() arch=${BASH_REMATCH[1]} elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then check=${BASH_REMATCH[1]} + elif [[ $line =~ ^grep\ *=\ *(.*)$ ]]; then + grep=${BASH_REMATCH[1]} elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then accel=${BASH_REMATCH[1]} elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then @@ -51,7 +55,7 @@ function for_each_unittest() fi done if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$grep" "$accel" "$timeout" fi exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index f8794e9a..ca502eab 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -79,8 +79,9 @@ function run() local opts="$5" local arch="$6" local check="${CHECK:-$7}" - local accel="$8" - local timeout="${9:-$TIMEOUT}" # unittests.cfg overrides the default + local grep="$8" + local accel="$9" + local timeout="${10:-$TIMEOUT}" # unittests.cfg overrides the default if [ "${CONFIG_EFI}" == "y" ]; then kernel=$(basename $kernel .flat) @@ -130,6 +131,24 @@ function run() done fi + if [ "$grep" ]; then + for grep_param in "${grep[@]}"; do + search=${grep_param%%,*} + path=${grep_param#*,} + path=${path%%=*} + value=${grep_param#*=} + if [ ! -f "$path" ]; then + continue + fi + + grep -q $search $path + if [ $([ $? -ne 0 ] && echo "N" || echo "Y") != "$value" ]; then + print_result "SKIP" $testname "" "grep $search $path != $value" + return 2 + fi + done + fi + last_line=$(premature_failure > >(tail -1)) && { skip=true if [ "${CONFIG_EFI}" == "y" ] && [[ "${last_line}" =~ "Dummy Hello World!" ]]; then diff --git a/scripts/s390x/func.bash b/scripts/s390x/func.bash index 2a941bbb..c9ebe34d 100644 --- a/scripts/s390x/func.bash +++ b/scripts/s390x/func.bash @@ -14,11 +14,12 @@ function arch_cmd_s390x() local opts=$6 local arch=$7 local check=$8 - local accel=$9 - local timeout=${10} + local grep=$9 + local accel=$10 + local timeout=${11} # run the normal test case - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$grep" "$accel" "$timeout" # run PV test case if [ "$ACCEL" = 'tcg' ] || find_word "migration" "$groups"; then @@ -34,5 +35,5 @@ function arch_cmd_s390x() print_result 'SKIP' $testname '' 'PVM image was not created' return 2 fi - "$cmd" "$testname" "$groups pv" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + "$cmd" "$testname" "$groups pv" "$smp" "$kernel" "$opts" "$arch" "$check" "$grep" "$accel" "$timeout" } diff --git a/x86/unittests.cfg b/x86/unittests.cfg index ed651850..99ba52a8 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -374,6 +374,7 @@ extra_params = -cpu max,+vmx -append vmx_vmcs_shadow_test arch = x86_64 groups = vmx timeout = 180 +grep = hypervisor,/proc/cpuinfo=N [vmx_pf_exception_test] file = vmx.flat base-commit: 5bf99cb38621d44b0a7d2204ecd9326b3209ab73 --