mirror of
https://github.com/torvalds/linux.git
synced 2026-11-10 17:11:02 +01:00
perf tests: Add shell test for kernel symbol beautifier
Add a dedicated shell test script, trace_ksym_beautifier.sh, to verify that 'perf trace' properly symbolises kernel virtual addresses (e.g. call_site in kmem:kmalloc) and function pointer fields (e.g. function in timer:hrtimer_start) using the kernel symbol beautifier (SCA_KSYM). Committer testing: root@number:~# perf test "kernel sym" 145: perf trace kernel symbol beautifier tests : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@number:~# perf test -vv "kernel sym" 145: perf trace kernel symbol beautifier tests: ---- start ---- test child forked, pid 920749 Testing perf trace kernel symbol beautifier (call_site) Testing perf trace kernel symbol beautifier (function pointer) ---- end(0) ---- 145: perf trace kernel symbol beautifier tests : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@number:~# perf test -vvv "kernel sym" 145: perf trace kernel symbol beautifier tests: ---- start ---- test child forked, pid 920784 Testing perf trace kernel symbol beautifier (call_site) Testing perf trace kernel symbol beautifier (function pointer) ---- end(0) ---- 145: perf trace kernel symbol beautifier tests : Ok === Test Summary === Passed main tests : 1 Passed subtests : 0 Skipped tests : 0 Failed tests : 0 root@number:~# Signed-off-by: Aaron Tomlin <atomlin@atomlin.com> Reviewed-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c6dd616181
commit
35770d96fc
38
tools/perf/tests/shell/trace_ksym_beautifier.sh
Executable file
38
tools/perf/tests/shell/trace_ksym_beautifier.sh
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/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_call_site() {
|
||||
echo "Testing perf trace kernel symbol beautifier (call_site)"
|
||||
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 "Call site kernel symbol beautification failed, output:\n%s\n" "$output"
|
||||
err=1
|
||||
fi
|
||||
}
|
||||
|
||||
test_ksym_function_ptr() {
|
||||
echo "Testing perf trace kernel symbol beautifier (function pointer)"
|
||||
output="$(perf trace -e timer:hrtimer_start --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 "Function pointer kernel symbol beautification failed, output:\n%s\n" "$output"
|
||||
err=1
|
||||
fi
|
||||
}
|
||||
|
||||
test_ksym_call_site
|
||||
|
||||
if [ $err = 0 ]; then
|
||||
test_ksym_function_ptr
|
||||
fi
|
||||
|
||||
exit $err
|
||||
Loading…
Reference in New Issue
Block a user