1#!/bin/sh
2# perf all PMU test
3# SPDX-License-Identifier: GPL-2.0
4
5set -e
6
7for p in $(perf list --raw-dump pmu); do
8  # In powerpc, skip the events for hv_24x7 and hv_gpci.
9  # These events needs input values to be filled in for
10  # core, chip, partition id based on system.
11  # Example: hv_24x7/CPM_ADJUNCT_INST,domain=?,core=?/
12  # hv_gpci/event,partition_id=?/
13  # Hence skip these events for ppc.
14  if echo "$p" |grep -Eq 'hv_24x7|hv_gpci' ; then
15    echo "Skipping: Event '$p' in powerpc"
16    continue
17  fi
18  echo "Testing $p"
19  result=$(perf stat -e "$p" true 2>&1)
20  if ! echo "$result" | grep -q "$p" && ! echo "$result" | grep -q "<not supported>" ; then
21    # We failed to see the event and it is supported. Possibly the workload was
22    # too small so retry with something longer.
23    result=$(perf stat -e "$p" perf bench internals synthesize 2>&1)
24    if ! echo "$result" | grep -q "$p" ; then
25      echo "Event '$p' not printed in:"
26      echo "$result"
27      exit 1
28    fi
29  fi
30done
31
32exit 0
33