* [LTP] [PATCH] tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF()
@ 2019-07-12 13:43 Petr Vorel
2019-07-18 5:56 ` Li Wang
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2019-07-12 13:43 UTC (permalink / raw)
To: ltp
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(-)
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))
--
2.22.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH] tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF()
2019-07-12 13:43 [LTP] [PATCH] tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF() Petr Vorel
@ 2019-07-18 5:56 ` Li Wang
2019-07-18 6:38 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2019-07-18 5:56 UTC (permalink / raw)
To: ltp
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" ?
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190718/04f9d61f/attachment.htm>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH] tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF()
2019-07-18 5:56 ` Li Wang
@ 2019-07-18 6:38 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2019-07-18 6:38 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-18 6:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-12 13:43 [LTP] [PATCH] tst_test.sh: Use $LTP_TIMEOUT_MUL also in TST_RETRY_FN_EXP_BACKOFF() Petr Vorel
2019-07-18 5:56 ` Li Wang
2019-07-18 6:38 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox