2022-04-14 04:46:42 +03:00
|
|
|
#!/bin/sh
|
|
|
|
# perf record tests
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
err=0
|
2022-05-05 21:25:05 +03:00
|
|
|
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
rm -f ${perfdata}
|
|
|
|
rm -f ${perfdata}.old
|
|
|
|
trap - exit term int
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_cleanup() {
|
|
|
|
cleanup
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
trap trap_cleanup exit term int
|
|
|
|
|
2022-04-14 04:46:42 +03:00
|
|
|
test_per_thread() {
|
|
|
|
echo "Basic --per-thread mode test"
|
2022-10-20 20:26:36 +03:00
|
|
|
if ! perf record -o /dev/null --quiet true 2> /dev/null
|
2022-05-05 21:25:05 +03:00
|
|
|
then
|
2022-10-20 20:26:36 +03:00
|
|
|
echo "Per-thread record [Skipped event not supported]"
|
2022-05-05 21:25:05 +03:00
|
|
|
if [ $err -ne 1 ]
|
|
|
|
then
|
|
|
|
err=2
|
|
|
|
fi
|
|
|
|
return
|
|
|
|
fi
|
2022-10-20 20:26:36 +03:00
|
|
|
if ! perf record --per-thread -o ${perfdata} true 2> /dev/null
|
2022-05-05 21:25:05 +03:00
|
|
|
then
|
2022-10-20 20:26:36 +03:00
|
|
|
echo "Per-thread record [Failed record]"
|
2022-05-05 21:25:05 +03:00
|
|
|
err=1
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if ! perf report -i ${perfdata} -q | egrep -q true
|
|
|
|
then
|
|
|
|
echo "Per-thread record [Failed missing output]"
|
|
|
|
err=1
|
|
|
|
return
|
|
|
|
fi
|
2022-04-14 04:46:42 +03:00
|
|
|
echo "Basic --per-thread mode test [Success]"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_register_capture() {
|
|
|
|
echo "Register capture test"
|
|
|
|
if ! perf list | egrep -q 'br_inst_retired.near_call'
|
|
|
|
then
|
2022-10-20 20:26:36 +03:00
|
|
|
echo "Register capture test [Skipped missing event]"
|
2022-05-05 21:25:05 +03:00
|
|
|
if [ $err -ne 1 ]
|
|
|
|
then
|
|
|
|
err=2
|
|
|
|
fi
|
2022-04-14 04:46:42 +03:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
if ! perf record --intr-regs=\? 2>&1 | egrep -q 'available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15'
|
|
|
|
then
|
|
|
|
echo "Register capture test [Skipped missing registers]"
|
|
|
|
return
|
|
|
|
fi
|
2022-09-27 08:15:13 +03:00
|
|
|
if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
|
2022-04-14 04:46:42 +03:00
|
|
|
-c 1000 --per-thread true 2> /dev/null \
|
|
|
|
| perf script -F ip,sym,iregs -i - 2> /dev/null \
|
|
|
|
| egrep -q "DI:"
|
|
|
|
then
|
|
|
|
echo "Register capture test [Failed missing output]"
|
|
|
|
err=1
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
echo "Register capture test [Success]"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_per_thread
|
|
|
|
test_register_capture
|
2022-05-05 21:25:05 +03:00
|
|
|
|
|
|
|
cleanup
|
2022-04-14 04:46:42 +03:00
|
|
|
exit $err
|