1#!/bin/sh
2# perf all PMU test
3# SPDX-License-Identifier: GPL-2.0
4
5set -e
6
7# Test all PMU events; however exclude parameterized ones (name contains '?')
8for p in $(perf list --raw-dump pmu | sed 's/[[:graph:]]\+?[[:graph:]]\+[[:space:]]//g'); do
9  echo "Testing $p"
10  result=$(perf stat -e "$p" true 2>&1)
11  if ! echo "$result" | grep -q "$p" && ! echo "$result" | grep -q "<not supported>" ; then
12    # We failed to see the event and it is supported. Possibly the workload was
13    # too small so retry with something longer.
14    result=$(perf stat -e "$p" perf bench internals synthesize 2>&1)
15    if ! echo "$result" | grep -q "$p" ; then
16      echo "Event '$p' not printed in:"
17      echo "$result"
18      exit 1
19    fi
20  fi
21done
22
23exit 0
24