[PATCH v2 5/7] perf test: Enhance annotate test coverage and isolate config
From: Ian Rogers
Date: Tue Jun 09 2026 - 03:13:27 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 | 54 ++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh
index 689de58e9238..2c06d2670cb1 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,60 @@ 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 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
+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