diff mbox series

[v2,1/1] tools: Fix syntax error caused by "; ; " in create_dmesg_entry awk script

Message ID 20231228072109.349636-1-shichen@redhat.com
State Accepted
Headers show
Series [v2,1/1] tools: Fix syntax error caused by "; ; " in create_dmesg_entry awk script | expand

Commit Message

Shizhao Chen Dec. 28, 2023, 7:21 a.m. UTC
When running runltp with both -S and -K provided, tests that are supposed to be
"skipped" and report TCONF results were failing due to an unexpected semicolon
at the end of the constructed command.

`-S` replace the test command with `exit 32;`
`-K` appends another semicolon to the command then we get `exit 32;;`

For example:

  >>> 780:madvise06__with_dmesg_entry BROK <<<

       1        <<<test_start>>>
       2        tag=madvise06__with_dmesg_entry stime=1703556061
       3        cmdline="dmesg -c 1>/dev/null 2>&1; exit 32;; dmesg > /mnt/testarea/ltp/output/DMESG_DIR_RHELKT1LITE.FILTERED-dmesg-output-53127-08:48:23PM/madvise06.dmesg.log"
       4        contacts=""
       5        analysis=exit
       6        <<<test_output>>>
       7        sh: -c: line 1: syntax error near unexpected token `;;'
       8        sh: -c: line 1: `dmesg -c 1>/dev/null 2>&1; exit 32;; dmesg > /mnt/testarea/ltp/output/DMESG_DIR_RHELKT1LITE.FILTERED-dmesg-output-53127-08:48:23PM/madvise06.dmesg.log'
       9        <<<execution_status>>>
      10        initiation_status="ok"
      11        duration=0 termination_type=exited termination_id=2 corefile=no
      12        cutime=0 cstime=1
      13        <<<test_end>>>

Signed-off-by: Shizhao Chen <shichen@redhat.com>
---
 tools/create_dmesg_entries_for_each_test.awk | 1 +
 1 file changed, 1 insertion(+)

Comments

Li Wang Dec. 28, 2023, 9:59 a.m. UTC | #1
Pushed, thanks!
diff mbox series

Patch

diff --git a/tools/create_dmesg_entries_for_each_test.awk b/tools/create_dmesg_entries_for_each_test.awk
index 25d750a55..ffd807fb4 100644
--- a/tools/create_dmesg_entries_for_each_test.awk
+++ b/tools/create_dmesg_entries_for_each_test.awk
@@ -27,6 +27,7 @@  NF && ! /^#/ {
 	for (i = 2; i <= NF; i++) {
 		s = s " " $i
 	}
+	sub(/[;]+$/, "", s)
 	s = s "; dmesg > " DMESG_DIR "/" $1 ".dmesg.log"
 	print s
 }