1 #!/bin/bash 2 # perf annotate basic tests 3 # SPDX-License-Identifier: GPL-2.0 4 5 set -e 6 7 shelldir=$(dirname "$0") 8 9 # shellcheck source=lib/perf_has_symbol.sh 10 . "${shelldir}"/lib/perf_has_symbol.sh 11 12 testsym="noploop" 13 14 skip_test_missing_symbol ${testsym} 15 16 err=0 17 perfdata=$(mktemp /tmp/__perf_test.perf.data.X 18 perfout=$(mktemp /tmp/__perf_test.perf.out.XXX 19 testprog="perf test -w noploop" 20 # disassembly format: "percent : offset: instr 21 disasm_regex="[0-9]*\.[0-9]* *: *\w*: *\w*" 22 23 cleanup() { 24 rm -rf "${perfdata}" "${perfout}" 25 rm -rf "${perfdata}".old 26 27 trap - EXIT TERM INT 28 } 29 30 trap_cleanup() { 31 echo "Unexpected signal in ${FUNCNAME[1]}" 32 cleanup 33 exit 1 34 } 35 trap trap_cleanup EXIT TERM INT 36 37 test_basic() { 38 echo "Basic perf annotate test" 39 if ! perf record -o "${perfdata}" ${testprog 40 then 41 echo "Basic annotate [Failed: perf record] 42 err=1 43 return 44 fi 45 46 # Generate the annotated output file 47 perf annotate -i "${perfdata}" --stdio 2> /d 48 49 # check if it has the target symbol 50 if ! grep "${testsym}" "${perfout}" 51 then 52 echo "Basic annotate [Failed: missing targ 53 err=1 54 return 55 fi 56 57 # check if it has the disassembly lines 58 if ! grep "${disasm_regex}" "${perfout}" 59 then 60 echo "Basic annotate [Failed: missing disa 61 err=1 62 return 63 fi 64 65 # check again with a target symbol name 66 if ! perf annotate -i "${perfdata}" "${tests 67 grep -m 3 "${disasm_regex}" 68 then 69 echo "Basic annotate [Failed: missing disa 70 err=1 71 return 72 fi 73 74 # check one more with external objdump tool 75 if ! perf annotate -i "${perfdata}" --objdum 76 grep -m 3 "${disasm_regex}" 77 then 78 echo "Basic annotate [Failed: missing disa 79 err=1 80 return 81 fi 82 echo "Basic annotate test [Success]" 83 } 84 85 test_basic 86 87 cleanup 88 exit $err
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.