From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 2/3] shell: Introduce TST_TIMEOUT variable, add checks
Date: Tue, 24 Sep 2019 18:20:32 +0200 [thread overview]
Message-ID: <20190924162032.GA28669@dell5510> (raw)
In-Reply-To: <20190924140757.GA787@rei>
Hi Cyril,
...
> > +++ b/doc/test-writing-guidelines.txt
> > -2.2.3 Test temporary directory
> > +2.2.3 Library environment variables for C
> > +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +[options="header"]
> > +|=============================================================================
> > +| Variable name | Action done
> > +| 'LTP_TIMEOUT_MUL' | Multiply timeout, must be number >= 1 (> 1 is useful for
> > + slow machines to avoid unexpected timeout).
> > + Variable is also used in shell tests.
> > +|=============================================================================
> > +
> > +2.2.4 Test temporary directory
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Can we please avoid this renumbering, also after this patch this
> variable applies to both shell and C. So this should probably go
> somewhere else, and I'm pretty sure that we have a few more at least
> LTPROOT, TMPDIR, KCONFIG_PATH, LTP_COLORIZE_OUTPUT.
OK, do you want a single section "Library environment variables" (for both C and
shell), putting at 5. ? (at the end?)
...
> > +++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
> > @@ -17,7 +17,7 @@ TST_NEEDS_CMDS="mount umount cat kill mkdir rmdir grep awk cut"
> > # Each test case runs for 900 secs when everything fine
> > # therefore the default 5 mins timeout is not enough.
> > -LTP_TIMEOUT_MUL=7
> > +TST_TIMEOUT=2100
> > . cgroup_lib.sh
> Shouldn't this go in in a separate patch?
I thought this change is closely related, but you're right as it does not break
the code, I'll put it into separate commit.
...
> > +++ b/testcases/lib/tst_test.sh
> > @@ -379,9 +379,47 @@ _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="LTP_TIMEOUT_MUL must be number >= 1!"
> > + local is_float
> > +
> > + tst_is_num "$LTP_TIMEOUT_MUL" || tst_brk TCONF "$err ($LTP_TIMEOUT_MUL)"
> > +
> > + if ! tst_is_int "$LTP_TIMEOUT_MUL"; then
> > + if tst_cmd_available awk; then
> > + is_float=1
> My first choice for floating point in shell would be bc.
Yes, but I guess awk is more common on linux than bc - I'd guess bc is not
installed by default, but maybe I'm wrong. If I'm wrong using bc would be
certainly more readable.
+ I didn't realize that bc is also in busybox (the same as awk).
So shell I rewrite it to bc?
> > + else
> > + tst_res TINFO "awk not available, cast LTP_TIMEOUT_MUL to int"
> > + tst_test_cmds cut
> > + LTP_TIMEOUT_MUL=$(echo "$LTP_TIMEOUT_MUL" | cut -d. -f1)
> Hmm, I guess that it would be safer to cut the part after the decimal
> point and add one, because that would always round up, which is probably
> what we really want instead.
Make sense (but see below).
> > + fi
> > + fi
> > +
> > + if [ "$is_float" ]; then
> > + echo | awk '{if ('"$LTP_TIMEOUT_MUL"' < 1) {exit 1}}' || \
> > + tst_brk TCONF "$err ($LTP_TIMEOUT_MUL)"
> The bc command can do comparsions like this as well.
Sure, I just was convinced it's not installed by default on distros.
> Also I wonder if it would be easier just to do ceil of the
> LTP_TIMEOUT_MUL unconditionally and get rid of the floating point mess,
> since it's just a timeout and we do not care that much if it's
> multiplied precisely as far as the resulting timeout is never smaller
> than the precise calculation.
OK, I'll do ceil in v4. I don't know why thought it'd be important to have that
support (I think Li or Clemens suggested that).
Kind regards,
Petr
next prev parent reply other threads:[~2019-09-24 16:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 13:50 [LTP] [PATCH v3 0/3] shell: Introduce TST_TIMEOUT variable Petr Vorel
2019-09-19 13:50 ` [LTP] [PATCH v3 1/3] shell: Add tst_is_num() Petr Vorel
2019-09-19 13:50 ` [LTP] [PATCH v3 2/3] shell: Introduce TST_TIMEOUT variable, add checks Petr Vorel
2019-09-24 14:07 ` Cyril Hrubis
2019-09-24 16:20 ` Petr Vorel [this message]
2019-09-24 18:38 ` Petr Vorel
2019-09-19 13:50 ` [LTP] [PATCH v3 3/3] net/if-mtu-change.sh: set TST_TIMEOUT Petr Vorel
2019-09-20 13:48 ` [LTP] [PATCH v3 0/3] shell: Introduce TST_TIMEOUT variable Clemens Famulla-Conrad
2019-09-24 7:01 ` Li Wang
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=20190924162032.GA28669@dell5510 \
--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