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
@@ -28,31 +27,31 @@ check_vmlinux() {
28
27
29
28
trace_test_string () {
30
29
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]+$"
33
32
then
34
- echo " String augmentation test failed"
33
+ printf " String augmentation test failed, output:\n $output \n "
35
34
err=1
36
35
fi
37
36
}
38
37
39
38
trace_test_buffer () {
40
39
echo " Testing perf trace's buffer augmentation"
41
40
# 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]+$"
44
43
then
45
- echo " Buffer augmentation test failed"
44
+ printf " Buffer augmentation test failed, output:\n $output \n "
46
45
err=1
47
46
fi
48
47
}
49
48
50
49
trace_test_struct_btf () {
51
50
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]+$"
54
53
then
55
- echo " BTF struct augmentation test failed"
54
+ printf " BTF struct augmentation test failed, output:\n $output \n "
56
55
err=1
57
56
fi
58
57
}
0 commit comments