| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | shelldir=$(dirname "$0")
|
| 6 | |
| 7 | . "${shelldir}"/lib/perf_has_symbol.sh
|
| 8 |
|
| 9 | sym="noploop"
|
| 10 |
|
| 11 | skip_test_missing_symbol ${sym}
|
| 12 |
|
| 13 | data=$(mktemp /tmp/perf.data.XXXXXX)
|
| 14 | data2=$(mktemp /tmp/perf.data2.XXXXXX)
|
| 15 | prog="perf test -w noploop 0.1"
|
| 16 | [ "$(uname -m)" = "s390x" ] && prog="perf test -w noploop 3"
|
| 17 | err=0
|
| 18 |
|
| 19 | set -e
|
| 20 |
|
| 21 | cleanup() {
|
| 22 | rm -rf "${data}"
|
| 23 | rm -rf "${data}".old
|
| 24 | rm -rf "${data2}"
|
| 25 | rm -rf "${data2}".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_record_report() {
|
| 38 | echo
|
| 39 | echo "Record+report pipe test"
|
| 40 |
|
| 41 | task="perf"
|
| 42 | if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
|
| 43 | then
|
| 44 | echo "Record+report pipe test [Failed - cannot find the test file in the perf report #1]"
|
| 45 | err=1
|
| 46 | return
|
| 47 | fi
|
| 48 |
|
| 49 | if ! perf record -g -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
|
| 50 | then
|
| 51 | echo "Record+report pipe test [Failed - cannot find the test file in the perf report #2]"
|
| 52 | err=1
|
| 53 | return
|
| 54 | fi
|
| 55 |
|
| 56 | perf record -g -e task-clock:u -o - ${prog} > ${data}
|
| 57 | if ! perf report -i ${data} --task | grep -q ${task}
|
| 58 | then
|
| 59 | echo "Record+report pipe test [Failed - cannot find the test file in the perf report #3]"
|
| 60 | err=1
|
| 61 | return
|
| 62 | fi
|
| 63 |
|
| 64 | echo "Record+report pipe test [Success]"
|
| 65 | }
|
| 66 |
|
| 67 | test_inject_bids() {
|
| 68 | inject_opt=$1
|
| 69 |
|
| 70 | echo
|
| 71 | echo "Inject ${inject_opt} build-ids test"
|
| 72 |
|
| 73 | if ! perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt}| perf report -i - | grep -q ${sym}
|
| 74 | then
|
| 75 | echo "Inject build-ids test [Failed - cannot find noploop function in pipe #1]"
|
| 76 | err=1
|
| 77 | return
|
| 78 | fi
|
| 79 |
|
| 80 | if ! perf record -g -e task-clock:u -o - ${prog} | perf inject ${inject_opt} | perf report -i - | grep -q ${sym}
|
| 81 | then
|
| 82 | echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #2]"
|
| 83 | err=1
|
| 84 | return
|
| 85 | fi
|
| 86 |
|
| 87 | perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt} -o ${data}
|
| 88 | if ! perf report -i ${data} | grep -q ${sym}; then
|
| 89 | echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #3]"
|
| 90 | err=1
|
| 91 | return
|
| 92 | fi
|
| 93 |
|
| 94 | perf record -e task-clock:u -o ${data} ${prog}
|
| 95 | if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
|
| 96 | echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #4]"
|
| 97 | err=1
|
| 98 | return
|
| 99 | fi
|
| 100 |
|
| 101 | perf record -e task-clock:u -o - ${prog} > ${data}
|
| 102 | if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
|
| 103 | echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #5]"
|
| 104 | err=1
|
| 105 | return
|
| 106 | fi
|
| 107 |
|
| 108 | perf record -e task-clock:u -o - ${prog} > ${data}
|
| 109 | perf inject ${inject_opt} -i ${data} -o ${data2}
|
| 110 | if ! perf report -i ${data2} | grep -q ${sym}; then
|
| 111 | echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #6]"
|
| 112 | err=1
|
| 113 | return
|
| 114 | fi
|
| 115 |
|
| 116 | echo "Inject ${inject_opt} build-ids test [Success]"
|
| 117 | }
|
| 118 |
|
| 119 | test_record_report
|
| 120 | test_inject_bids -B
|
| 121 | test_inject_bids -b
|
| 122 | test_inject_bids --buildid-all
|
| 123 | test_inject_bids --mmap2-buildid-all
|
| 124 |
|
| 125 | cleanup
|
| 126 | exit $err
|
| 127 |
|