[PATCH v1 5/7] perf test: Enhance annotate test coverage and isolate config

From: Ian Rogers

Date: Tue Jun 09 2026 - 01:21:18 EST


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 <irogers@xxxxxxxxxx>
---
tools/perf/tests/shell/annotate.sh | 56 ++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh
index 689de58e9238..d3bafa7e3db5 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
@@ -23,6 +25,7 @@ disasm_regex="[0-9]*\.[0-9]* *: *\w*: *\w*"
cleanup() {
rm -rf "${perfdata}" "${perfout}"
rm -rf "${perfdata}".old
+ rm -f /tmp/__perf_test.config.*

trap - EXIT TERM INT
}
@@ -106,8 +109,61 @@ test_basic() {
echo "${mode} annotate test [Success]"
}

+test_disassembler() {
+ disassembler=$1
+ feature=$2
+
+ 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 [ "x${ret}" != "x0" ]
+ then
+ echo "annotate with ${disassembler} [Failed: perf annotate error]"
+ err=1
+ return 1
+ 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 1
+ 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 1
+ fi
+
+ echo "annotate with ${disassembler} [Success]"
+ return 0
+}
+
test_basic Basic
test_basic Pipe

+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.1064.gd145956f57-goog