Update the annotate.sh shell test to test different disassembler backends (objdump, llvm, capstone, libasm) utilizing the new --disassembler command-line option. Isolate the test script from host environment pollution by exporting PERF_CONFIG=/dev/null at the start of the script, ensuring it runs hermetically. Assisted-by: Antigravity:Google Gemini 3.5-flash Signed-off-by: Ian Rogers --- tools/perf/tests/shell/annotate.sh | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh index 689de58e9238..eae6a46a247b 100755 --- a/tools/perf/tests/shell/annotate.sh +++ b/tools/perf/tests/shell/annotate.sh @@ -4,6 +4,8 @@ set -e +export PERF_CONFIG=/dev/null + shelldir=$(dirname "$0") # shellcheck source=lib/perf_has_symbol.sh @@ -106,8 +108,66 @@ test_basic() { echo "${mode} annotate test [Success]" } +test_disassembler() { + disassembler=$1 + feature=$2 + local ret=0 + + if [ -n "${feature}" ] + then + if ! perf check feature "${feature}" > /dev/null 2>&1 + then + echo "Skip test for ${disassembler} (feature ${feature} not supported)" + return 0 + fi + fi + + echo "Test annotate with disassembler: ${disassembler}" + + perf annotate --no-demangle -i "${perfdata}" --stdio \ + --percent-limit 10 --disassembler "${disassembler}" \ + 2> /dev/null > "${perfout}" || ret=$? + + if [ "${ret}" -ne 0 ] + then + echo "annotate with ${disassembler} [Failed: perf annotate error]" + err=1 + return 0 + fi + + # check if it has the target symbol + if ! grep -q "${testsym}" "${perfout}" + then + echo "annotate with ${disassembler} [Failed: missing target symbol]" + err=1 + return 0 + fi + + # check if it has the disassembly lines + if ! grep -q "${disasm_regex}" "${perfout}" + then + echo "annotate with ${disassembler} [Failed: missing disasm output]" + err=1 + return 0 + fi + + echo "annotate with ${disassembler} [Success]" + return 0 +} + test_basic Basic test_basic Pipe +# Restore perfdata to a regular format for disassembler tests +perf record -o "${perfdata}" ${testprog} > /dev/null 2>&1 + +if [ "${err}" -eq 0 ] +then + test_disassembler "objdump" "" + test_disassembler "llvm" "libLLVM" + test_disassembler "capstone" "libcapstone" + test_disassembler "libasm" "libasm" +fi + cleanup exit $err -- 2.54.0.1099.g489fc7bff1-goog