1*dcf7a177SIan Rogers#!/bin/sh 2*dcf7a177SIan Rogers# perf all libpfm4 events test 3*dcf7a177SIan Rogers# SPDX-License-Identifier: GPL-2.0 4*dcf7a177SIan Rogers 5*dcf7a177SIan Rogersif perf version --build-options | grep HAVE_LIBPFM | grep -q OFF 6*dcf7a177SIan Rogersthen 7*dcf7a177SIan Rogers echo "Skipping, no libpfm4 support" 8*dcf7a177SIan Rogers exit 2 9*dcf7a177SIan Rogersfi 10*dcf7a177SIan Rogers 11*dcf7a177SIan Rogerserr=0 12*dcf7a177SIan Rogersfor p in $(perf list --raw-dump pfm) 13*dcf7a177SIan Rogersdo 14*dcf7a177SIan Rogers if echo "$p" | grep -q unc_ 15*dcf7a177SIan Rogers then 16*dcf7a177SIan Rogers echo "Skipping uncore event '$p' that may require additional options." 17*dcf7a177SIan Rogers continue 18*dcf7a177SIan Rogers fi 19*dcf7a177SIan Rogers echo "Testing $p" 20*dcf7a177SIan Rogers result=$(perf stat --pfm-events "$p" true 2>&1) 21*dcf7a177SIan Rogers x=$? 22*dcf7a177SIan Rogers if echo "$result" | grep -q "failed to parse event $p : invalid or missing unit mask" 23*dcf7a177SIan Rogers then 24*dcf7a177SIan Rogers continue 25*dcf7a177SIan Rogers fi 26*dcf7a177SIan Rogers if test "$x" -ne "0" 27*dcf7a177SIan Rogers then 28*dcf7a177SIan Rogers echo "Unexpected exit code '$x'" 29*dcf7a177SIan Rogers err=1 30*dcf7a177SIan Rogers fi 31*dcf7a177SIan Rogers if ! echo "$result" | grep -q "$p" && ! echo "$result" | grep -q "<not supported>" 32*dcf7a177SIan Rogers then 33*dcf7a177SIan Rogers # We failed to see the event and it is supported. Possibly the workload was 34*dcf7a177SIan Rogers # too small so retry with something longer. 35*dcf7a177SIan Rogers result=$(perf stat --pfm-events "$p" perf bench internals synthesize 2>&1) 36*dcf7a177SIan Rogers x=$? 37*dcf7a177SIan Rogers if test "$x" -ne "0" 38*dcf7a177SIan Rogers then 39*dcf7a177SIan Rogers echo "Unexpected exit code '$x'" 40*dcf7a177SIan Rogers err=1 41*dcf7a177SIan Rogers fi 42*dcf7a177SIan Rogers if ! echo "$result" | grep -q "$p" 43*dcf7a177SIan Rogers then 44*dcf7a177SIan Rogers echo "Event '$p' not printed in:" 45*dcf7a177SIan Rogers echo "$result" 46*dcf7a177SIan Rogers err=1 47*dcf7a177SIan Rogers fi 48*dcf7a177SIan Rogers fi 49*dcf7a177SIan Rogersdone 50*dcf7a177SIan Rogers 51*dcf7a177SIan Rogersexit "$err" 52