* [LTP] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID
@ 2018-05-02 13:45 Petr Vorel
2018-05-02 14:45 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2018-05-02 13:45 UTC (permalink / raw)
To: ltp
'basename $0' fails when loaded in command line with bash (at least)
as $0 is invalid ('-bash'):
$ unset TST_ID; export TST_NO_DEFAULT_RUN=1; . tst_test.sh
-bash: tst_ansi_color.sh: No such file or directory
basename: invalid option -- 'b'
Try 'basename --help' for more information.
It's better to TCONF than be without TST_ID.
NOTE: Sourcing tst_test.sh can be needed for network scripts: users
might want to set network variables with tst_net.sh, which itself
sources tst_test.sh.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_test.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 8d49d34b6..39744d29e 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -377,7 +377,8 @@ tst_run()
}
if [ -z "$TST_ID" ]; then
- filename=$(basename $0)
+ filename=$(basename $0) || \
+ tst_brk TBROK "Failed to set TST_ID from \$0 ('$0'), fix it with setting TST_ID before sourcing tst_test.sh"
TST_ID=${filename%%.*}
fi
export TST_ID="$TST_ID"
--
2.16.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID
2018-05-02 13:45 [LTP] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID Petr Vorel
@ 2018-05-02 14:45 ` Petr Vorel
2018-05-03 7:54 ` Li Wang
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2018-05-02 14:45 UTC (permalink / raw)
To: ltp
Hi,
...
> if [ -z "$TST_ID" ]; then
> - filename=$(basename $0)
> + filename=$(basename $0) || \
> + tst_brk TBROK "Failed to set TST_ID from \$0 ('$0'), fix it with setting TST_ID before sourcing tst_test.sh"
^
Here is going to be TCONF.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID
2018-05-02 14:45 ` Petr Vorel
@ 2018-05-03 7:54 ` Li Wang
2018-06-01 9:48 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2018-05-03 7:54 UTC (permalink / raw)
To: ltp
On Wed, May 2, 2018 at 10:45 PM, Petr Vorel <pvorel@suse.cz> wrote:
> Hi,
>
> ...
> > if [ -z "$TST_ID" ]; then
> > - filename=$(basename $0)
> > + filename=$(basename $0) || \
> > + tst_brk TBROK "Failed to set TST_ID from \$0 ('$0'), fix
> it with setting TST_ID before sourcing tst_test.sh"
> ^
> Here is going to be TCONF.
>
​Looks good to me.
--
Li Wang
liwang@redhat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180503/b5d560ac/attachment.html>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID
2018-05-03 7:54 ` Li Wang
@ 2018-06-01 9:48 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-06-01 9:48 UTC (permalink / raw)
To: ltp
Hi,
> On Wed, May 2, 2018 at 10:45 PM, Petr Vorel <pvorel@suse.cz> wrote:
> > ...
> > > if [ -z "$TST_ID" ]; then
> > > - filename=$(basename $0)
> > > + filename=$(basename $0) || \
> > > + tst_brk TBROK "Failed to set TST_ID from \$0 ('$0'), fix
> > it with setting TST_ID before sourcing tst_test.sh"
> > ^
> > Here is going to be TCONF.
> Looks good to me.
Pushed.
Li, thanks for your review.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-06-01 9:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-02 13:45 [LTP] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID Petr Vorel
2018-05-02 14:45 ` Petr Vorel
2018-05-03 7:54 ` Li Wang
2018-06-01 9:48 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.