aboutsummaryrefslogtreecommitdiff
path: root/testcases/lib
diff options
context:
space:
mode:
authorAlexey Kodanev <alexey.kodanev@oracle.com>2018-11-30 15:09:11 +0300
committerAlexey Kodanev <alexey.kodanev@oracle.com>2018-11-30 17:28:30 +0300
commitfbea02ab5df7946cb1c03f22a759852af1048655 (patch)
treec883eab46be1d96276b83a516c8f9b624660f698 /testcases/lib
parent6c03c71e8aaede5483638a31035feab366ebc558 (diff)
lib/tst_test.sh: setup timeout per test run for the shell tests
Use LTP_TIMEOUT_MUL environment variable, similar to what we have in the C library. Basically, the patch puts the child process with kill command to the background to signal the test process group processes after the certain timeout, which is controlled by LTP_TIMEOUT_MUL. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <pvorel@suse.cz>
Diffstat (limited to 'testcases/lib')
-rw-r--r--testcases/lib/tst_test.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index adfaea47e..a0bf6cc7a 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -59,6 +59,11 @@ _tst_do_exit()
[ "$TST_TMPDIR_RHOST" = 1 ] && tst_cleanup_rhost
fi
+ if [ -n "$_tst_setup_timer_pid" ]; then
+ kill $_tst_setup_timer_pid 2>/dev/null
+ wait $_tst_setup_timer_pid
+ fi
+
if [ $TST_FAIL -gt 0 ]; then
ret=$((ret|1))
fi
@@ -347,6 +352,24 @@ _tst_rescmp()
fi
}
+
+_tst_setup_timer()
+{
+ LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1}
+
+ local sec=$((300 * LTP_TIMEOUT_MUL))
+ local h=$((sec / 3600))
+ local m=$((sec / 60 % 60))
+ local s=$((sec % 60))
+ local pid=$$
+
+ tst_res TINFO "timeout per run is ${h}h ${m}m ${s}s"
+
+ sleep $sec && tst_res TBROK "test killed, timeout!" && kill -9 -$pid &
+
+ _tst_setup_timer_pid=$!
+}
+
tst_run()
{
local _tst_i
@@ -406,6 +429,8 @@ tst_run()
tst_brk TCONF "test requires kernel $TST_MIN_KVER+"
fi
+ _tst_setup_timer
+
if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
if [ -z "$TMPDIR" ]; then
export TMPDIR="/tmp"