From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/1] tst_test.sh: Add test cmd helper tst_test_cmds()
Date: Tue, 24 Jul 2018 14:57:08 +0200 [thread overview]
Message-ID: <20180724125708.GA5894@x230> (raw)
In-Reply-To: <20180724093537.GA19255@rei>
Hi Cyril,
> Hi!
> > + tst_cmd_available()
> > tst_test_cmds() is meant to be a check just for a particular test.
> > Works like tst_check_cmds(), but instead of tst_brk() calls tst_res().
> Hmm looking at this after a while I would expect the tst_test_cmds() to
> exit the test while tst_check_cmds() to return a value, the question is
> if this is worth of the work of renaming the current uses...
Indeed, names would be better to be reversed. It's up to you.
If you want, I'll first rename tst_check_cmds() to tst_test_cmds()
and then add this new one as tst_check_cmds().
> > tst_cmd_available() helper can handle cases when command shell builtin
> > is not available (e.g. Busybox).
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > Hi,
> > if you don't like using which or testing with 127 exit code in
> > tst_cmd_available() (or if you don't like tst_cmd_available()), I
> > can remove it.
> This looks fine to me.
Thx!
> > Locating kernel modules
> > +++++++++++++++++++++++
> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
...
> > tst_check_cmds()
> > {
> > local cmd
> > for cmd in $*; do
> BTW you can just write 'for cmd; do' here since the default
> array to loop over are the parameters passed to a function.
Thanks, I'll simplify it. This POSIX shell feature was hidden to me.
...
> > +tst_test_cmds()
> > +{
> > + local cmd
> > + for cmd in $*; do
> > + if ! tst_cmd_available $cmd; then
> > + tst_res TCONF "'$cmd' not found"
> > + return 1
> > fi
> > done
> Can we add explicit return 0 here?
Sure.
> Other than that it's fine.
Kind regards,
Petr
next prev parent reply other threads:[~2018-07-24 12:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-23 9:17 [LTP] [PATCH v2 1/1] tst_test.sh: Add test cmd helper tst_test_cmds() Petr Vorel
2018-06-01 9:42 ` Petr Vorel
2018-07-24 9:35 ` Cyril Hrubis
2018-07-24 12:57 ` Petr Vorel [this message]
2018-07-24 13:15 ` Cyril Hrubis
2018-07-24 15:19 ` 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=20180724125708.GA5894@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