From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/3] shell: Introduce TST_TIMEOUT variable
Date: Tue, 17 Sep 2019 18:55:20 +0200 [thread overview]
Message-ID: <20190917165520.GA30320@x230> (raw)
In-Reply-To: <CAEemH2f4oeSvN-p7xSzjo2ZFvndxjX2sQ+M9f6fYV_bN2ewn=A@mail.gmail.com>
> Hi Petr,
> Thanks for your working.
Thanks for a review!
...
> > +++ b/testcases/lib/tst_test.sh
> > @@ -379,9 +379,41 @@ _tst_rescmp()
> > _tst_setup_timer()
> > {
> > + TST_TIMEOUT=${TST_TIMEOUT:-300}
> > LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1}
> > - local sec=$((300 * LTP_TIMEOUT_MUL))
> > + if [ "$TST_TIMEOUT" = -1 ]; then
> > + tst_res TINFO "Timeout per run is disabled"
> > + return
> > + fi
> > +
> > + local err is_float
> > + if tst_is_num "$LTP_TIMEOUT_MUL"; then
> > + if tst_is_int "$LTP_TIMEOUT_MUL"; then
> > + [ "$LTP_TIMEOUT_MUL" -ge 1 ] || err=1
> > + else
> > + tst_test_cmds awk
This is the reason: awk dependency.
> > + echo | awk '{if ('"$LTP_TIMEOUT_MUL"' < 1) {exit
> > 1}}' || err=1
> > + is_float=1
> > + fi
> > + else
> > + err=1
> > + fi
> I'm OK to allow $LTP_TIMEOUT_MUL being float. But here I don't see what's
> enough reason to add the is_float variable. Because we could use the float
> expression for both types comparing, isn't it?
> > + if [ "$err" ]; then
> > + tst_brk TCONF "LTP_TIMEOUT_MUL must be number >= 1!
> > ($LTP_TIMEOUT_MUL)"
> > + fi
> > +
> > + if ! tst_is_int "$TST_TIMEOUT" || [ "$TST_TIMEOUT" -lt 1 ]; then
> > + tst_brk TBROK "TST_TIMEOUT must be int >= 1!
> > ($TST_TIMEOUT)"
> > + fi
> > +
> > + local sec
> > + if [ "$is_float" ]; then
> > + sec=`echo |awk '{printf("%d\n", '$TST_TIMEOUT' *
> > '$LTP_TIMEOUT_MUL')}'`
> > + else
> > + sec=$((TST_TIMEOUT * LTP_TIMEOUT_MUL))
> > + fi
> Here as well, why we need to distinguish the float and int, is the float
> expression does not work for integer?
Because it brings awk dependency on whole library, which I'm not sure if we
want (awk is a must on linux distros, it's in busybox; it's missing on android
toolsbox, but android project concentrates on syscalls, probably nobody uses
shell tests on android). Also I'm not sure about containers, JeOS etc. (it
sometimes miss a basic dependency).
If awk dependency is ok, it'd simplify test a bit.
Kind regards,
Petr
next prev parent reply other threads:[~2019-09-17 16:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 12:58 [LTP] [PATCH v2 0/3] LTP_TIMEOUT for shell API Petr Vorel
2019-09-13 12:58 ` [LTP] [PATCH v2 1/3] shell: Add tst_is_num() Petr Vorel
2019-09-13 12:58 ` [LTP] [PATCH v2 2/3] shell: Introduce TST_TIMEOUT variable Petr Vorel
2019-09-16 10:15 ` Li Wang
2019-09-17 16:55 ` Petr Vorel [this message]
2019-09-18 3:21 ` Li Wang
2019-09-18 8:24 ` Petr Vorel
2019-09-18 8:46 ` Li Wang
2019-09-18 9:50 ` Petr Vorel
2019-09-18 10:14 ` Li Wang
2019-09-18 13:53 ` Petr Vorel
2019-09-18 17:19 ` Clemens Famulla-Conrad
2019-09-16 10:26 ` Clemens Famulla-Conrad
2019-09-18 9:40 ` Petr Vorel
2019-09-18 17:16 ` Clemens Famulla-Conrad
2019-09-13 12:58 ` [LTP] [PATCH v2 3/3] net/if-mtu-change.sh: set TST_TIMEOUT Petr Vorel
2019-09-16 10:37 ` [LTP] [PATCH v2 0/3] LTP_TIMEOUT for shell API Clemens Famulla-Conrad
2019-09-17 11:22 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190917165520.GA30320@x230 \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox