All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib/tst_test.sh: setup timeout per test run for the shell tests
@ 2018-10-18 12:52 Alexey Kodanev
  2018-11-27 13:35 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kodanev @ 2018-10-18 12:52 UTC (permalink / raw)
  To: ltp

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>
---
 testcases/lib/tst_test.sh |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 7a41309..a7aa608 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -42,6 +42,11 @@ _tst_do_exit()
 {
 	local ret=0
 
+	if [ -n "$_tst_setup_timer_pid" ]; then
+		kill $_tst_setup_timer_pid
+		wait $_tst_setup_timer_pid 2>/dev/null
+	fi
+
 	if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" -a \
 	     -z "$TST_NO_CLEANUP" ]; then
 		$TST_CLEANUP
@@ -347,6 +352,23 @@ _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 && kill -INT -$pid &
+	_tst_setup_timer_pid=$!
+}
+
 tst_run()
 {
 	local _tst_i
@@ -406,6 +428,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"
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] lib/tst_test.sh: setup timeout per test run for the shell tests
  2018-10-18 12:52 [LTP] [PATCH] lib/tst_test.sh: setup timeout per test run for the shell tests Alexey Kodanev
@ 2018-11-27 13:35 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2018-11-27 13:35 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> 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>
> ---
>  testcases/lib/tst_test.sh |   24 ++++++++++++++++++++++++
>  1 files changed, 24 insertions(+), 0 deletions(-)

> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 7a41309..a7aa608 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -42,6 +42,11 @@ _tst_do_exit()
>  {
>  	local ret=0

> +	if [ -n "$_tst_setup_timer_pid" ]; then
> +		kill $_tst_setup_timer_pid
> +		wait $_tst_setup_timer_pid 2>/dev/null

STDERR redirection to /dev/null must be on kill, not on wait:
	   kill $_tst_setup_timer_pid 2>/dev/null
	   wait $_tst_setup_timer_pid

Otherwise warning is issued when timeout occurs:
udp_ipsec 1 TINFO: run client 'netstress -l -T udp -H 10.0.0.1 -n 100 -N 100 -a 2 -r 500 -d tst_netload.res -g 49072'
udp_ipsec 1 TBROK: test interrupted
/opt/ltp/testcases/bin/udp_ipsec.sh: 46: kill: No such process

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-27 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18 12:52 [LTP] [PATCH] lib/tst_test.sh: setup timeout per test run for the shell tests Alexey Kodanev
2018-11-27 13:35 ` Petr Vorel

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.