]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf test cs-etm: Skip if not root
authorJames Clark <james.clark@linaro.org>
Tue, 9 Jun 2026 14:40:17 +0000 (15:40 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 10 Jun 2026 21:55:49 +0000 (18:55 -0300)
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>
tools/perf/tests/shell/test_arm_coresight.sh
tools/perf/tests/shell/test_arm_coresight_disasm.sh

index 39553702c1f31e8dc54622019963635221f81749..8ed2c934c87d03cfbabb6b92c9724f9be42dac7e 100755 (executable)
@@ -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)
 
index 0dfb4fadf53177814f8f1bd7532a4c283c8ae9a8..339ae48318681d653d9a3af26c0f97c1b5954e69 100755 (executable)
@@ -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 ##