Skip to content

Commit db45296

Browse files
captain5050namhyung
authored andcommitted
perf tests evlist: Add basic evlist test
Add test that evlist reports expected events from perf record. Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 199d5e8 commit db45296

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

tools/perf/tests/shell/evlist.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
# perf evlist tests
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
set -e
6+
7+
err=0
8+
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
9+
10+
cleanup() {
11+
rm -f "${perfdata}"
12+
trap - EXIT TERM INT
13+
}
14+
15+
trap_cleanup() {
16+
echo "Unexpected signal in ${FUNCNAME[1]}"
17+
cleanup
18+
exit 1
19+
}
20+
trap trap_cleanup EXIT TERM INT
21+
22+
test_evlist_simple() {
23+
echo "Simple evlist test"
24+
if ! perf record -e cycles -o "${perfdata}" true 2> /dev/null
25+
then
26+
echo "Simple evlist [Failed record]"
27+
err=1
28+
return
29+
fi
30+
if ! perf evlist -i "${perfdata}" | grep -q "cycles"
31+
then
32+
echo "Simple evlist [Failed to list event]"
33+
err=1
34+
return
35+
fi
36+
echo "Simple evlist test [Success]"
37+
}
38+
39+
test_evlist_group() {
40+
echo "Group evlist test"
41+
if ! perf record -e "{cycles,instructions}" -o "${perfdata}" true 2> /dev/null
42+
then
43+
echo "Group evlist [Skipped event group recording failed]"
44+
return
45+
fi
46+
47+
if ! perf evlist -i "${perfdata}" -g | grep -q "{.*cycles.*,.*instructions.*}"
48+
then
49+
echo "Group evlist [Failed to list event group]"
50+
err=1
51+
return
52+
fi
53+
echo "Group evlist test [Success]"
54+
}
55+
56+
test_evlist_verbose() {
57+
echo "Event configuration evlist test"
58+
if ! perf record -e cycles -o "${perfdata}" true 2> /dev/null
59+
then
60+
echo "Event configuration evlist [Failed record]"
61+
err=1
62+
return
63+
fi
64+
65+
if ! perf evlist -i "${perfdata}" -v | grep -q "config:"
66+
then
67+
echo "Event configuration evlist [Failed to list verbose info]"
68+
err=1
69+
return
70+
fi
71+
echo "Event configuration evlist test [Success]"
72+
}
73+
74+
test_evlist_simple
75+
test_evlist_group
76+
test_evlist_verbose
77+
78+
cleanup
79+
exit $err

0 commit comments

Comments
 (0)