| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
|
| 6 | |
| 7 | |
| 8 | perfdata="perf.data"
|
| 9 | csv="$tmpdir/csv"
|
| 10 | csvsummary="$tmpdir/csvsummary"
|
| 11 | err=0
|
| 12 |
|
| 13 | |
| 14 | perfdir=$(dirname "$0")/../..
|
| 15 | if [ -e "$perfdir/scripts/python/Perf-Trace-Util" ]; then
|
| 16 | export PERF_EXEC_PATH=$perfdir
|
| 17 | fi
|
| 18 |
|
| 19 | |
| 20 | export ASAN_OPTIONS=detect_leaks=0
|
| 21 |
|
| 22 | cleanup() {
|
| 23 | rm -f "${perfdata}"
|
| 24 | rm -f "${perfdata}".old
|
| 25 | rm -rf "$tmpdir"
|
| 26 |
|
| 27 | trap - exit term int
|
| 28 | }
|
| 29 |
|
| 30 | trap_cleanup() {
|
| 31 | cleanup
|
| 32 | exit 1
|
| 33 | }
|
| 34 | trap trap_cleanup exit term int
|
| 35 |
|
| 36 | report() {
|
| 37 | if [ "$1" = 0 ]; then
|
| 38 | echo "PASS: \"$2\""
|
| 39 | else
|
| 40 | echo "FAIL: \"$2\" Error message: \"$3\""
|
| 41 | err=1
|
| 42 | fi
|
| 43 | }
|
| 44 |
|
| 45 | check_exec_0() {
|
| 46 | if [ $? != 0 ]; then
|
| 47 | report 1 "invocation of $1 command failed"
|
| 48 | fi
|
| 49 | }
|
| 50 |
|
| 51 | find_str_or_fail() {
|
| 52 | grep -q "$1" "$2"
|
| 53 | if [ "$?" != 0 ]; then
|
| 54 | report 1 "$3" "Failed to find required string:'${1}'."
|
| 55 | else
|
| 56 | report 0 "$3"
|
| 57 | fi
|
| 58 | }
|
| 59 |
|
| 60 | |
| 61 | skip_no_probe_record_support() {
|
| 62 | perf check feature -q libtraceevent && return 0
|
| 63 | return 2
|
| 64 | }
|
| 65 |
|
| 66 | prepare_perf_data() {
|
| 67 | |
| 68 | perf record -e sched:sched_switch -a -o "${perfdata}" -- sleep 1 > /dev/null 2>&1
|
| 69 | |
| 70 | if [ ! -e "${perfdata}" ]; then
|
| 71 | printf "FAIL: perf record failed to create \"${perfdata}\" \n"
|
| 72 | return 1
|
| 73 | fi
|
| 74 | }
|
| 75 |
|
| 76 | |
| 77 | test_basic() {
|
| 78 | out="$tmpdir/perf.out"
|
| 79 | perf script report task-analyzer > "$out"
|
| 80 | check_exec_0 "perf script report task-analyzer"
|
| 81 | find_str_or_fail "Comm" "$out" "${FUNCNAME[0]}"
|
| 82 | }
|
| 83 |
|
| 84 | test_ns_rename(){
|
| 85 | out="$tmpdir/perf.out"
|
| 86 | perf script report task-analyzer --ns --rename-comms-by-tids 0:random > "$out"
|
| 87 | check_exec_0 "perf script report task-analyzer --ns --rename-comms-by-tids 0:random"
|
| 88 | find_str_or_fail "Comm" "$out" "${FUNCNAME[0]}"
|
| 89 | }
|
| 90 |
|
| 91 | test_ms_filtertasks_highlight(){
|
| 92 | out="$tmpdir/perf.out"
|
| 93 | perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf \
|
| 94 | > "$out"
|
| 95 | check_exec_0 "perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf"
|
| 96 | find_str_or_fail "Comm" "$out" "${FUNCNAME[0]}"
|
| 97 | }
|
| 98 |
|
| 99 | test_extended_times_timelimit_limittasks() {
|
| 100 | out="$tmpdir/perf.out"
|
| 101 | perf script report task-analyzer --extended-times --time-limit :99999 \
|
| 102 | --limit-to-tasks perf > "$out"
|
| 103 | check_exec_0 "perf script report task-analyzer --extended-times --time-limit :99999 --limit-to-tasks perf"
|
| 104 | find_str_or_fail "Out-Out" "$out" "${FUNCNAME[0]}"
|
| 105 | }
|
| 106 |
|
| 107 | test_summary() {
|
| 108 | out="$tmpdir/perf.out"
|
| 109 | perf script report task-analyzer --summary > "$out"
|
| 110 | check_exec_0 "perf script report task-analyzer --summary"
|
| 111 | find_str_or_fail "Summary" "$out" "${FUNCNAME[0]}"
|
| 112 | }
|
| 113 |
|
| 114 | test_summaryextended() {
|
| 115 | out="$tmpdir/perf.out"
|
| 116 | perf script report task-analyzer --summary-extended > "$out"
|
| 117 | check_exec_0 "perf script report task-analyzer --summary-extended"
|
| 118 | find_str_or_fail "Inter Task Times" "$out" "${FUNCNAME[0]}"
|
| 119 | }
|
| 120 |
|
| 121 | test_summaryonly() {
|
| 122 | out="$tmpdir/perf.out"
|
| 123 | perf script report task-analyzer --summary-only > "$out"
|
| 124 | check_exec_0 "perf script report task-analyzer --summary-only"
|
| 125 | find_str_or_fail "Summary" "$out" "${FUNCNAME[0]}"
|
| 126 | }
|
| 127 |
|
| 128 | test_extended_times_summary_ns() {
|
| 129 | out="$tmpdir/perf.out"
|
| 130 | perf script report task-analyzer --extended-times --summary --ns > "$out"
|
| 131 | check_exec_0 "perf script report task-analyzer --extended-times --summary --ns"
|
| 132 | find_str_or_fail "Out-Out" "$out" "${FUNCNAME[0]}"
|
| 133 | find_str_or_fail "Summary" "$out" "${FUNCNAME[0]}"
|
| 134 | }
|
| 135 |
|
| 136 | test_csv() {
|
| 137 | perf script report task-analyzer --csv "${csv}" > /dev/null
|
| 138 | check_exec_0 "perf script report task-analyzer --csv ${csv}"
|
| 139 | find_str_or_fail "Comm;" "${csv}" "${FUNCNAME[0]}"
|
| 140 | }
|
| 141 |
|
| 142 | test_csv_extended_times() {
|
| 143 | perf script report task-analyzer --csv "${csv}" --extended-times > /dev/null
|
| 144 | check_exec_0 "perf script report task-analyzer --csv ${csv} --extended-times"
|
| 145 | find_str_or_fail "Out-Out;" "${csv}" "${FUNCNAME[0]}"
|
| 146 | }
|
| 147 |
|
| 148 | test_csvsummary() {
|
| 149 | perf script report task-analyzer --csv-summary "${csvsummary}" > /dev/null
|
| 150 | check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary}"
|
| 151 | find_str_or_fail "Comm;" "${csvsummary}" "${FUNCNAME[0]}"
|
| 152 | }
|
| 153 |
|
| 154 | test_csvsummary_extended() {
|
| 155 | perf script report task-analyzer --csv-summary "${csvsummary}" --summary-extended \
|
| 156 | >/dev/null
|
| 157 | check_exec_0 "perf script report task-analyzer --csv-summary ${csvsummary} --summary-extended"
|
| 158 | find_str_or_fail "Out-Out;" "${csvsummary}" "${FUNCNAME[0]}"
|
| 159 | }
|
| 160 |
|
| 161 | skip_no_probe_record_support
|
| 162 | err=$?
|
| 163 | if [ $err -ne 0 ]; then
|
| 164 | echo "WARN: Skipping tests. No libtraceevent support"
|
| 165 | cleanup
|
| 166 | exit $err
|
| 167 | fi
|
| 168 | prepare_perf_data
|
| 169 | test_basic
|
| 170 | test_ns_rename
|
| 171 | test_ms_filtertasks_highlight
|
| 172 | test_extended_times_timelimit_limittasks
|
| 173 | test_summary
|
| 174 | test_summaryextended
|
| 175 | test_summaryonly
|
| 176 | test_extended_times_summary_ns
|
| 177 | test_csv
|
| 178 | test_csvsummary
|
| 179 | test_csv_extended_times
|
| 180 | test_csvsummary_extended
|
| 181 | cleanup
|
| 182 | exit $err
|