blob: b5dec6b6da36938281e7817fbb23993bc3898344 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/bin/bash
# perf stat events uniquifying
# SPDX-License-Identifier: GPL-2.0
set -e
err=0
stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
cleanup() {
rm -f "${stat_output}"
trap - EXIT TERM INT
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
test_event_uniquifying() {
echo "Uniquification of PMU sysfs events test"
# Read events from perf list with and without -v. With -v the duplicate PMUs
# aren't deduplicated. Note, json events are listed by perf list without a
# PMU.
read -ra pmu_events <<< "$(perf list --raw pmu)"
read -ra pmu_v_events <<< "$(perf list -v --raw pmu)"
# For all non-deduplicated events.
for pmu_v_event in "${pmu_v_events[@]}"; do
# If the event matches an event in the deduplicated events then it musn't
# be an event with duplicate PMUs, continue the outer loop.
for pmu_event in "${pmu_events[@]}"; do
if [[ "$pmu_v_event" == "$pmu_event" ]]; then
continue 2
fi
done
# Strip the suffix from the non-deduplicated event's PMU.
event=$(echo "$pmu_v_event" | sed -E 's/_[0-9]+//')
for pmu_event in "${pmu_events[@]}"; do
if [[ "$event" == "$pmu_event" ]]; then
echo "Testing event ${event} is uniquified to ${pmu_v_event}"
if ! perf stat -e "$event" -A -o ${stat_output} -- true; then
echo "Error running perf stat for event '$event' [Skip]"
if [ $err = 0 ]; then
err=2
fi
continue
fi
# Ensure the non-deduplicated event appears in the output.
if ! grep -q "${pmu_v_event}" "${stat_output}"; then
echo "Uniquification of PMU sysfs events test [Failed]"
cat "${stat_output}"
err=1
fi
break
fi
done
done
}
test_event_uniquifying
cleanup
exit $err
|