[LTP] Bug: ROD_SILENT does not preserve its argument list
Petr Vorel
pvorel@suse.cz
Wed Apr 16 14:15:23 CEST 2025
Hi John,
> Hello:
> Submitting bug against ROD_SILENT.
> Sincerely,
NOTE: if you put the above below first '---', we read it on the mailing list,
but it will not be part of the commit message, see example [1].
> * John Morin.
> ==== Bug in ROD_SILENT ====
> Need to quote "$@" in ROD_SILENT so each parameter is individually quoted. Otherwise, the original structure of its arguments is lost.
> ==== Fix ====
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 718a6b0ca..cfa327a8a 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -153,7 +153,7 @@ ROD_SILENT()
> {
> local tst_out
> - tst_out="$(tst_rod $@ 2>&1)"
> + tst_out=$(tst_rod "$@" 2>&1)
> if [ $? -ne 0 ]; then
> echo "$tst_out"
> tst_brk TBROK "$@ failed"
> ==== Test showing bug ====
> Test "test1" is an LTP tests. The runs the same command using ROD and ROD_SILENT. The command it runs simply greps for string "blah1 blah2" in file data2. When run, ROD passes while ROD_SILENT fails. This is because ROD_SILENT does not preserve quoted arguments.
> % cat data2
> --- blah1 blah2 blah3 ---
Thank you for a valid fix + example how to test, merged as [2].
IMHO this was broken from the original implementation
14cefa9 ("tst_test.sh: Implement ROD_BASE in C") [3].
FYI patch was not applicable neither to the current master nor to the latest
LTP release 20250130. It was not difficult to apply the patch manually, but for
bigger changes it's better when the patch apply.
Before merging I reworded the commit message and added your SBT:
Signed-off-by: John Morin <John.Morin@gd-ms.com>
> % cat test1
> #!/bin/bash
Also, LTP uses POSIX shell syntax [4] (FYI it's better to test against /bin/dash, or
use checkbashisms, to make sure there is no bashism).
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/20250402224148.435022-1-pvorel@suse.cz/
[2] https://github.com/linux-test-project/ltp/commit/0c0076fbaf6e0059b470fadff6240fc56952c218
[3] https://github.com/linux-test-project/ltp/commit/14cefa9387de5c23174c1a013dc2a04bb3717d4d
[4] https://linux-test-project.readthedocs.io/en/latest/developers/writing_tests.html#shell-coding-style
> TST_TESTFUNC="do_test"
> do_test()
> {
> ROD grep "blah1 blah2" data2
> ROD_SILENT grep "blah1 blah2" data2
> tst_res TPASS "pass"
> }
> . tst_test.sh
> tst_run
> % ./test1 # Note ROD passes while ROD_SILENT fails
> > ./test1
> test1 1 TINFO: Running: test1
> test1 1 TINFO: Tested kernel: ...
> test1 1 TINFO: timeout per run is 0h 5m 0s
> --- blah1 blah2 blah3 ---
> grep: blah2: No such file or directory
> data2:--- blah1 blah2 blah3 ---
> test1 1 TBROK: grep blah1 blah2 data2 failed
> Summary:
> passed 0
> failed 0
> broken 1
> skipped 0
> warnings 0
More information about the ltp
mailing list