diff mbox series

tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF()

Message ID 20190712134328.20528-1-pvorel@suse.cz
State Superseded
Delegated to: Petr Vorel
Headers show
Series tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF() | expand

Commit Message

Petr Vorel July 12, 2019, 1:43 p.m. UTC
This function should also address possibility of slow machine.

Because using on 2 places moved the default definition to the beginning
of the script.
+ use $((...)) instead of expr.
+ move expression using $3 after check whether we have enough parameters

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Li Wang July 18, 2019, 5:56 a.m. UTC | #1
Hi Petr,

If timeout occurred in the exp backoff macro, we could pass a bit more time
to it and use prototype directly.

    e.g.   TST_RETRY_FN_EXP_BACKOFF "$1" "$2" "more_time"

And yes, we actually can't guarantee a proper time value for all kinds of
platforms. So I agree on involve $LTP_TIMEOUT_MUL to exp backoff macro.

Btw, shouldn't we also apply this change to the C prototype too?
On Fri, Jul 12, 2019 at 9:43 PM Petr Vorel <pvorel@suse.cz> wrote:

> ...

-                       tst_brk TBROK "\"$tst_fun\" timed out"
> +                       tst_brk TBROK "\"$tst_fun\" timed out! If you are
> running on slow machine, try exporting LTP_TIMEOUT_MUL"
>

"..., try exporting LTP_TIMEOUT_MUL > 1" ?
Petr Vorel July 18, 2019, 6:38 a.m. UTC | #2
Hi Li,

> Hi Petr,

> If timeout occurred in the exp backoff macro, we could pass a bit more time
> to it and use prototype directly.

>     e.g.   TST_RETRY_FN_EXP_BACKOFF "$1" "$2" "more_time"

> And yes, we actually can't guarantee a proper time value for all kinds of
> platforms. So I agree on involve $LTP_TIMEOUT_MUL to exp backoff macro.

> Btw, shouldn't we also apply this change to the C prototype too?
> On Fri, Jul 12, 2019 at 9:43 PM Petr Vorel <pvorel@suse.cz> wrote:
Yes, you're right.

> > ...

> -                       tst_brk TBROK "\"$tst_fun\" timed out"
> > +                       tst_brk TBROK "\"$tst_fun\" timed out! If you are
> > running on slow machine, try exporting LTP_TIMEOUT_MUL"


> "..., try exporting LTP_TIMEOUT_MUL > 1" ?
Yes, that's better description.

=> I'll prepare v2.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 31b3a3951..55a642267 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -17,6 +17,8 @@  export TST_ITERATIONS=1
 export TST_TMPDIR_RHOST=0
 export TST_LIB_LOADED=1
 
+export LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1}
+
 . tst_ansi_color.sh
 . tst_security.sh
 
@@ -164,12 +166,13 @@  TST_RETRY_FN_EXP_BACKOFF()
 {
 	local tst_fun="$1"
 	local tst_exp=$2
-	local tst_sec=$(expr $3 \* 1000000)
 	local tst_delay=1
+	local tst_sec
 
 	if [ $# -ne 3 ]; then
 		tst_brk TBROK "TST_RETRY_FN_EXP_BACKOFF expects 3 parameters"
 	fi
+	tst_sec=$(($3 * LTP_TIMEOUT_MUL * 1000000))
 
 	if ! tst_is_int "$tst_sec"; then
 		tst_brk TBROK "TST_RETRY_FN_EXP_BACKOFF: tst_sec must be integer ('$tst_sec')"
@@ -185,7 +188,7 @@  TST_RETRY_FN_EXP_BACKOFF()
 			tst_sleep ${tst_delay}us
 			tst_delay=$((tst_delay*2))
 		else
-			tst_brk TBROK "\"$tst_fun\" timed out"
+			tst_brk TBROK "\"$tst_fun\" timed out! If you are running on slow machine, try exporting LTP_TIMEOUT_MUL"
 		fi
 	done
 
@@ -374,8 +377,6 @@  _tst_rescmp()
 
 _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))