20 lines · bash
1#!/bin/bash2# test Intel TPEBS counting mode3# SPDX-License-Identifier: GPL-2.04 5set -e6grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }7 8# Use this event for testing because it should exist in all platforms9event=cache-misses:R10 11# Without this cmd option, default value or zero is returned12echo "Testing without --record-tpebs"13result=$(perf stat -e "$event" true 2>&1)14[[ "$result" =~ $event ]] || exit 115 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 120