From caab9f1e6f7ac0d8d5209c31854d640b807519ce Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 11 Jul 2013 12:58:45 +0100 Subject: [PATCH 2/2] ./run: Timeout tests after 1 hour. No single test should run longer than 1 hour even on the slowest of hardware. We are having a problem in Koji where a test hangs and then we end up losing the output completely, so a timeout + print the log to that point is much better. --- run.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/run.in b/run.in index f49df8e..d8b2e03 100755 --- a/run.in +++ b/run.in @@ -220,12 +220,20 @@ fi # - redirect all output to a file, and only print the file if the # test fails # - print how long it takes to run the test +# - timeout if the test takes too long to run + +# Do we have Padraig's timeout utility (from coreutils)? +if timeout --help >/dev/null 2>&1; then + # Timeout (SIGTERM) after 1 hour. + # Then send a second SIGKILL 30 seconds later. + timeout="timeout -k 30s 1h" +fi pid=$$ tmpout=$b/tmp/run-$pid rm -f $tmpout start_t="$(date +'%s')" -$libtool "$@" > $tmpout 2>&1 +$timeout $libtool "$@" > $tmpout 2>&1 fail=$? end_t="$(date +'%s')" if [ "$fail" -eq 0 ]; then @@ -234,6 +242,11 @@ if [ "$fail" -eq 0 ]; then elif [ "$fail" -eq 77 ]; then # Tests return 77 to mean skipped. cat $tmpout +elif [ "$fail" -eq 124 ]; then + # Timed out. + echo "$b/run --test" "$@" + cat $tmpout + echo "$b/run: command timed out after 1 hour" else # Test failed. echo "$b/run --test" "$@" -- 1.8.3.1