[LTP] [PATCH v3 2/4] Add support for mixing C and shell code

Cyril Hrubis chrubis@suse.cz
Fri Sep 6 11:53:13 CEST 2024


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.

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


More information about the ltp mailing list