File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # perf kallsyms tests
3+ # SPDX-License-Identifier: GPL-2.0
4+
5+ err=0
6+
7+ test_kallsyms () {
8+ echo " Basic perf kallsyms test"
9+
10+ # Check if /proc/kallsyms is readable
11+ if [ ! -r /proc/kallsyms ]; then
12+ echo " Basic perf kallsyms test [Skipped: /proc/kallsyms not readable]"
13+ err=2
14+ return
15+ fi
16+
17+ # Use a symbol that is definitely a function and present in all kernels, e.g. schedule
18+ symbol=" schedule"
19+
20+ # Run perf kallsyms
21+ # It prints "address symbol_name"
22+ output=$( perf kallsyms $symbol 2>&1 )
23+ ret=$?
24+
25+ if [ $ret -ne 0 ] || [ -z " $output " ]; then
26+ # If empty or failed, it might be due to permissions (kptr_restrict)
27+ # Check if we can grep the symbol from /proc/kallsyms directly
28+ if grep -q " $symbol " /proc/kallsyms 2> /dev/null; then
29+ # If it's in /proc/kallsyms but perf kallsyms returned empty/error,
30+ # it likely means perf couldn't parse it or access it correctly (e.g. kptr_restrict=2).
31+ echo " Basic perf kallsyms test [Skipped: $symbol found in /proc/kallsyms but perf kallsyms failed (output: '$output ')]"
32+ err=2
33+ return
34+ else
35+ echo " Basic perf kallsyms test [Skipped: $symbol not found in /proc/kallsyms]"
36+ err=2
37+ return
38+ fi
39+ fi
40+
41+ if echo " $output " | grep -q " not found" ; then
42+ echo " Basic perf kallsyms test [Failed: output '$output ' does not contain $symbol ]"
43+ err=1
44+ return
45+ fi
46+
47+ if perf kallsyms ErlingHaaland | grep -vq " not found" ; then
48+ echo " Basic perf kallsyms test [Failed: ErlingHaaland found in the output]"
49+ err=1
50+ return
51+ fi
52+ echo " Basic perf kallsyms test [Success]"
53+ }
54+
55+ test_kallsyms
56+ exit $err
You can’t perform that action at this time.
0 commit comments