[PATCH perf-tools-next v2 4/4] perf tests: Add shell test for kernel symbol beautifier
From: Aaron Tomlin
Date: Sun Aug 16 2026 - 16:59:56 EST
Add a dedicated shell test script, trace_ksym_beautifier.sh, to verify
that 'perf trace' properly symbolises kernel virtual addresses and
function pointers using both the default kallsyms beautifier (SCA_KSYM)
and BTF type routing i.e., --force-btf.
Signed-off-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
---
.../perf/tests/shell/trace_ksym_beautifier.sh | 52 +++++++++++++++++++
1 file changed, 52 insertions(+)
create mode 100755 tools/perf/tests/shell/trace_ksym_beautifier.sh
diff --git a/tools/perf/tests/shell/trace_ksym_beautifier.sh b/tools/perf/tests/shell/trace_ksym_beautifier.sh
new file mode 100755
index 000000000000..2916f78503f7
--- /dev/null
+++ b/tools/perf/tests/shell/trace_ksym_beautifier.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# perf trace kernel symbol beautifier tests
+# SPDX-License-Identifier: GPL-2.0
+
+err=0
+OUTPUT=$(mktemp /tmp/perf_trace_test.XXXXX)
+
+# shellcheck source=lib/probe.sh
+. "$(dirname $0)"/lib/probe.sh
+skip_if_no_perf_trace || exit 2
+[ "$(id -u)" = 0 ] || exit 2
+
+cleanup() {
+ rm -f ${OUTPUT}
+}
+
+trap cleanup EXIT TERM INT HUP
+
+test_ksym_kallsyms() {
+ echo "Testing perf trace kernel symbol beautifier (default kallsyms)"
+ perf trace -e kmem:kmalloc --max-events=1 > ${OUTPUT} 2>&1
+ if ! grep -q -E "call_site: [a-zA-Z0-9_]+" ${OUTPUT}
+ then
+ printf "Default kallsyms function symbolization failed, output:\n$(cat ${OUTPUT})\n"
+ err=1
+ fi
+}
+
+test_ksym_btf() {
+ echo "Testing perf trace kernel symbol beautifier (BTF)"
+ if [ ! -f /sys/kernel/btf/vmlinux ]; then
+ echo "Skipping BTF test due to missing vmlinux BTF"
+ return
+ fi
+
+ perf trace -e kmem:kmalloc --force-btf --max-events=1 > ${OUTPUT} 2>&1
+ if ! grep -q -E "call_site: [a-zA-Z0-9_]+" ${OUTPUT}
+ then
+ printf "BTF function symbolization failed, output:\n$(cat ${OUTPUT})\n"
+ err=1
+ fi
+}
+
+test_ksym_kallsyms
+
+if [ $err = 0 ]; then
+ test_ksym_btf
+fi
+
+cleanup
+
+exit $err
--
2.55.0