1#!/bin/sh
2# perf all metrics test
3# SPDX-License-Identifier: GPL-2.0
4
5set -e
6
7for m in $(perf list --raw-dump metrics); do
8  echo "Testing $m"
9  result=$(perf stat -M "$m" true 2>&1)
10  if [[ ! "$result" =~ "$m" ]] && [[ ! "$result" =~ "<not supported>" ]]; then
11    # We failed to see the metric and the events are support. Possibly the
12    # workload was too small so retry with something longer.
13    result=$(perf stat -M "$m" perf bench internals synthesize 2>&1)
14    if [[ ! "$result" =~ "$m" ]]; then
15      echo "Metric '$m' not printed in:"
16      echo "$result"
17      exit 1
18    fi
19  fi
20done
21
22exit 0
23