1#!/bin/bash 2# perf all PMU test (exclusive) 3# SPDX-License-Identifier: GPL-2.0 4 5set -e 6err=0 7result="" 8 9trap_cleanup() { 10 echo "Unexpected signal in ${FUNCNAME[1]}" 11 echo "$result" 12 exit 1 13} 14trap trap_cleanup EXIT TERM INT 15 16# Test all PMU events; however exclude parameterized ones (name contains '?') 17for p in $(perf list --raw-dump pmu | sed 's/[[:graph:]]\+?[[:graph:]]\+[[:space:]]//g') 18do 19 echo "Testing $p" 20 result=$(perf stat -e "$p" true 2>&1) 21 if echo "$result" | grep -q "$p" 22 then 23 # Event seen in output. 24 continue 25 fi 26 if echo "$result" | grep -q "<not supported>" 27 then 28 # Event not supported, so ignore. 29 continue 30 fi 31 if echo "$result" | grep -q "Access to performance monitoring and observability operations is limited." 32 then 33 # Access is limited, so ignore. 34 continue 35 fi 36 37 # We failed to see the event and it is supported. Possibly the workload was 38 # too small so retry with something longer. 39 result=$(perf stat -e "$p" perf bench internals synthesize 2>&1) 40 if echo "$result" | grep -q "$p" 41 then 42 # Event seen in output. 43 continue 44 fi 45 echo "Error: event '$p' not printed in:" 46 echo "$result" 47 err=1 48done 49 50trap - EXIT TERM INT 51exit $err 52