mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

perf test 70 takes a long time. One culprit is the output of command perf annotate. Per default enabled are - demangle symbol names - interleave source code with assembly code. Disable demangle of symbols and abort the annotation after the first 250 lines. This speeds up the test case considerable, for example on s390: Output before: # time perf test 70 70: perf annotate basic tests : Ok ..... real 2m7.467s user 1m26.869s sys 0m34.086s # Output after: # time perf test 70 70: perf annotate basic tests : Ok real 0m3.341s user 0m1.606s sys 0m0.362s # Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Reviewed-by: James Clark <james.clark@linaro.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: sumanthk@linux.ibm.com Link: https://lore.kernel.org/r/20240917085706.249691-1-tmricht@linux.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
88 lines
2.1 KiB
Bash
Executable file
88 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# perf annotate basic tests
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
set -e
|
|
|
|
shelldir=$(dirname "$0")
|
|
|
|
# shellcheck source=lib/perf_has_symbol.sh
|
|
. "${shelldir}"/lib/perf_has_symbol.sh
|
|
|
|
testsym="noploop"
|
|
|
|
skip_test_missing_symbol ${testsym}
|
|
|
|
err=0
|
|
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
|
|
perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX)
|
|
testprog="perf test -w noploop"
|
|
# disassembly format: "percent : offset: instruction (operands ...)"
|
|
disasm_regex="[0-9]*\.[0-9]* *: *\w*: *\w*"
|
|
|
|
cleanup() {
|
|
rm -rf "${perfdata}" "${perfout}"
|
|
rm -rf "${perfdata}".old
|
|
|
|
trap - EXIT TERM INT
|
|
}
|
|
|
|
trap_cleanup() {
|
|
echo "Unexpected signal in ${FUNCNAME[1]}"
|
|
cleanup
|
|
exit 1
|
|
}
|
|
trap trap_cleanup EXIT TERM INT
|
|
|
|
test_basic() {
|
|
echo "Basic perf annotate test"
|
|
if ! perf record -o "${perfdata}" ${testprog} 2> /dev/null
|
|
then
|
|
echo "Basic annotate [Failed: perf record]"
|
|
err=1
|
|
return
|
|
fi
|
|
|
|
# Generate the annotated output file
|
|
perf annotate --no-demangle -i "${perfdata}" --stdio 2> /dev/null | head -250 > "${perfout}"
|
|
|
|
# check if it has the target symbol
|
|
if ! grep "${testsym}" "${perfout}"
|
|
then
|
|
echo "Basic annotate [Failed: missing target symbol]"
|
|
err=1
|
|
return
|
|
fi
|
|
|
|
# check if it has the disassembly lines
|
|
if ! grep "${disasm_regex}" "${perfout}"
|
|
then
|
|
echo "Basic annotate [Failed: missing disasm output from default disassembler]"
|
|
err=1
|
|
return
|
|
fi
|
|
|
|
# check again with a target symbol name
|
|
if ! perf annotate --no-demangle -i "${perfdata}" "${testsym}" 2> /dev/null | \
|
|
head -250 | grep -m 3 "${disasm_regex}"
|
|
then
|
|
echo "Basic annotate [Failed: missing disasm output when specifying the target symbol]"
|
|
err=1
|
|
return
|
|
fi
|
|
|
|
# check one more with external objdump tool (forced by --objdump option)
|
|
if ! perf annotate --no-demangle -i "${perfdata}" --objdump=objdump 2> /dev/null | \
|
|
head -250 | grep -m 3 "${disasm_regex}"
|
|
then
|
|
echo "Basic annotate [Failed: missing disasm output from non default disassembler (using --objdump)]"
|
|
err=1
|
|
return
|
|
fi
|
|
echo "Basic annotate test [Success]"
|
|
}
|
|
|
|
test_basic
|
|
|
|
cleanup
|
|
exit $err
|