3 # SPDX-License-Identifier: GPL-2.0
7 shelldir=$(dirname "$0")
8 # shellcheck source=lib/waiting.sh
9 . "${shelldir}"/lib/waiting.sh
12 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
13 testprog="perf test -w thloop"
18 rm -rf "${perfdata}".old
27 trap trap_cleanup EXIT TERM INT
30 echo "Basic --per-thread mode test"
31 if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
33 echo "Per-thread record [Skipped event not supported]"
36 if ! perf record --per-thread -o "${perfdata}" ${testprog} 2> /dev/null
38 echo "Per-thread record [Failed record]"
42 if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
44 echo "Per-thread record [Failed missing output]"
49 # run the test program in background (for 30 seconds)
55 wait_for_threads ${TESTPID} 2
56 perf record -p "${TESTPID}" --per-thread -o "${perfdata}" sleep 1 2> /dev/null
59 if [ ! -e "${perfdata}" ]
61 echo "Per-thread record [Failed record -p]"
65 if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
67 echo "Per-thread record [Failed -p missing output]"
72 echo "Basic --per-thread mode test [Success]"
75 test_register_capture() {
76 echo "Register capture test"
77 if ! perf list | grep -q 'br_inst_retired.near_call'
79 echo "Register capture test [Skipped missing event]"
82 if ! perf record --intr-regs=\? 2>&1 | grep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
84 echo "Register capture test [Skipped missing registers]"
87 if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call \
88 -c 1000 --per-thread ${testprog} 2> /dev/null \
89 | perf script -F ip,sym,iregs -i - 2> /dev/null \
92 echo "Register capture test [Failed missing output]"
96 echo "Register capture test [Success]"
100 echo "Basic --system-wide mode test"
101 if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
103 echo "System-wide record [Skipped not supported]"
106 if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
108 echo "System-wide record [Failed missing output]"
112 if ! perf record -aB --synth=no -e cpu-clock,cs --threads=cpu \
113 -o "${perfdata}" ${testprog} 2> /dev/null
115 echo "System-wide record [Failed record --threads option]"
119 if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
121 echo "System-wide record [Failed --threads missing output]"
125 echo "Basic --system-wide mode test [Success]"
129 echo "Basic target workload test"
130 if ! perf record -o "${perfdata}" ${testprog} 2> /dev/null
132 echo "Workload record [Failed record]"
136 if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
138 echo "Workload record [Failed missing output]"
142 if ! perf record -e cpu-clock,cs --threads=package \
143 -o "${perfdata}" ${testprog} 2> /dev/null
145 echo "Workload record [Failed record --threads option]"
149 if ! perf report -i "${perfdata}" -q | grep -q "${testsym}"
151 echo "Workload record [Failed --threads missing output]"
155 echo "Basic target workload test [Success]"
159 test_register_capture