1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/tools/perf/tests/shell/annotate.sh
Thomas Richter 658a8805cb perf test: Speed up test case 70 annotate basic tests
On some s390 linux machine (mostly older models) and with debug
packages installed, the test case 'perf annotate basic tests' runs
for some longer time.
Speed up the test and save the output of command perf annotate
in a temporary file. This is used to perform pattern matching via
grep command. This saves on invocation of perf annotate which
runs for some time.

Output before:
 # time bash -x tests/shell/annotate.sh >/dev/null 2>&1; echo EXIT CODE $?

 real   4m35.543s
 user   3m19.442s
 sys    1m14.322s
 EXIT CODE 0
 #
Output after:
 # time bash -x tests/shell/annotate.sh >/dev/null 2>&1; echo EXIT CODE $?

 real   2m2.881s
 user   1m30.980s
 sys    0m30.684s
 EXIT CODE 0
 #

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: gor@linux.ibm.com
Cc: hca@linux.ibm.com
Cc: sumanthk@linux.ibm.com
Cc: svens@linux.ibm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240607054352.2774936-1-tmricht@linux.ibm.com
2024-06-07 13:06:44 -07:00

87 lines
2 KiB
Bash
Executable file

#!/bin/sh
# 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() {
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 -i "${perfdata}" --stdio 2> /dev/null > "${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 -i "${perfdata}" "${testsym}" 2> /dev/null | \
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 -i "${perfdata}" --objdump=objdump 2> /dev/null | \
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