xref: /linux/tools/perf/tests/shell/test_stat_intel_tpebs.sh (revision a3a02a52bcfcbcc4a637d4b68bf1bc391c9fad02)
1#!/bin/bash
2# test Intel TPEBS counting mode
3# SPDX-License-Identifier: GPL-2.0
4
5set -e
6grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
7
8# Use this event for testing because it should exist in all platforms
9event=cache-misses:R
10
11# Without this cmd option, default value or zero is returned
12echo "Testing without --record-tpebs"
13result=$(perf stat -e "$event" true 2>&1)
14[[ "$result" =~ $event ]] || exit 1
15
16# In platforms that do not support TPEBS, it should execute without error.
17echo "Testing with --record-tpebs"
18result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
19[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
20