File: record_weak_term.sh

package info (click to toggle)
linux 6.19.5-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,759,704 kB
  • sloc: ansic: 27,007,363; asm: 273,421; sh: 151,330; python: 81,278; makefile: 58,557; perl: 34,311; xml: 21,064; cpp: 5,986; yacc: 4,841; lex: 2,901; awk: 1,707; sed: 30; ruby: 25
file content (37 lines) | stat: -rwxr-xr-x 1,044 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# record weak terms
# SPDX-License-Identifier: GPL-2.0
# Test that command line options override weak terms from sysfs or inbuilt json.
set -e

shelldir=$(dirname "$0")
# shellcheck source=lib/setup_python.sh
. "${shelldir}"/lib/setup_python.sh

# Find the first event with a specified period, such as
# "cpu_core/event=0x24,period=200003,umask=0xff/"
event=$(perf list --json | $PYTHON -c '
import json, sys
for e in json.load(sys.stdin):
    if "EventName" not in e or "/modifier" in e["EventName"]:
        continue
    if "Encoding" in e and "period=" in e["Encoding"]:
        print(e["EventName"])
        break
')
if [[ "$event" = "" ]]
then
  echo "Skip: No sysfs/json events with inbuilt period."
  exit 2
fi

echo "Testing that for $event the period is overridden with 1000"
perf list --detail "$event"
if ! perf record -c 1000 -vv -e "$event" -o /dev/null true 2>&1 | \
  grep -q -F '{ sample_period, sample_freq }   1000'
then
  echo "Fail: Unexpected verbose output and sample period"
  exit 1
fi
echo "Success"
exit 0