From: James Clark Date: Tue, 9 Jun 2026 14:40:17 +0000 (+0100) Subject: perf test cs-etm: Skip if not root X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=ac390ed34317144589cc8b6b374dbed137c7f076;p=thirdparty%2Fkernel%2Flinux.git 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 Cc: Amir Ayupov Cc: Ian Rogers Cc: Jiri Olsa Cc: Jonathan Corbet Cc: Leo Yan Cc: Mike Leach Cc: Namhyung Kim Cc: Paschalis Mpeis Cc: Shuah Khan Cc: Suzuki Poulouse Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/tests/shell/test_arm_coresight.sh index 39553702c1f31..8ed2c934c87d0 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -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) diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/perf/tests/shell/test_arm_coresight_disasm.sh index 0dfb4fadf5317..339ae48318681 100755 --- a/tools/perf/tests/shell/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/test_arm_coresight_disasm.sh @@ -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 ##