2 # perf annotate basic tests
3 # SPDX-License-Identifier: GPL-2.0
7 shelldir
=$
(dirname "$0")
9 # shellcheck source=lib/perf_has_symbol.sh
10 .
"${shelldir}"/lib
/perf_has_symbol.sh
14 skip_test_missing_symbol
${testsym}
17 perfdata
=$
(mktemp
/tmp
/__perf_test.perf.data.XXXXX
)
18 perfout
=$
(mktemp
/tmp
/__perf_test.perf.out.XXXXX
)
19 testprog
="perf test -w noploop"
20 # disassembly format: "percent : offset: instruction (operands ...)"
21 disasm_regex
="[0-9]*\.[0-9]* *: *\w*: *\w*"
24 rm -rf "${perfdata}" "${perfout}"
25 rm -rf "${perfdata}".old
31 echo "Unexpected signal in ${FUNCNAME[1]}"
35 trap trap_cleanup EXIT TERM INT
38 echo "Basic perf annotate test"
39 if ! perf record
-o "${perfdata}" ${testprog} 2> /dev
/null
41 echo "Basic annotate [Failed: perf record]"
46 # Generate the annotated output file
47 perf annotate
--no-demangle -i "${perfdata}" --stdio 2> /dev
/null |
head -250 > "${perfout}"
49 # check if it has the target symbol
50 if ! grep "${testsym}" "${perfout}"
52 echo "Basic annotate [Failed: missing target symbol]"
57 # check if it has the disassembly lines
58 if ! grep "${disasm_regex}" "${perfout}"
60 echo "Basic annotate [Failed: missing disasm output from default disassembler]"
65 # check again with a target symbol name
66 if ! perf annotate
--no-demangle -i "${perfdata}" "${testsym}" 2> /dev
/null | \
67 head -250 |
grep -m 3 "${disasm_regex}"
69 echo "Basic annotate [Failed: missing disasm output when specifying the target symbol]"
74 # check one more with external objdump tool (forced by --objdump option)
75 if ! perf annotate
--no-demangle -i "${perfdata}" --objdump=objdump
2> /dev
/null | \
76 head -250 |
grep -m 3 "${disasm_regex}"
78 echo "Basic annotate [Failed: missing disasm output from non default disassembler (using --objdump)]"
82 echo "Basic annotate test [Success]"