Loading...
1#!/bin/bash
2# perf all metrics test
3# SPDX-License-Identifier: GPL-2.0
4
5err=0
6for m in $(perf list --raw-dump metrics); do
7 echo "Testing $m"
8 result=$(perf stat -M "$m" true 2>&1)
9 if [[ "$result" =~ ${m:0:50} ]] || [[ "$result" =~ "<not supported>" ]]
10 then
11 continue
12 fi
13 # Failed so try system wide.
14 result=$(perf stat -M "$m" -a sleep 0.01 2>&1)
15 if [[ "$result" =~ ${m:0:50} ]]
16 then
17 continue
18 fi
19 # Failed again, possibly the workload was too small so retry with something
20 # longer.
21 result=$(perf stat -M "$m" perf bench internals synthesize 2>&1)
22 if [[ "$result" =~ ${m:0:50} ]]
23 then
24 continue
25 fi
26 echo "Metric '$m' not printed in:"
27 echo "$result"
28 if [[ "$err" != "1" ]]
29 then
30 err=2
31 if [[ "$result" =~ "FP_ARITH" || "$result" =~ "AMX" ]]
32 then
33 echo "Skip, not fail, for FP issues"
34 elif [[ "$result" =~ "PMM" ]]
35 then
36 echo "Skip, not fail, for Optane memory issues"
37 else
38 err=1
39 fi
40 fi
41done
42
43exit "$err"
1#!/bin/bash
2# perf all metrics test
3# SPDX-License-Identifier: GPL-2.0
4
5ParanoidAndNotRoot()
6{
7 [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
8}
9
10system_wide_flag="-a"
11if ParanoidAndNotRoot 0
12then
13 system_wide_flag=""
14fi
15
16err=0
17for m in $(perf list --raw-dump metrics); do
18 echo "Testing $m"
19 result=$(perf stat -M "$m" $system_wide_flag -- sleep 0.01 2>&1)
20 result_err=$?
21 if [[ $result_err -gt 0 ]]
22 then
23 if [[ "$result" =~ \
24 "Access to performance monitoring and observability operations is limited" ]]
25 then
26 echo "Permission failure"
27 echo $result
28 if [[ $err -eq 0 ]]
29 then
30 err=2 # Skip
31 fi
32 continue
33 elif [[ "$result" =~ "in per-thread mode, enable system wide" ]]
34 then
35 echo "Permissions - need system wide mode"
36 echo $result
37 if [[ $err -eq 0 ]]
38 then
39 err=2 # Skip
40 fi
41 continue
42 elif [[ "$result" =~ "<not supported>" ]]
43 then
44 echo "Not supported events"
45 echo $result
46 if [[ $err -eq 0 ]]
47 then
48 err=2 # Skip
49 fi
50 continue
51 elif [[ "$result" =~ "FP_ARITH" || "$result" =~ "AMX" ]]
52 then
53 echo "FP issues"
54 echo $result
55 if [[ $err -eq 0 ]]
56 then
57 err=2 # Skip
58 fi
59 continue
60 elif [[ "$result" =~ "PMM" ]]
61 then
62 echo "Optane memory issues"
63 echo $result
64 if [[ $err -eq 0 ]]
65 then
66 err=2 # Skip
67 fi
68 continue
69 fi
70 fi
71
72 if [[ "$result" =~ ${m:0:50} ]]
73 then
74 continue
75 fi
76
77 # Failed, possibly the workload was too small so retry with something longer.
78 result=$(perf stat -M "$m" $system_wide_flag -- perf bench internals synthesize 2>&1)
79 if [[ "$result" =~ ${m:0:50} ]]
80 then
81 continue
82 fi
83 echo "Metric '$m' not printed in:"
84 echo "$result"
85 err=1
86done
87
88exit "$err"