1#!/bin/bash 2# perf metrics value validation 3# SPDX-License-Identifier: GPL-2.0 4 5shelldir=$(dirname "$0") 6# shellcheck source=lib/setup_python.sh 7. "${shelldir}"/lib/setup_python.sh 8 9grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; } 10 11# Skip if no permission to record system-wide events 12if ! perf stat -a -e instructions sleep 0.01 >/dev/null 2>&1; then 13 echo "Skipping: no permission to record system-wide events (-a)" 14 exit 2 15fi 16 17 18pythonvalidator=$(dirname $0)/lib/perf_metric_validation.py 19rulefile=$(dirname $0)/lib/perf_metric_validation_rules.json 20tmpdir=$(mktemp -d /tmp/__perf_test.program.XXXXX) 21workload="perf bench futex hash -r 2 -s" 22 23# Add -debug, save data file and full rule file 24echo "Launch python validation script $pythonvalidator" 25echo "Output will be stored in: $tmpdir" 26for cputype in /sys/bus/event_source/devices/cpu_*; do 27 cputype=$(basename "$cputype") 28 echo "Testing metrics for: $cputype" 29 $PYTHON $pythonvalidator -rule $rulefile -output_dir $tmpdir -wl "${workload}" \ 30 -cputype "${cputype}" 31 ret=$? 32 rm -rf $tmpdir 33 if [ $ret -ne 0 ]; then 34 echo "Metric validation return with errors. Please check metrics reported with errors." 35 fi 36done 37exit $ret 38 39