perf test cs-etm: Skip if not root

Use the common idiom for skipping tests if not running as root, which is
required for these tests.

Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Amir Ayupov <aaupov@meta.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Mike Leach <mike.leach@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paschalis Mpeis <Paschalis.Mpeis@arm.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
James Clark 2026-06-09 15:40:17 +01:00 committed by Arnaldo Carvalho de Melo
parent f8fabdccde
commit ac390ed343
2 changed files with 9 additions and 3 deletions

View File

@ -20,6 +20,12 @@ skip_if_no_cs_etm_event() {
skip_if_no_cs_etm_event || exit 2
if [ "$(id -u)" != 0 ]; then
# Requires root for -C and system wide tests
echo "[Skip] No root permission"
exit 2
fi
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
file=$(mktemp /tmp/temporary_file.XXXXX)

View File

@ -42,7 +42,7 @@ sep="\s\|\s"
branch_search="\sbl${sep}b${sep}b.ne${sep}b.eq${sep}cbz\s"
## Test kernel ##
if [ -e /proc/kcore ]; then
if [ "$(id -u)" == 0 ] && [ -e /proc/kcore ]; then
echo "Testing kernel disassembly"
perf record -o ${perfdata} -e cs_etm//k --kcore -- touch $file > /dev/null 2>&1
perf script -i ${perfdata} -s python:${script_path} -- \
@ -50,8 +50,8 @@ if [ -e /proc/kcore ]; then
grep -q -e ${branch_search} ${file}
echo "Found kernel branches"
else
# kcore is required for correct kernel decode due to runtime code patching
echo "No kcore, skipping kernel test"
# Root and kcore are required for correct kernel decode due to runtime code patching
echo "No root or kcore, skipping kernel test"
fi
## Test user ##