Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#!/bin/bash
2# perf evlist tests
3# SPDX-License-Identifier: GPL-2.0
4
5set -e
6
7err=0
8perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
9
10cleanup() {
11 rm -f "${perfdata}"
12 trap - EXIT TERM INT
13}
14
15trap_cleanup() {
16 echo "Unexpected signal in ${FUNCNAME[1]}"
17 cleanup
18 exit 1
19}
20trap trap_cleanup EXIT TERM INT
21
22test_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
39test_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
56test_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
74test_evlist_simple
75test_evlist_group
76test_evlist_verbose
77
78cleanup
79exit $err