[LTP] [PATCH v3 2/4] Add support for mixing C and shell code
Li Wang
liwang@redhat.com
Fri Sep 6 12:09:59 CEST 2024
On Fri, Sep 6, 2024 at 5:54 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> > tst_test.c:1860: TINFO: LTP version: 20240524
> > tst_test.c:1864: TINFO: Tested kernel: 6.8.0-1010-raspi #11-Ubuntu SMP
> > PREEMPT_DYNAMIC Thu Aug 8 23:22:41 UTC 2024 aarch64
> > tst_test.c:1703: TINFO: Timeout per run is 0h 00m 30s
> > shell_test01.c:11: TINFO: C test exits now
> > Usage: tst_res_ filename lineno [TPASS|TFAIL|TCONF|TINFO|TDEBUG] 'A short
> > description'
> > tst_test.c:1535: TBROK: Test haven't reported results!
> >
> > Summary:
> > passed 0
> > failed 0
> > broken 1
> > skipped 0
> > warnings 0
> >
> >
> > Here I got test failures on my RPi4 (bash-5.2.21) that the $LINEON can't
> > be parsed correctly.
>
> Are you sure that this is due to bash? My guess is that on RPi the
> default shell is dash because it's debian based.
>
Double checked that is indeed bash.
liwang@raspi4:~/ltp/testcases/lib$ echo $0
-bash
liwang@raspi4:~/ltp/testcases/lib$ echo $SHELL
/bin/bash
liwang@raspi4:~/ltp/testcases/lib$ ps -p $$
PID TTY TIME CMD
174997 pts/0 00:00:04 bash
I even manually coded the !#/bin/bash in every test file, the test still
failed.
$ bash run_tests.sh
tst_test.c:1860: TINFO: LTP version: 20240524
tst_test.c:1864: TINFO: Tested kernel: 6.8.0-1010-raspi #11-Ubuntu SMP
PREEMPT_DYNAMIC Thu Aug 8 23:22:41 UTC 2024 aarch64
tst_test.c:1703: TINFO: Timeout per run is 0h 00m 30s
shell_test01.c:11: TINFO: C test exits now
/home/liwang/ltp/testcases/lib/tests//shell_test_pass.sh: line 5: tst_res:
command not found
/bin/bash
tst_test.c:1535: TBROK: Test haven't reported results!
Summary:
passed 0
failed 0
broken 1
skipped 0
warnings 0
>
> I will try to reproduce.
>
> > The reason probably is some shells or specific versions might not handle
> > $LINENO correctly within aliases, especially when the line number needs
> > to be dynamically determined.
> >
> > So I suggest using a function instead of the alias.
> >
> >
> > --- a/testcases/lib/tst_env.sh
> > +++ b/testcases/lib/tst_env.sh
> > @@ -21,5 +21,12 @@ tst_brk_()
> > esac
> > }
> >
> > -alias tst_res="tst_res_ $tst_script_name \$LINENO"
> > -alias tst_brk="tst_brk_ $tst_script_name \$LINENO"
> > +tst_res()
> > +{
> > + tst_res_ "$tst_script_name" "$LINENO" "$@"
> > +}
> > +
> > +tst_brk()
> > +{
> > + tst_brk_ "$tst_script_name" "$LINENO" "$@"
> > +}
>
> That actually does not work because unlike the alias the $LINENO is
> expanded in the wrong place and the line is incorrect.
>
> The whole reason for this to be alias is that it's expanded on the
> correct line in the test source.
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
>
--
Regards,
Li Wang
More information about the ltp
mailing list