File: evlist.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 (79 lines) | stat: -rwxr-xr-x 1,545 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# perf evlist tests
# SPDX-License-Identifier: GPL-2.0

set -e

err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)

cleanup() {
	rm -f "${perfdata}"
	trap - EXIT TERM INT
}

trap_cleanup() {
	echo "Unexpected signal in ${FUNCNAME[1]}"
	cleanup
	exit 1
}
trap trap_cleanup EXIT TERM INT

test_evlist_simple() {
	echo "Simple evlist test"
	if ! perf record -e cycles -o "${perfdata}" true 2> /dev/null
	then
		echo "Simple evlist [Failed record]"
		err=1
		return
	fi
	if ! perf evlist -i "${perfdata}" | grep -q "cycles"
	then
		echo "Simple evlist [Failed to list event]"
		err=1
		return
	fi
	echo "Simple evlist test [Success]"
}

test_evlist_group() {
	echo "Group evlist test"
	if ! perf record -e "{cycles,instructions}" -o "${perfdata}" true 2> /dev/null
	then
		echo "Group evlist [Skipped event group recording failed]"
		return
	fi

	if ! perf evlist -i "${perfdata}" -g | grep -q "{.*cycles.*,.*instructions.*}"
	then
		echo "Group evlist [Failed to list event group]"
		err=1
		return
	fi
	echo "Group evlist test [Success]"
}

test_evlist_verbose() {
	echo "Event configuration evlist test"
	if ! perf record -e cycles -o "${perfdata}" true 2> /dev/null
	then
		echo "Event configuration evlist [Failed record]"
		err=1
		return
	fi

	if ! perf evlist -i "${perfdata}" -v | grep -q "config:"
	then
		echo "Event configuration evlist [Failed to list verbose info]"
		err=1
		return
	fi
	echo "Event configuration evlist test [Success]"
}

test_evlist_simple
test_evlist_group
test_evlist_verbose

cleanup
exit $err