Skip to content

Commit d796c51

Browse files
Sbermnamhyung
authored andcommitted
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 <[email protected]> Tested-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent fc4a0ae commit d796c51

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tools/perf/tests/shell/trace_btf_general.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# SPDX-License-Identifier: GPL-2.0
44

55
err=0
6-
set -e
76

87
# shellcheck source=lib/probe.sh
98
. "$(dirname $0)"/lib/probe.sh
@@ -28,31 +27,31 @@ check_vmlinux() {
2827

2928
trace_test_string() {
3029
echo "Testing perf trace's string augmentation"
31-
if ! perf trace -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1 | \
32-
grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$"
30+
output="$(perf trace -e renameat* --max-events=1 -- mv ${file1} ${file2} 2>&1)"
31+
if ! echo "$output" | grep -q -E "^mv/[0-9]+ renameat(2)?\(.*, \"${file1}\", .*, \"${file2}\", .*\) += +[0-9]+$"
3332
then
34-
echo "String augmentation test failed"
33+
printf "String augmentation test failed, output:\n$output\n"
3534
err=1
3635
fi
3736
}
3837

3938
trace_test_buffer() {
4039
echo "Testing perf trace's buffer augmentation"
4140
# echo will insert a newline (\10) at the end of the buffer
42-
if ! perf trace -e write --max-events=1 -- echo "${buffer}" 2>&1 | \
43-
grep -q -E "^echo/[0-9]+ write\([0-9]+, ${buffer}.*, [0-9]+\) += +[0-9]+$"
41+
output="$(perf trace -e write --max-events=1 -- echo "${buffer}" 2>&1)"
42+
if ! echo "$output" | grep -q -E "^echo/[0-9]+ write\([0-9]+, ${buffer}.*, [0-9]+\) += +[0-9]+$"
4443
then
45-
echo "Buffer augmentation test failed"
44+
printf "Buffer augmentation test failed, output:\n$output\n"
4645
err=1
4746
fi
4847
}
4948

5049
trace_test_struct_btf() {
5150
echo "Testing perf trace's struct augmentation"
52-
if ! perf trace -e clock_nanosleep --force-btf --max-events=1 -- sleep 1 2>&1 | \
53-
grep -q -E "^sleep/[0-9]+ clock_nanosleep\(0, 0, \{1,\}, 0x[0-9a-f]+\) += +[0-9]+$"
51+
output="$(perf trace -e clock_nanosleep --force-btf --max-events=1 -- sleep 1 2>&1)"
52+
if ! echo "$output" | grep -q -E "^sleep/[0-9]+ clock_nanosleep\(0, 0, \{1,\}, 0x[0-9a-f]+\) += +[0-9]+$"
5453
then
55-
echo "BTF struct augmentation test failed"
54+
printf "BTF struct augmentation test failed, output:\n$output\n"
5655
err=1
5756
fi
5857
}

0 commit comments

Comments
 (0)