Files
cubelinux-kernel/tools/perf/tests/shell/kallsyms.sh
T
Greg Kroah-Hartman 598cf27219 Linux 6.19.3
Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com>
Tested-by: Peter Schneider <pschneider1968@googlemail.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Salvatore Bonaccorso <carnil@debian.org>
Tested-by: Brett A C Sheffield <bacs@librecast.net>
Tested-by: Mark Brown <broonie@kernel.org>
Tested-by: Luna Jernberg <droidbittin@gmail.com>
Tested-by: Ronald Warsow <rwarsow@gmx.de>
Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
Tested-by: Ron Economos <re@w6rz.net>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-02-19 16:33:27 +01:00

57 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# perf kallsyms tests
# SPDX-License-Identifier: GPL-2.0
err=0
test_kallsyms() {
echo "Basic perf kallsyms test"
# Check if /proc/kallsyms is readable
if [ ! -r /proc/kallsyms ]; then
echo "Basic perf kallsyms test [Skipped: /proc/kallsyms not readable]"
err=2
return
fi
# Use a symbol that is definitely a function and present in all kernels, e.g. schedule
symbol="schedule"
# Run perf kallsyms
# It prints "address symbol_name"
output=$(perf kallsyms $symbol 2>&1)
ret=$?
if [ $ret -ne 0 ] || [ -z "$output" ]; then
# If empty or failed, it might be due to permissions (kptr_restrict)
# Check if we can grep the symbol from /proc/kallsyms directly
if grep -q "$symbol" /proc/kallsyms 2>/dev/null; then
# If it's in /proc/kallsyms but perf kallsyms returned empty/error,
# it likely means perf couldn't parse it or access it correctly (e.g. kptr_restrict=2).
echo "Basic perf kallsyms test [Skipped: $symbol found in /proc/kallsyms but perf kallsyms failed (output: '$output')]"
err=2
return
else
echo "Basic perf kallsyms test [Skipped: $symbol not found in /proc/kallsyms]"
err=2
return
fi
fi
if echo "$output" | grep -q "not found"; then
echo "Basic perf kallsyms test [Failed: output '$output' does not contain $symbol]"
err=1
return
fi
if perf kallsyms ErlingHaaland | grep -vq "not found"; then
echo "Basic perf kallsyms test [Failed: ErlingHaaland found in the output]"
err=1
return
fi
echo "Basic perf kallsyms test [Success]"
}
test_kallsyms
exit $err