1#!/bin/bash 2# record weak terms 3# SPDX-License-Identifier: GPL-2.0 4# Test that command line options override weak terms from sysfs or inbuilt json. 5set -e 6 7shelldir=$(dirname "$0") 8# shellcheck source=lib/setup_python.sh 9. "${shelldir}"/lib/setup_python.sh 10 11# Find the first event with a specified period, such as 12# "cpu_core/event=0x24,period=200003,umask=0xff/" 13event=$(perf list --json | $PYTHON -c ' 14import json, sys 15for e in json.load(sys.stdin): 16 if "EventName" not in e or "/modifier" in e["EventName"]: 17 continue 18 if "Encoding" in e and "period=" in e["Encoding"]: 19 print(e["EventName"]) 20 break 21') 22if [[ "$event" = "" ]] 23then 24 echo "Skip: No sysfs/json events with inbuilt period." 25 exit 2 26fi 27 28echo "Testing that for $event the period is overridden with 1000" 29perf list --detail "$event" 30if ! perf record -c 1000 -vv -e "$event" -o /dev/null true 2>&1 | \ 31 grep -q -F '{ sample_period, sample_freq } 1000' 32then 33 echo "Fail: Unexpected verbose output and sample period" 34 exit 1 35fi 36echo "Success" 37exit 0 38