[PATCH perf-tools-next v5 4/4] perf tests: Add shell test for kernel symbol beautifier
From: Aaron Tomlin
Date: Sat Aug 22 2026 - 17:38:10 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 | 43 +++++++++++++++++++
1 file changed, 43 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..45c803338d4c
--- /dev/null
+++ b/tools/perf/tests/shell/trace_ksym_beautifier.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# perf trace kernel symbol beautifier tests
+# SPDX-License-Identifier: GPL-2.0
+
+err=0
+
+# shellcheck source=lib/probe.sh
+. "$(dirname "$0")"/lib/probe.sh
+skip_if_no_perf_trace || exit 2
+[ "$(id -u)" = 0 ] || exit 2
+
+test_ksym_kallsyms() {
+ echo "Testing perf trace kernel symbol beautifier (default kallsyms)"
+ output="$(perf trace -e kmem:kmalloc --max-events=1 -- true 2>&1)"
+ if ! echo "$output" | grep -q -E "call_site: [a-zA-Z_][a-zA-Z0-9_]*" || echo "$output" | grep -q -E "call_site: 0x[0-9a-fA-F]+"
+ then
+ printf "Default kallsyms function symbolization failed, output:\n%s\n" "$output"
+ 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
+
+ output="$(perf trace -e timer:hrtimer_start --force-btf --max-events=1 -- sleep 0.01 2>&1)"
+ if ! echo "$output" | grep -q -E "function: [a-zA-Z_][a-zA-Z0-9_]*" || echo "$output" | grep -q -E "function: 0x[0-9a-fA-F]+"
+ then
+ printf "BTF function symbolization failed, output:\n%s\n" "$output"
+ err=1
+ fi
+}
+
+test_ksym_kallsyms
+
+if [ $err = 0 ]; then
+ test_ksym_btf
+fi
+
+exit $err
--
2.55.0