| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | |
| 6 |
|
| 7 | |
| 8 | . "$(dirname $0)"/lib/probe.sh
|
| 9 |
|
| 10 | skip_if_no_perf_trace || exit 2
|
| 11 | [ "$(id -u)" = 0 ] || exit 2
|
| 12 |
|
| 13 | OUTPUT=$(mktemp /tmp/perf_trace_test.XXXXX)
|
| 14 |
|
| 15 | test_perf_trace() {
|
| 16 | args=$1
|
| 17 | workload="cat /dev/null"
|
| 18 | search="^\s*(open|read|close).*[0-9]+%$"
|
| 19 |
|
| 20 | echo "testing: perf trace ${args} -- ${workload}"
|
| 21 | perf trace ${args} -- ${workload} >${OUTPUT} 2>&1
|
| 22 | if [ $? -ne 0 ]; then
|
| 23 | echo "Error: perf trace ${args} failed unexpectedly"
|
| 24 | cat ${OUTPUT}
|
| 25 | rm -f ${OUTPUT}
|
| 26 | exit 1
|
| 27 | fi
|
| 28 |
|
| 29 | count=$(grep -E -c -m 3 "${search}" ${OUTPUT})
|
| 30 | if [ "${count}" != "3" ]; then
|
| 31 | echo "Error: cannot find enough pattern ${search} in the output"
|
| 32 | cat ${OUTPUT}
|
| 33 | rm -f ${OUTPUT}
|
| 34 | exit 1
|
| 35 | fi
|
| 36 | }
|
| 37 |
|
| 38 | |
| 39 | test_perf_trace "-s"
|
| 40 |
|
| 41 | |
| 42 | test_perf_trace "-S"
|
| 43 |
|
| 44 | |
| 45 | test_perf_trace "-s --summary-mode=thread"
|
| 46 |
|
| 47 | |
| 48 | test_perf_trace "-S --summary-mode=total"
|
| 49 |
|
| 50 | |
| 51 | test_perf_trace "-as --summary-mode=thread --no-bpf-summary"
|
| 52 |
|
| 53 | |
| 54 | test_perf_trace "-as --summary-mode=total --no-bpf-summary"
|
| 55 |
|
| 56 | if ! perf check feature -q bpf; then
|
| 57 | echo "Skip --bpf-summary tests as perf built without libbpf"
|
| 58 | rm -f ${OUTPUT}
|
| 59 | exit 2
|
| 60 | fi
|
| 61 |
|
| 62 | |
| 63 | test_perf_trace "-as --summary-mode=thread --bpf-summary"
|
| 64 |
|
| 65 | |
| 66 | test_perf_trace "-as --summary-mode=total --bpf-summary"
|
| 67 |
|
| 68 | |
| 69 | test_perf_trace "-aS --summary-mode=total --bpf-summary"
|
| 70 |
|
| 71 | |
| 72 | test_perf_trace "-as --summary-mode=cgroup --bpf-summary"
|
| 73 |
|
| 74 | |
| 75 | test_perf_trace "-aS --summary-mode=cgroup --bpf-summary"
|
| 76 |
|
| 77 | rm -f ${OUTPUT}
|