Skip to contentSkip to conversation

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

PATCH New Petr Vorel 2 participants 3 messages Jul 12, 2019 – Jul 18, 2019

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

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

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

---
 testcases/lib/tst_test.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
testcases/lib/tst_test.sh +5 -4
index 31b3a3951..55a642267 100644
@@ -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))
Signature · 1 line
2.22.0
#1 lore raw

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

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?

Quoted 1 line · Petr Vorel

...

- tst_brk TBROK "\"$tst_fun\" timed out"

Quoted 3 lines

+ 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" ?

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190718/04f9d61f/attachment.htm>
author
#2 lore raw

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

Hi Li,

Quoted 5 lines

Hi Petr,

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

Quoted 7 lines
    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 <[email protected]> wrote:

Yes, you're right.

Quoted 8 lines
Quoted 1 line

...

- tst_brk TBROK "\"$tst_fun\" timed out"

Quoted 2 lines

+ 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