From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com
Subject: [kvm-unit-tests PATCH v3 6/6] run scripts: add timeout support
Date: Mon, 29 Feb 2016 19:53:23 +0100 [thread overview]
Message-ID: <1456772003-27911-7-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1456772003-27911-1-git-send-email-drjones@redhat.com>
Also remove useless qemu variable in scripts/runtime.bash.
Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
---
v3: now also powerpc/run. It may be noticed that powerpc/unittests.cfg
is not getting updated, as x86 and arm are. That's because I
accidentally already added the timeout variable comment to powerpc's
unittest.cfg header...
arm/run | 1 +
arm/unittests.cfg | 1 +
powerpc/run | 1 +
scripts/arch-run.bash | 8 ++++++++
scripts/functions.bash | 8 ++++++--
scripts/runtime.bash | 10 ++++++----
x86/run | 1 +
x86/unittests.cfg | 1 +
8 files changed, 25 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/powerpc/run b/powerpc/run
index 8ac684cc7c12f..b012789d962cd 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -45,6 +45,7 @@ M='-machine pseries'
M+=",accel=$ACCEL"
command="$qemu $M -bios $FIRMWARE"
command+=" -display none -serial stdio -kernel"
+command="$(timeout_cmd) $command"
echo $command "$@"
# powerpc tests currently exit with rtas-poweroff, which exits with 0.
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
next prev parent reply other threads:[~2016-02-29 18:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 18:53 [kvm-unit-tests PATCH v3 0/6] reduce exit status ambiguity and more Andrew Jones
2016-02-29 18:53 ` [kvm-unit-tests PATCH v3 1/6] x86: clean up exit use, use abort Andrew Jones
2016-02-29 18:53 ` [kvm-unit-tests PATCH v3 2/6] run scripts need consistent exit status Andrew Jones
2016-02-29 18:53 ` [kvm-unit-tests PATCH v3 3/6] arch-run: reduce return code ambiguity Andrew Jones
2016-03-01 21:29 ` Paolo Bonzini
2016-03-02 12:57 ` Radim Krčmář
2016-03-02 14:44 ` Paolo Bonzini
2016-03-02 15:42 ` Radim Krčmář
2016-03-02 16:05 ` Paolo Bonzini
2016-03-02 17:13 ` Radim Krčmář
2016-02-29 18:53 ` [kvm-unit-tests PATCH v3 4/6] cleanup unittests.cfg headers Andrew Jones
2016-02-29 18:53 ` [kvm-unit-tests PATCH v3 5/6] runtime: enable some unittest config overriding Andrew Jones
2016-02-29 18:53 ` Andrew Jones [this message]
2016-03-01 21:30 ` [kvm-unit-tests PATCH v3 0/6] reduce exit status ambiguity and more Paolo Bonzini
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=1456772003-27911-7-git-send-email-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.