Also remove useless qemu variable in scripts/runtime.bash. Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> Reviewed-by: Radim Krčmář <rkrcmar@xxxxxxxxxx> --- arm/run | 1 + arm/unittests.cfg | 1 + scripts/arch-run.bash | 8 ++++++++ scripts/functions.bash | 8 ++++++-- scripts/runtime.bash | 10 ++++++---- x86/run | 1 + x86/unittests.cfg | 1 + 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/arm/run b/arm/run index c9463de6dd241..4b9aeb3665436 100755 --- a/arm/run +++ b/arm/run @@ -70,6 +70,7 @@ chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd' M+=",accel=$ACCEL" command="$qemu $M -cpu $processor $chr_testdev" command+=" -display none -serial stdio -kernel" +command="$(timeout_cmd) $command" echo $command "$@" exit_fixup $command "$@" diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 926bbb153728b..8c6c475f050fc 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -15,6 +15,7 @@ # accel = kvm|tcg # Optionally specify if test must run with # # kvm or tcg. If not specified, then kvm will # # be used when available. +# timeout = <duration> # Optionally specify a timeout. ############################################################################## # diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 3a63ed179a7de..28a33f41b6ede 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -19,6 +19,7 @@ # 1 - most likely QEMU failed # 2 - most likely a run script failed # 3 - most likely the unittest failed +# 124 - most likely the unittest timed out # 127 - most likely the unittest called abort() # 1..127 - FAILURE (could be QEMU, a run script, or the unittest) # >= 128 - Signal (signum = status - 128) @@ -59,3 +60,10 @@ exit_fixup () return $ret } + +timeout_cmd () +{ + if [ "$TIMEOUT" ] && [ "$TIMEOUT" != "0" ]; then + echo "timeout -k 1s --foreground $TIMEOUT" + fi +} diff --git a/scripts/functions.bash b/scripts/functions.bash index f13fe6f88f23d..ee9143c5d630d 100644 --- a/scripts/functions.bash +++ b/scripts/functions.bash @@ -11,12 +11,13 @@ function for_each_unittest() local arch local check local accel + local timeout exec {fd}<"$unittests" while read -u $fd line; do if [[ "$line" =~ ^\[(.*)\]$ ]]; then - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" testname=${BASH_REMATCH[1]} smp=1 kernel="" @@ -25,6 +26,7 @@ function for_each_unittest() arch="" check="" accel="" + timeout="" elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then kernel=$TEST_DIR/${BASH_REMATCH[1]} elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then @@ -39,8 +41,10 @@ function for_each_unittest() check=${BASH_REMATCH[1]} elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then accel=${BASH_REMATCH[1]} + elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then + timeout=${BASH_REMATCH[1]} fi done - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 1ac57ccdfc614..0e055f0dddc2c 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -1,6 +1,6 @@ : "${RUNTIME_arch_run?}" - -qemu=${QEMU:-qemu-system-$ARCH} +: ${MAX_SMP:=$(getconf _NPROCESSORS_CONF)} +: ${TIMEOUT:=90s} function run() { @@ -12,6 +12,7 @@ function run() local arch="$6" local check="${CHECK:-$7}" local accel="${ACCEL:-$8}" + local timeout="${9:-$TIMEOUT}" # unittests.cfg overrides the default if [ -z "$testname" ]; then return @@ -38,7 +39,7 @@ function run() fi done - cmdline="TESTNAME=$testname ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" + cmdline="TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" if [ "$verbose" = "yes" ]; then echo $cmdline fi @@ -50,6 +51,8 @@ function run() if [ $ret -eq 0 ]; then echo -e "\e[32mPASS\e[0m $1" + elif [ $ret -eq 124 ]; then + echo -e "\e[31mFAIL\e[0m $1 (timeout; duration=$timeout)" else echo -e "\e[31mFAIL\e[0m $1" fi @@ -57,7 +60,6 @@ function run() return $ret } -: ${MAX_SMP:=$(getconf _NPROCESSORS_CONF)} # # Probe for MAX_SMP, in case it's less than the number of host cpus. # diff --git a/x86/run b/x86/run index b07c815c5a6e1..3386524957a61 100755 --- a/x86/run +++ b/x86/run @@ -43,6 +43,7 @@ else fi command="${qemu} -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev $hyperv_testdev -kernel" +command="$(timeout_cmd) $command" echo ${command} "$@" exit_fixup ${command} "$@" diff --git a/x86/unittests.cfg b/x86/unittests.cfg index 4a9564536e8ea..b6094a4477ad5 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -12,6 +12,7 @@ # # specific to only one. # groups = <group_name1> <group_name2> ... # Used to identify test cases # # with run_tests -g ... +# timeout = <duration> # Optionally specify a timeout. ############################################################################## [apic] -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html