| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | set -e
|
| 6 |
|
| 7 | err=0
|
| 8 | perfdata=$(mktemp /tmp/__perf_timechart_test.perf.data.XXXXX)
|
| 9 | output=$(mktemp /tmp/__perf_timechart_test.output.XXXXX.svg)
|
| 10 |
|
| 11 | cleanup() {
|
| 12 | rm -f "${perfdata}"*
|
| 13 | rm -f "${output}"
|
| 14 | trap - EXIT TERM INT
|
| 15 | }
|
| 16 |
|
| 17 | trap_cleanup() {
|
| 18 | echo "Unexpected signal in ${FUNCNAME[1]}"
|
| 19 | cleanup
|
| 20 | exit 1
|
| 21 | }
|
| 22 | trap trap_cleanup EXIT TERM INT
|
| 23 |
|
| 24 | test_timechart() {
|
| 25 | NAME=$1
|
| 26 | OPTION=$2
|
| 27 |
|
| 28 | echo "perf timechart ${NAME} test"
|
| 29 |
|
| 30 | |
| 31 | |
| 32 | |
| 33 | if ! perf timechart record -o "${perfdata}" ${OPTION} true > /dev/null 2>&1; then
|
| 34 | echo "perf timechart ${NAME} test [Skipped: perf timechart record failed (permissions/events?)]"
|
| 35 | return
|
| 36 | fi
|
| 37 |
|
| 38 | |
| 39 | if ! perf timechart -i "${perfdata}" -o "${output}" > /dev/null 2>&1; then
|
| 40 | echo "perf timechart ${NAME} test [Failed: perf timechart command failed]"
|
| 41 | err=1
|
| 42 | return
|
| 43 | fi
|
| 44 |
|
| 45 | |
| 46 | if [ ! -s "${output}" ]; then
|
| 47 | echo "perf timechart ${NAME} test [Failed: output file is empty or missing]"
|
| 48 | err=1
|
| 49 | return
|
| 50 | fi
|
| 51 |
|
| 52 | |
| 53 | if ! grep -q "svg" "${output}"; then
|
| 54 | echo "perf timechart ${NAME} test [Failed: output doesn't look like SVG]"
|
| 55 | err=1
|
| 56 | return
|
| 57 | fi
|
| 58 |
|
| 59 | echo "perf timechart ${NAME} test [Success]"
|
| 60 | }
|
| 61 |
|
| 62 | if ! perf check feature -q libtraceevent ; then
|
| 63 | echo "perf timechart is not supported. Skip."
|
| 64 | cleanup
|
| 65 | exit 2
|
| 66 | fi
|
| 67 |
|
| 68 | test_timechart "Basic" ""
|
| 69 | test_timechart "IO-only" "-I"
|
| 70 | test_timechart "Backtrace" "-g"
|
| 71 |
|
| 72 | cleanup
|
| 73 | exit $err
|