Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test trace: Remove set -e for BTF general tests

Remove set -e and print error messages in BTF general tests.

Before:
$ sudo /tmp/perf test btf -vv
108: perf trace BTF general tests:
108: perf trace BTF general tests : Running
--- start ---
test child forked, pid 889299
Checking if vmlinux BTF exists
Testing perf trace's string augmentation
String augmentation test failed
---- end(-1) ----
108: perf trace BTF general tests : FAILED!

After:
$ sudo /tmp/perf test btf -vv
108: perf trace BTF general tests:
108: perf trace BTF general tests : Running
--- start ---
test child forked, pid 886551
Checking if vmlinux BTF exists
Testing perf trace's string augmentation
String augmentation test failed, output:
:886566/886566 renameat2(CWD, "/tmp/file1_RcMa", CWD, "/tmp/file2_RcMa", NOREPLACE) = 0---- end(-1) ----
108: perf trace BTF general tests : FAILED!

Signed-off-by: Howard Chu <howardchu95@gmail.com>
Tested-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20250528191148.89118-5-howardchu95@gmail.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Howard Chu and committed by
Namhyung Kim
d796c51e fc4a0ae7

+9 -10
+9 -10
tools/perf/tests/shell/trace_btf_general.sh
··· 3 3 # SPDX-License-Identifier: GPL-2.0 4 4 5 5 err=0 6 - set -e 7 6 8 7 # shellcheck source=lib/probe.sh 9 8 . "$(dirname $0)"/lib/probe.sh ··· 27 28 28 29 trace_test_string() { 29 30 echo "Testing perf trace's string augmentation" 30 - if ! perf trace -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1 | \ 31 - grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$" 31 + output="$(perf trace -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1)" 32 + if ! echo "$output" | grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$" 32 33 then 33 - echo "String augmentation test failed" 34 + printf "String augmentation test failed, output:\n$output\n" 34 35 err=1 35 36 fi 36 37 } ··· 38 39 trace_test_buffer() { 39 40 echo "Testing perf trace's buffer augmentation" 40 41 # echo will insert a newline (\10) at the end of the buffer 41 - if ! perf trace -e write --max-events=1 -- echo "${buffer}" 2>&1 | \ 42 - grep -q -E "^echo/[0-9]+ write\([0-9]+, ${buffer}.*, [0-9]+\) += +[0-9]+$" 42 + output="$(perf trace -e write --max-events=1 -- echo "${buffer}" 2>&1)" 43 + if ! echo "$output" | grep -q -E "^echo/[0-9]+ write\([0-9]+, ${buffer}.*, [0-9]+\) += +[0-9]+$" 43 44 then 44 - echo "Buffer augmentation test failed" 45 + printf "Buffer augmentation test failed, output:\n$output\n" 45 46 err=1 46 47 fi 47 48 } 48 49 49 50 trace_test_struct_btf() { 50 51 echo "Testing perf trace's struct augmentation" 51 - if ! perf trace -e clock_nanosleep --force-btf --max-events=1 -- sleep 1 2>&1 | \ 52 - grep -q -E "^sleep/[0-9]+ clock_nanosleep\(0, 0, \{1,\}, 0x[0-9a-f]+\) += +[0-9]+$" 52 + output="$(perf trace -e clock_nanosleep --force-btf --max-events=1 -- sleep 1 2>&1)" 53 + if ! echo "$output" | grep -q -E "^sleep/[0-9]+ clock_nanosleep\(0, 0, \{1,\}, 0x[0-9a-f]+\) += +[0-9]+$" 53 54 then 54 - echo "BTF struct augmentation test failed" 55 + printf "BTF struct augmentation test failed, output:\n$output\n" 55 56 err=1 56 57 fi 57 58 }