Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
f50246e2 JO |
2 | #include "parse-events.h" |
3 | #include "evsel.h" | |
4 | #include "evlist.h" | |
cd0cfad7 | 5 | #include <api/fs/fs.h> |
c81251e8 | 6 | #include "tests.h" |
84f5d36f | 7 | #include "debug.h" |
2690c730 | 8 | #include "util.h" |
76b31a29 | 9 | #include <dirent.h> |
a43783ae | 10 | #include <errno.h> |
7a8ef4c4 ACM |
11 | #include <sys/types.h> |
12 | #include <sys/stat.h> | |
13 | #include <unistd.h> | |
877a7a11 | 14 | #include <linux/kernel.h> |
d2709c7c | 15 | #include <linux/hw_breakpoint.h> |
4605eab3 | 16 | #include <api/fs/fs.h> |
20a9ed28 | 17 | #include <api/fs/tracing_path.h> |
f50246e2 | 18 | |
30f31c0a JO |
19 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ |
20 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) | |
21 | ||
f50246e2 JO |
22 | static int test__checkevent_tracepoint(struct perf_evlist *evlist) |
23 | { | |
0c21f736 | 24 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
25 | |
26 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
8d7d8474 | 27 | TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); |
f50246e2 JO |
28 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
29 | TEST_ASSERT_VAL("wrong sample_type", | |
30f31c0a | 30 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
f50246e2 JO |
31 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
32 | return 0; | |
33 | } | |
34 | ||
35 | static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) | |
36 | { | |
37 | struct perf_evsel *evsel; | |
38 | ||
39 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); | |
8d7d8474 | 40 | TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); |
f50246e2 | 41 | |
e5cadb93 | 42 | evlist__for_each_entry(evlist, evsel) { |
f50246e2 JO |
43 | TEST_ASSERT_VAL("wrong type", |
44 | PERF_TYPE_TRACEPOINT == evsel->attr.type); | |
45 | TEST_ASSERT_VAL("wrong sample_type", | |
30f31c0a | 46 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
f50246e2 JO |
47 | TEST_ASSERT_VAL("wrong sample_period", |
48 | 1 == evsel->attr.sample_period); | |
49 | } | |
50 | return 0; | |
51 | } | |
52 | ||
53 | static int test__checkevent_raw(struct perf_evlist *evlist) | |
54 | { | |
0c21f736 | 55 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
56 | |
57 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
58 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
59 | TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config); | |
60 | return 0; | |
61 | } | |
62 | ||
63 | static int test__checkevent_numeric(struct perf_evlist *evlist) | |
64 | { | |
0c21f736 | 65 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
66 | |
67 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
68 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | |
69 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | |
70 | return 0; | |
71 | } | |
72 | ||
73 | static int test__checkevent_symbolic_name(struct perf_evlist *evlist) | |
74 | { | |
0c21f736 | 75 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
76 | |
77 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
78 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
79 | TEST_ASSERT_VAL("wrong config", | |
80 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
81 | return 0; | |
82 | } | |
83 | ||
84 | static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) | |
85 | { | |
0c21f736 | 86 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
87 | |
88 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
89 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
90 | TEST_ASSERT_VAL("wrong config", | |
91 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
ee4c7588 JO |
92 | /* |
93 | * The period value gets configured within perf_evlist__config, | |
94 | * while this test executes only parse events method. | |
95 | */ | |
f50246e2 | 96 | TEST_ASSERT_VAL("wrong period", |
ee4c7588 | 97 | 0 == evsel->attr.sample_period); |
f50246e2 JO |
98 | TEST_ASSERT_VAL("wrong config1", |
99 | 0 == evsel->attr.config1); | |
100 | TEST_ASSERT_VAL("wrong config2", | |
101 | 1 == evsel->attr.config2); | |
102 | return 0; | |
103 | } | |
104 | ||
105 | static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) | |
106 | { | |
0c21f736 | 107 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
108 | |
109 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
110 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); | |
111 | TEST_ASSERT_VAL("wrong config", | |
112 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); | |
113 | return 0; | |
114 | } | |
115 | ||
116 | static int test__checkevent_genhw(struct perf_evlist *evlist) | |
117 | { | |
0c21f736 | 118 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
119 | |
120 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
121 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); | |
122 | TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config); | |
123 | return 0; | |
124 | } | |
125 | ||
126 | static int test__checkevent_breakpoint(struct perf_evlist *evlist) | |
127 | { | |
0c21f736 | 128 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
129 | |
130 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
131 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
132 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
133 | TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == | |
134 | evsel->attr.bp_type); | |
135 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == | |
136 | evsel->attr.bp_len); | |
137 | return 0; | |
138 | } | |
139 | ||
140 | static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) | |
141 | { | |
0c21f736 | 142 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
143 | |
144 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
145 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
146 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
147 | TEST_ASSERT_VAL("wrong bp_type", | |
148 | HW_BREAKPOINT_X == evsel->attr.bp_type); | |
149 | TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len); | |
150 | return 0; | |
151 | } | |
152 | ||
153 | static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) | |
154 | { | |
0c21f736 | 155 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
156 | |
157 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
158 | TEST_ASSERT_VAL("wrong type", | |
159 | PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
160 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
161 | TEST_ASSERT_VAL("wrong bp_type", | |
162 | HW_BREAKPOINT_R == evsel->attr.bp_type); | |
163 | TEST_ASSERT_VAL("wrong bp_len", | |
164 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); | |
165 | return 0; | |
166 | } | |
167 | ||
168 | static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) | |
169 | { | |
0c21f736 | 170 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
171 | |
172 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
173 | TEST_ASSERT_VAL("wrong type", | |
174 | PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
175 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
176 | TEST_ASSERT_VAL("wrong bp_type", | |
177 | HW_BREAKPOINT_W == evsel->attr.bp_type); | |
178 | TEST_ASSERT_VAL("wrong bp_len", | |
179 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); | |
180 | return 0; | |
181 | } | |
182 | ||
7582732f JO |
183 | static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) |
184 | { | |
0c21f736 | 185 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
7582732f JO |
186 | |
187 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
188 | TEST_ASSERT_VAL("wrong type", | |
189 | PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
190 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
191 | TEST_ASSERT_VAL("wrong bp_type", | |
192 | (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type); | |
193 | TEST_ASSERT_VAL("wrong bp_len", | |
194 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); | |
195 | return 0; | |
196 | } | |
197 | ||
f50246e2 JO |
198 | static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) |
199 | { | |
0c21f736 | 200 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
201 | |
202 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
203 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
204 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
205 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
206 | ||
207 | return test__checkevent_tracepoint(evlist); | |
208 | } | |
209 | ||
210 | static int | |
211 | test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) | |
212 | { | |
213 | struct perf_evsel *evsel; | |
214 | ||
215 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); | |
216 | ||
e5cadb93 | 217 | evlist__for_each_entry(evlist, evsel) { |
f50246e2 JO |
218 | TEST_ASSERT_VAL("wrong exclude_user", |
219 | !evsel->attr.exclude_user); | |
220 | TEST_ASSERT_VAL("wrong exclude_kernel", | |
221 | evsel->attr.exclude_kernel); | |
222 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
223 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
224 | } | |
225 | ||
226 | return test__checkevent_tracepoint_multi(evlist); | |
227 | } | |
228 | ||
229 | static int test__checkevent_raw_modifier(struct perf_evlist *evlist) | |
230 | { | |
0c21f736 | 231 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
232 | |
233 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
234 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
235 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
236 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
237 | ||
238 | return test__checkevent_raw(evlist); | |
239 | } | |
240 | ||
241 | static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) | |
242 | { | |
0c21f736 | 243 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
244 | |
245 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
246 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
247 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
248 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
249 | ||
250 | return test__checkevent_numeric(evlist); | |
251 | } | |
252 | ||
253 | static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) | |
254 | { | |
0c21f736 | 255 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
256 | |
257 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
258 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
259 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
260 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
261 | ||
262 | return test__checkevent_symbolic_name(evlist); | |
263 | } | |
264 | ||
265 | static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) | |
266 | { | |
0c21f736 | 267 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
268 | |
269 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
270 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
271 | ||
272 | return test__checkevent_symbolic_name(evlist); | |
273 | } | |
274 | ||
275 | static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) | |
276 | { | |
0c21f736 | 277 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
278 | |
279 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
280 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
281 | ||
282 | return test__checkevent_symbolic_name(evlist); | |
283 | } | |
284 | ||
285 | static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) | |
286 | { | |
0c21f736 | 287 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
288 | |
289 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
290 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
291 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
292 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
293 | ||
294 | return test__checkevent_symbolic_alias(evlist); | |
295 | } | |
296 | ||
297 | static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) | |
298 | { | |
0c21f736 | 299 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
300 | |
301 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
302 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
303 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
304 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
305 | ||
306 | return test__checkevent_genhw(evlist); | |
307 | } | |
308 | ||
a1e12da4 JO |
309 | static int test__checkevent_exclude_idle_modifier(struct perf_evlist *evlist) |
310 | { | |
311 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
312 | ||
313 | TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); | |
314 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
315 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
316 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
317 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
318 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
319 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
320 | ||
321 | return test__checkevent_symbolic_name(evlist); | |
322 | } | |
323 | ||
324 | static int test__checkevent_exclude_idle_modifier_1(struct perf_evlist *evlist) | |
325 | { | |
326 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
327 | ||
328 | TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); | |
329 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
330 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
331 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
332 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
333 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
334 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
335 | ||
336 | return test__checkevent_symbolic_name(evlist); | |
337 | } | |
338 | ||
f50246e2 JO |
339 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) |
340 | { | |
0c21f736 | 341 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 | 342 | |
f50246e2 JO |
343 | |
344 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
345 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
346 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
347 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
287e74aa | 348 | TEST_ASSERT_VAL("wrong name", |
ac2ba9f3 | 349 | !strcmp(perf_evsel__name(evsel), "mem:0:u")); |
f50246e2 JO |
350 | |
351 | return test__checkevent_breakpoint(evlist); | |
352 | } | |
353 | ||
354 | static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) | |
355 | { | |
0c21f736 | 356 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
357 | |
358 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
359 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
360 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
361 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
287e74aa | 362 | TEST_ASSERT_VAL("wrong name", |
ac2ba9f3 | 363 | !strcmp(perf_evsel__name(evsel), "mem:0:x:k")); |
f50246e2 JO |
364 | |
365 | return test__checkevent_breakpoint_x(evlist); | |
366 | } | |
367 | ||
368 | static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) | |
369 | { | |
0c21f736 | 370 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
371 | |
372 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
373 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
374 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
375 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
287e74aa | 376 | TEST_ASSERT_VAL("wrong name", |
ac2ba9f3 | 377 | !strcmp(perf_evsel__name(evsel), "mem:0:r:hp")); |
f50246e2 JO |
378 | |
379 | return test__checkevent_breakpoint_r(evlist); | |
380 | } | |
381 | ||
382 | static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) | |
383 | { | |
0c21f736 | 384 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
385 | |
386 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
387 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
388 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
389 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
287e74aa | 390 | TEST_ASSERT_VAL("wrong name", |
ac2ba9f3 | 391 | !strcmp(perf_evsel__name(evsel), "mem:0:w:up")); |
f50246e2 JO |
392 | |
393 | return test__checkevent_breakpoint_w(evlist); | |
394 | } | |
395 | ||
7582732f JO |
396 | static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) |
397 | { | |
0c21f736 | 398 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
7582732f JO |
399 | |
400 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
401 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
402 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
403 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
287e74aa | 404 | TEST_ASSERT_VAL("wrong name", |
ac2ba9f3 | 405 | !strcmp(perf_evsel__name(evsel), "mem:0:rw:kp")); |
7582732f JO |
406 | |
407 | return test__checkevent_breakpoint_rw(evlist); | |
408 | } | |
409 | ||
f50246e2 JO |
410 | static int test__checkevent_pmu(struct perf_evlist *evlist) |
411 | { | |
412 | ||
0c21f736 | 413 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
414 | |
415 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
416 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
417 | TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); | |
418 | TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); | |
419 | TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); | |
ee4c7588 JO |
420 | /* |
421 | * The period value gets configured within perf_evlist__config, | |
422 | * while this test executes only parse events method. | |
423 | */ | |
424 | TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period); | |
f50246e2 JO |
425 | |
426 | return 0; | |
427 | } | |
428 | ||
429 | static int test__checkevent_list(struct perf_evlist *evlist) | |
430 | { | |
0c21f736 | 431 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
f50246e2 JO |
432 | |
433 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | |
434 | ||
435 | /* r1 */ | |
f50246e2 JO |
436 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
437 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | |
438 | TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); | |
439 | TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2); | |
440 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
441 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
442 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
443 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
444 | ||
43f322b4 | 445 | /* syscalls:sys_enter_openat:k */ |
0c21f736 | 446 | evsel = perf_evsel__next(evsel); |
f50246e2 JO |
447 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
448 | TEST_ASSERT_VAL("wrong sample_type", | |
30f31c0a | 449 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
f50246e2 JO |
450 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
451 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
452 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
453 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
454 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
455 | ||
456 | /* 1:1:hp */ | |
0c21f736 | 457 | evsel = perf_evsel__next(evsel); |
f50246e2 JO |
458 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
459 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | |
460 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
461 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
462 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
463 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
464 | ||
465 | return 0; | |
466 | } | |
467 | ||
6b5fc39b JO |
468 | static int test__checkevent_pmu_name(struct perf_evlist *evlist) |
469 | { | |
0c21f736 | 470 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
6b5fc39b | 471 | |
7a25b2d3 | 472 | /* cpu/config=1,name=krava/u */ |
6b5fc39b JO |
473 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
474 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
475 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | |
22c8b843 | 476 | TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); |
6b5fc39b | 477 | |
7a25b2d3 | 478 | /* cpu/config=2/u" */ |
0c21f736 | 479 | evsel = perf_evsel__next(evsel); |
6b5fc39b JO |
480 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
481 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
482 | TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); | |
7a25b2d3 | 483 | TEST_ASSERT_VAL("wrong name", |
ac2ba9f3 | 484 | !strcmp(perf_evsel__name(evsel), "cpu/config=2/u")); |
6b5fc39b JO |
485 | |
486 | return 0; | |
487 | } | |
488 | ||
71ef150e KL |
489 | static int test__checkevent_pmu_partial_time_callgraph(struct perf_evlist *evlist) |
490 | { | |
491 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
492 | ||
493 | /* cpu/config=1,call-graph=fp,time,period=100000/ */ | |
494 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
495 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
496 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | |
497 | /* | |
498 | * The period, time and callgraph value gets configured | |
499 | * within perf_evlist__config, | |
500 | * while this test executes only parse events method. | |
501 | */ | |
502 | TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period); | |
503 | TEST_ASSERT_VAL("wrong callgraph", !(PERF_SAMPLE_CALLCHAIN & evsel->attr.sample_type)); | |
504 | TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->attr.sample_type)); | |
505 | ||
506 | /* cpu/config=2,call-graph=no,time=0,period=2000/ */ | |
507 | evsel = perf_evsel__next(evsel); | |
508 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
509 | TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); | |
510 | /* | |
511 | * The period, time and callgraph value gets configured | |
512 | * within perf_evlist__config, | |
513 | * while this test executes only parse events method. | |
514 | */ | |
515 | TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period); | |
516 | TEST_ASSERT_VAL("wrong callgraph", !(PERF_SAMPLE_CALLCHAIN & evsel->attr.sample_type)); | |
517 | TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->attr.sample_type)); | |
518 | ||
519 | return 0; | |
520 | } | |
521 | ||
3f3a2064 JO |
522 | static int test__checkevent_pmu_events(struct perf_evlist *evlist) |
523 | { | |
9a354cdc | 524 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
3f3a2064 | 525 | |
3f3a2064 JO |
526 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
527 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
528 | TEST_ASSERT_VAL("wrong exclude_user", | |
529 | !evsel->attr.exclude_user); | |
530 | TEST_ASSERT_VAL("wrong exclude_kernel", | |
531 | evsel->attr.exclude_kernel); | |
532 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
533 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
c9ee780f | 534 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
3f3a2064 JO |
535 | |
536 | return 0; | |
537 | } | |
538 | ||
ffe59788 KL |
539 | |
540 | static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist) | |
541 | { | |
542 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
543 | ||
544 | /* pmu-event:u */ | |
545 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
546 | TEST_ASSERT_VAL("wrong exclude_user", | |
547 | !evsel->attr.exclude_user); | |
548 | TEST_ASSERT_VAL("wrong exclude_kernel", | |
549 | evsel->attr.exclude_kernel); | |
550 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
551 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
552 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | |
553 | ||
554 | /* cpu/pmu-event/u*/ | |
555 | evsel = perf_evsel__next(evsel); | |
556 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
557 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | |
558 | TEST_ASSERT_VAL("wrong exclude_user", | |
559 | !evsel->attr.exclude_user); | |
560 | TEST_ASSERT_VAL("wrong exclude_kernel", | |
561 | evsel->attr.exclude_kernel); | |
562 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
563 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
564 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | |
565 | ||
566 | return 0; | |
567 | } | |
568 | ||
4429392e JO |
569 | static int test__checkterms_simple(struct list_head *terms) |
570 | { | |
6cee6cd3 | 571 | struct parse_events_term *term; |
4429392e JO |
572 | |
573 | /* config=10 */ | |
6cee6cd3 | 574 | term = list_entry(terms->next, struct parse_events_term, list); |
4429392e JO |
575 | TEST_ASSERT_VAL("wrong type term", |
576 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); | |
577 | TEST_ASSERT_VAL("wrong type val", | |
578 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | |
579 | TEST_ASSERT_VAL("wrong val", term->val.num == 10); | |
580 | TEST_ASSERT_VAL("wrong config", !term->config); | |
581 | ||
582 | /* config1 */ | |
6cee6cd3 | 583 | term = list_entry(term->list.next, struct parse_events_term, list); |
4429392e JO |
584 | TEST_ASSERT_VAL("wrong type term", |
585 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); | |
586 | TEST_ASSERT_VAL("wrong type val", | |
587 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | |
588 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); | |
589 | TEST_ASSERT_VAL("wrong config", !term->config); | |
590 | ||
591 | /* config2=3 */ | |
6cee6cd3 | 592 | term = list_entry(term->list.next, struct parse_events_term, list); |
4429392e JO |
593 | TEST_ASSERT_VAL("wrong type term", |
594 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); | |
595 | TEST_ASSERT_VAL("wrong type val", | |
596 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | |
597 | TEST_ASSERT_VAL("wrong val", term->val.num == 3); | |
598 | TEST_ASSERT_VAL("wrong config", !term->config); | |
599 | ||
600 | /* umask=1*/ | |
6cee6cd3 | 601 | term = list_entry(term->list.next, struct parse_events_term, list); |
4429392e JO |
602 | TEST_ASSERT_VAL("wrong type term", |
603 | term->type_term == PARSE_EVENTS__TERM_TYPE_USER); | |
604 | TEST_ASSERT_VAL("wrong type val", | |
605 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | |
606 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); | |
607 | TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); | |
608 | ||
609 | return 0; | |
610 | } | |
611 | ||
905f5ee2 JO |
612 | static int test__group1(struct perf_evlist *evlist) |
613 | { | |
614 | struct perf_evsel *evsel, *leader; | |
615 | ||
616 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
8d7d8474 | 617 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
905f5ee2 JO |
618 | |
619 | /* instructions:k */ | |
0c21f736 | 620 | evsel = leader = perf_evlist__first(evlist); |
905f5ee2 JO |
621 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
622 | TEST_ASSERT_VAL("wrong config", | |
623 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
624 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
625 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
626 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
627 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
628 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
629 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 630 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
8d7d8474 NK |
631 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
632 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 633 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
634 | |
635 | /* cycles:upp */ | |
0c21f736 | 636 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
637 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
638 | TEST_ASSERT_VAL("wrong config", | |
639 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
640 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
641 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
642 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
42be7398 JO |
643 | /* use of precise requires exclude_guest */ |
644 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
905f5ee2 JO |
645 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
646 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); | |
647 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
8d7d8474 | 648 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
a9f93f97 | 649 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
650 | |
651 | return 0; | |
652 | } | |
653 | ||
654 | static int test__group2(struct perf_evlist *evlist) | |
655 | { | |
656 | struct perf_evsel *evsel, *leader; | |
657 | ||
658 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | |
8d7d8474 | 659 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
905f5ee2 JO |
660 | |
661 | /* faults + :ku modifier */ | |
0c21f736 | 662 | evsel = leader = perf_evlist__first(evlist); |
905f5ee2 JO |
663 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
664 | TEST_ASSERT_VAL("wrong config", | |
665 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); | |
666 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
667 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
668 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
669 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
670 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
671 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 672 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
8d7d8474 NK |
673 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
674 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 675 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
676 | |
677 | /* cache-references + :u modifier */ | |
0c21f736 | 678 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
679 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
680 | TEST_ASSERT_VAL("wrong config", | |
681 | PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); | |
682 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
683 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
684 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
5a30a99f | 685 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
905f5ee2 JO |
686 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
687 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
688 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
8d7d8474 | 689 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
a9f93f97 | 690 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
691 | |
692 | /* cycles:k */ | |
0c21f736 | 693 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
694 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
695 | TEST_ASSERT_VAL("wrong config", | |
696 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
697 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
698 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
699 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
700 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
701 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
702 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 703 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
a9f93f97 | 704 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
705 | |
706 | return 0; | |
707 | } | |
708 | ||
1d037ca1 | 709 | static int test__group3(struct perf_evlist *evlist __maybe_unused) |
905f5ee2 JO |
710 | { |
711 | struct perf_evsel *evsel, *leader; | |
712 | ||
713 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); | |
8d7d8474 | 714 | TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); |
905f5ee2 | 715 | |
43f322b4 | 716 | /* group1 syscalls:sys_enter_openat:H */ |
0c21f736 | 717 | evsel = leader = perf_evlist__first(evlist); |
905f5ee2 JO |
718 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
719 | TEST_ASSERT_VAL("wrong sample_type", | |
720 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | |
721 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); | |
722 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
723 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
724 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
725 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
726 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
727 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 728 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
905f5ee2 JO |
729 | TEST_ASSERT_VAL("wrong group name", |
730 | !strcmp(leader->group_name, "group1")); | |
8d7d8474 NK |
731 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
732 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 733 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
734 | |
735 | /* group1 cycles:kppp */ | |
0c21f736 | 736 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
737 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
738 | TEST_ASSERT_VAL("wrong config", | |
739 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
740 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
741 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
742 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
42be7398 JO |
743 | /* use of precise requires exclude_guest */ |
744 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
905f5ee2 JO |
745 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
746 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); | |
747 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
748 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
8d7d8474 | 749 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
a9f93f97 | 750 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
751 | |
752 | /* group2 cycles + G modifier */ | |
0c21f736 | 753 | evsel = leader = perf_evsel__next(evsel); |
905f5ee2 JO |
754 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
755 | TEST_ASSERT_VAL("wrong config", | |
756 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
757 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
758 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
759 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
760 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
761 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
762 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 763 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
905f5ee2 JO |
764 | TEST_ASSERT_VAL("wrong group name", |
765 | !strcmp(leader->group_name, "group2")); | |
8d7d8474 NK |
766 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
767 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 768 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
769 | |
770 | /* group2 1:3 + G modifier */ | |
0c21f736 | 771 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
772 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
773 | TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); | |
774 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
775 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
776 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
777 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
778 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
779 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
780 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
8d7d8474 | 781 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
a9f93f97 | 782 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
783 | |
784 | /* instructions:u */ | |
0c21f736 | 785 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
786 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
787 | TEST_ASSERT_VAL("wrong config", | |
788 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
789 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
790 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
791 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
792 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
793 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
794 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 795 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
a9f93f97 | 796 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
797 | |
798 | return 0; | |
799 | } | |
800 | ||
1d037ca1 | 801 | static int test__group4(struct perf_evlist *evlist __maybe_unused) |
905f5ee2 JO |
802 | { |
803 | struct perf_evsel *evsel, *leader; | |
804 | ||
805 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
8d7d8474 | 806 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
905f5ee2 JO |
807 | |
808 | /* cycles:u + p */ | |
0c21f736 | 809 | evsel = leader = perf_evlist__first(evlist); |
905f5ee2 JO |
810 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
811 | TEST_ASSERT_VAL("wrong config", | |
812 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
813 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
814 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
815 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
42be7398 JO |
816 | /* use of precise requires exclude_guest */ |
817 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
905f5ee2 JO |
818 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
819 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); | |
820 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
823254ed | 821 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
8d7d8474 NK |
822 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
823 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 824 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
825 | |
826 | /* instructions:kp + p */ | |
0c21f736 | 827 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
828 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
829 | TEST_ASSERT_VAL("wrong config", | |
830 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
831 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | |
832 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
833 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
42be7398 JO |
834 | /* use of precise requires exclude_guest */ |
835 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
905f5ee2 JO |
836 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
837 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); | |
838 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
8d7d8474 | 839 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
a9f93f97 | 840 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
841 | |
842 | return 0; | |
843 | } | |
844 | ||
1d037ca1 | 845 | static int test__group5(struct perf_evlist *evlist __maybe_unused) |
905f5ee2 JO |
846 | { |
847 | struct perf_evsel *evsel, *leader; | |
848 | ||
849 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); | |
8d7d8474 | 850 | TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); |
905f5ee2 JO |
851 | |
852 | /* cycles + G */ | |
0c21f736 | 853 | evsel = leader = perf_evlist__first(evlist); |
905f5ee2 JO |
854 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
855 | TEST_ASSERT_VAL("wrong config", | |
856 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
857 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
858 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
859 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
860 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
861 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
862 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
863 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
823254ed | 864 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
8d7d8474 NK |
865 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
866 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 867 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
868 | |
869 | /* instructions + G */ | |
0c21f736 | 870 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
871 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
872 | TEST_ASSERT_VAL("wrong config", | |
873 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
874 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
875 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
876 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
877 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
878 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
879 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
880 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
8d7d8474 | 881 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
a9f93f97 | 882 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
883 | |
884 | /* cycles:G */ | |
0c21f736 | 885 | evsel = leader = perf_evsel__next(evsel); |
905f5ee2 JO |
886 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
887 | TEST_ASSERT_VAL("wrong config", | |
888 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
889 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
890 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
891 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
892 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
893 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
894 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
895 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
823254ed | 896 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
8d7d8474 NK |
897 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
898 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
a9f93f97 | 899 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
905f5ee2 JO |
900 | |
901 | /* instructions:G */ | |
0c21f736 | 902 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
903 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
904 | TEST_ASSERT_VAL("wrong config", | |
905 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
906 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
907 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
908 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
909 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
910 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
911 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
912 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
8d7d8474 | 913 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
905f5ee2 JO |
914 | |
915 | /* cycles */ | |
0c21f736 | 916 | evsel = perf_evsel__next(evsel); |
905f5ee2 JO |
917 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
918 | TEST_ASSERT_VAL("wrong config", | |
919 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
920 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
921 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
922 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
923 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
924 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
925 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
823254ed | 926 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
905f5ee2 JO |
927 | |
928 | return 0; | |
929 | } | |
930 | ||
5a30a99f JO |
931 | static int test__group_gh1(struct perf_evlist *evlist) |
932 | { | |
933 | struct perf_evsel *evsel, *leader; | |
934 | ||
935 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
936 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | |
937 | ||
938 | /* cycles + :H group modifier */ | |
939 | evsel = leader = perf_evlist__first(evlist); | |
940 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
941 | TEST_ASSERT_VAL("wrong config", | |
942 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
943 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
944 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
945 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
946 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
947 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
948 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
949 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
950 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | |
951 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | |
952 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
953 | ||
954 | /* cache-misses:G + :H group modifier */ | |
955 | evsel = perf_evsel__next(evsel); | |
956 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
957 | TEST_ASSERT_VAL("wrong config", | |
958 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | |
959 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
960 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
961 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
962 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
963 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
964 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
965 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
966 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | |
967 | ||
968 | return 0; | |
969 | } | |
970 | ||
971 | static int test__group_gh2(struct perf_evlist *evlist) | |
972 | { | |
973 | struct perf_evsel *evsel, *leader; | |
974 | ||
975 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
976 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | |
977 | ||
978 | /* cycles + :G group modifier */ | |
979 | evsel = leader = perf_evlist__first(evlist); | |
980 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
981 | TEST_ASSERT_VAL("wrong config", | |
982 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
983 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
984 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
985 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
986 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
987 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
988 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
989 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
990 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | |
991 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | |
992 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
993 | ||
994 | /* cache-misses:H + :G group modifier */ | |
995 | evsel = perf_evsel__next(evsel); | |
996 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
997 | TEST_ASSERT_VAL("wrong config", | |
998 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | |
999 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1000 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
1001 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
1002 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
1003 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1004 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1005 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1006 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | |
1007 | ||
1008 | return 0; | |
1009 | } | |
1010 | ||
1011 | static int test__group_gh3(struct perf_evlist *evlist) | |
1012 | { | |
1013 | struct perf_evsel *evsel, *leader; | |
1014 | ||
1015 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
1016 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | |
1017 | ||
1018 | /* cycles:G + :u group modifier */ | |
1019 | evsel = leader = perf_evlist__first(evlist); | |
1020 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1021 | TEST_ASSERT_VAL("wrong config", | |
1022 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
1023 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1024 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1025 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1026 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
1027 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
1028 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1029 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1030 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | |
1031 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | |
1032 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
1033 | ||
1034 | /* cache-misses:H + :u group modifier */ | |
1035 | evsel = perf_evsel__next(evsel); | |
1036 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1037 | TEST_ASSERT_VAL("wrong config", | |
1038 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | |
1039 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1040 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1041 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1042 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
1043 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1044 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1045 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1046 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | |
1047 | ||
1048 | return 0; | |
1049 | } | |
1050 | ||
1051 | static int test__group_gh4(struct perf_evlist *evlist) | |
1052 | { | |
1053 | struct perf_evsel *evsel, *leader; | |
1054 | ||
1055 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
1056 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | |
1057 | ||
1058 | /* cycles:G + :uG group modifier */ | |
1059 | evsel = leader = perf_evlist__first(evlist); | |
1060 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1061 | TEST_ASSERT_VAL("wrong config", | |
1062 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
1063 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1064 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1065 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1066 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
1067 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | |
1068 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1069 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1070 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | |
1071 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | |
1072 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | |
1073 | ||
1074 | /* cache-misses:H + :uG group modifier */ | |
1075 | evsel = perf_evsel__next(evsel); | |
1076 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1077 | TEST_ASSERT_VAL("wrong config", | |
1078 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | |
1079 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1080 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1081 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1082 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | |
1083 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1084 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1085 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1086 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | |
1087 | ||
1088 | return 0; | |
1089 | } | |
1090 | ||
a9f93f97 JO |
1091 | static int test__leader_sample1(struct perf_evlist *evlist) |
1092 | { | |
1093 | struct perf_evsel *evsel, *leader; | |
1094 | ||
1095 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | |
1096 | ||
1097 | /* cycles - sampling group leader */ | |
1098 | evsel = leader = perf_evlist__first(evlist); | |
1099 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1100 | TEST_ASSERT_VAL("wrong config", | |
1101 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
1102 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1103 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
1104 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
1105 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
1106 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1107 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1108 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1109 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1110 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | |
1111 | ||
1112 | /* cache-misses - not sampling */ | |
1113 | evsel = perf_evsel__next(evsel); | |
1114 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1115 | TEST_ASSERT_VAL("wrong config", | |
1116 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | |
1117 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1118 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
1119 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
1120 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
1121 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1122 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1123 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1124 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | |
1125 | ||
1126 | /* branch-misses - not sampling */ | |
1127 | evsel = perf_evsel__next(evsel); | |
1128 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1129 | TEST_ASSERT_VAL("wrong config", | |
1130 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); | |
1131 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1132 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | |
1133 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); | |
1134 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
1135 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1136 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1137 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1138 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1139 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | |
1140 | ||
1141 | return 0; | |
1142 | } | |
1143 | ||
1144 | static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused) | |
1145 | { | |
1146 | struct perf_evsel *evsel, *leader; | |
1147 | ||
1148 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
1149 | ||
1150 | /* instructions - sampling group leader */ | |
1151 | evsel = leader = perf_evlist__first(evlist); | |
1152 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1153 | TEST_ASSERT_VAL("wrong config", | |
1154 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | |
1155 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1156 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1157 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1158 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
1159 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1160 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1161 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1162 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1163 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | |
1164 | ||
1165 | /* branch-misses - not sampling */ | |
1166 | evsel = perf_evsel__next(evsel); | |
1167 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1168 | TEST_ASSERT_VAL("wrong config", | |
1169 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); | |
1170 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1171 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1172 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1173 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | |
1174 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | |
1175 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1176 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1177 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1178 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | |
1179 | ||
1180 | return 0; | |
1181 | } | |
1182 | ||
c9ee780f ME |
1183 | static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) |
1184 | { | |
1185 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1186 | ||
1187 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1188 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1189 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1190 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); | |
1191 | TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); | |
1192 | ||
1193 | return test__checkevent_symbolic_name(evlist); | |
1194 | } | |
1195 | ||
1196 | static int test__pinned_group(struct perf_evlist *evlist) | |
1197 | { | |
1198 | struct perf_evsel *evsel, *leader; | |
1199 | ||
1200 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | |
1201 | ||
1202 | /* cycles - group leader */ | |
1203 | evsel = leader = perf_evlist__first(evlist); | |
1204 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1205 | TEST_ASSERT_VAL("wrong config", | |
1206 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | |
1207 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | |
1208 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | |
1209 | TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); | |
1210 | ||
1211 | /* cache-misses - can not be pinned, but will go on with the leader */ | |
1212 | evsel = perf_evsel__next(evsel); | |
1213 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | |
1214 | TEST_ASSERT_VAL("wrong config", | |
1215 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | |
1216 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | |
1217 | ||
1218 | /* branch-misses - ditto */ | |
1219 | evsel = perf_evsel__next(evsel); | |
1220 | TEST_ASSERT_VAL("wrong config", | |
1221 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); | |
1222 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | |
1223 | ||
1224 | return 0; | |
1225 | } | |
1226 | ||
ec32398c JS |
1227 | static int test__checkevent_breakpoint_len(struct perf_evlist *evlist) |
1228 | { | |
1229 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1230 | ||
1231 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
1232 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
1233 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
1234 | TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == | |
1235 | evsel->attr.bp_type); | |
1236 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 == | |
1237 | evsel->attr.bp_len); | |
1238 | ||
1239 | return 0; | |
1240 | } | |
1241 | ||
1242 | static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist) | |
1243 | { | |
1244 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1245 | ||
1246 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | |
1247 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | |
1248 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | |
1249 | TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W == | |
1250 | evsel->attr.bp_type); | |
1251 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 == | |
1252 | evsel->attr.bp_len); | |
1253 | ||
1254 | return 0; | |
1255 | } | |
1256 | ||
1257 | static int | |
1258 | test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist) | |
1259 | { | |
1260 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1261 | ||
1262 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | |
1263 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | |
1264 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); | |
1265 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | |
1266 | ||
1267 | return test__checkevent_breakpoint_rw(evlist); | |
1268 | } | |
1269 | ||
ddd83c97 JO |
1270 | static int test__checkevent_precise_max_modifier(struct perf_evlist *evlist) |
1271 | { | |
1272 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1273 | ||
1274 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | |
1275 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); | |
1276 | TEST_ASSERT_VAL("wrong config", | |
1277 | PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config); | |
1278 | return 0; | |
1279 | } | |
1280 | ||
10bf358a WN |
1281 | static int test__checkevent_config_symbol(struct perf_evlist *evlist) |
1282 | { | |
1283 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1284 | ||
1285 | TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0); | |
1286 | return 0; | |
1287 | } | |
1288 | ||
1289 | static int test__checkevent_config_raw(struct perf_evlist *evlist) | |
1290 | { | |
1291 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1292 | ||
1293 | TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0); | |
1294 | return 0; | |
1295 | } | |
1296 | ||
1297 | static int test__checkevent_config_num(struct perf_evlist *evlist) | |
1298 | { | |
1299 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1300 | ||
1301 | TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0); | |
1302 | return 0; | |
1303 | } | |
1304 | ||
43d0b978 WN |
1305 | static int test__checkevent_config_cache(struct perf_evlist *evlist) |
1306 | { | |
1307 | struct perf_evsel *evsel = perf_evlist__first(evlist); | |
1308 | ||
1309 | TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0); | |
1310 | return 0; | |
1311 | } | |
10bf358a | 1312 | |
82ce75d9 JO |
1313 | static int count_tracepoints(void) |
1314 | { | |
82ce75d9 JO |
1315 | struct dirent *events_ent; |
1316 | DIR *events_dir; | |
1317 | int cnt = 0; | |
1318 | ||
fbf99625 | 1319 | events_dir = opendir(tracing_events_path); |
82ce75d9 JO |
1320 | |
1321 | TEST_ASSERT_VAL("Can't open events dir", events_dir); | |
1322 | ||
1323 | while ((events_ent = readdir(events_dir))) { | |
1324 | char sys_path[PATH_MAX]; | |
1325 | struct dirent *sys_ent; | |
1326 | DIR *sys_dir; | |
1327 | ||
1328 | if (!strcmp(events_ent->d_name, ".") | |
1329 | || !strcmp(events_ent->d_name, "..") | |
1330 | || !strcmp(events_ent->d_name, "enable") | |
1331 | || !strcmp(events_ent->d_name, "header_event") | |
1332 | || !strcmp(events_ent->d_name, "header_page")) | |
1333 | continue; | |
1334 | ||
1335 | scnprintf(sys_path, PATH_MAX, "%s/%s", | |
fbf99625 | 1336 | tracing_events_path, events_ent->d_name); |
82ce75d9 JO |
1337 | |
1338 | sys_dir = opendir(sys_path); | |
1339 | TEST_ASSERT_VAL("Can't open sys dir", sys_dir); | |
1340 | ||
1341 | while ((sys_ent = readdir(sys_dir))) { | |
1342 | if (!strcmp(sys_ent->d_name, ".") | |
1343 | || !strcmp(sys_ent->d_name, "..") | |
1344 | || !strcmp(sys_ent->d_name, "enable") | |
1345 | || !strcmp(sys_ent->d_name, "filter")) | |
1346 | continue; | |
1347 | ||
1348 | cnt++; | |
1349 | } | |
1350 | ||
1351 | closedir(sys_dir); | |
1352 | } | |
1353 | ||
1354 | closedir(events_dir); | |
1355 | return cnt; | |
1356 | } | |
1357 | ||
1358 | static int test__all_tracepoints(struct perf_evlist *evlist) | |
1359 | { | |
1360 | TEST_ASSERT_VAL("wrong events count", | |
1361 | count_tracepoints() == evlist->nr_entries); | |
1362 | ||
1363 | return test__checkevent_tracepoint_multi(evlist); | |
1364 | } | |
1365 | ||
23b6339b | 1366 | struct evlist_test { |
f50246e2 JO |
1367 | const char *name; |
1368 | __u32 type; | |
615b8f99 | 1369 | const int id; |
f50246e2 JO |
1370 | int (*check)(struct perf_evlist *evlist); |
1371 | }; | |
1372 | ||
23b6339b | 1373 | static struct evlist_test test__events[] = { |
615b8f99 | 1374 | { |
43f322b4 | 1375 | .name = "syscalls:sys_enter_openat", |
f50246e2 | 1376 | .check = test__checkevent_tracepoint, |
615b8f99 | 1377 | .id = 0, |
f50246e2 | 1378 | }, |
615b8f99 | 1379 | { |
f50246e2 JO |
1380 | .name = "syscalls:*", |
1381 | .check = test__checkevent_tracepoint_multi, | |
615b8f99 | 1382 | .id = 1, |
f50246e2 | 1383 | }, |
615b8f99 | 1384 | { |
f50246e2 JO |
1385 | .name = "r1a", |
1386 | .check = test__checkevent_raw, | |
615b8f99 | 1387 | .id = 2, |
f50246e2 | 1388 | }, |
615b8f99 | 1389 | { |
f50246e2 JO |
1390 | .name = "1:1", |
1391 | .check = test__checkevent_numeric, | |
615b8f99 | 1392 | .id = 3, |
f50246e2 | 1393 | }, |
615b8f99 | 1394 | { |
f50246e2 JO |
1395 | .name = "instructions", |
1396 | .check = test__checkevent_symbolic_name, | |
615b8f99 | 1397 | .id = 4, |
f50246e2 | 1398 | }, |
615b8f99 | 1399 | { |
f50246e2 JO |
1400 | .name = "cycles/period=100000,config2/", |
1401 | .check = test__checkevent_symbolic_name_config, | |
615b8f99 | 1402 | .id = 5, |
f50246e2 | 1403 | }, |
615b8f99 | 1404 | { |
f50246e2 JO |
1405 | .name = "faults", |
1406 | .check = test__checkevent_symbolic_alias, | |
615b8f99 | 1407 | .id = 6, |
f50246e2 | 1408 | }, |
615b8f99 | 1409 | { |
f50246e2 JO |
1410 | .name = "L1-dcache-load-miss", |
1411 | .check = test__checkevent_genhw, | |
615b8f99 | 1412 | .id = 7, |
f50246e2 | 1413 | }, |
615b8f99 | 1414 | { |
f50246e2 JO |
1415 | .name = "mem:0", |
1416 | .check = test__checkevent_breakpoint, | |
615b8f99 | 1417 | .id = 8, |
f50246e2 | 1418 | }, |
615b8f99 | 1419 | { |
f50246e2 JO |
1420 | .name = "mem:0:x", |
1421 | .check = test__checkevent_breakpoint_x, | |
615b8f99 | 1422 | .id = 9, |
f50246e2 | 1423 | }, |
615b8f99 | 1424 | { |
f50246e2 JO |
1425 | .name = "mem:0:r", |
1426 | .check = test__checkevent_breakpoint_r, | |
615b8f99 | 1427 | .id = 10, |
f50246e2 | 1428 | }, |
615b8f99 | 1429 | { |
f50246e2 JO |
1430 | .name = "mem:0:w", |
1431 | .check = test__checkevent_breakpoint_w, | |
615b8f99 | 1432 | .id = 11, |
f50246e2 | 1433 | }, |
615b8f99 | 1434 | { |
43f322b4 | 1435 | .name = "syscalls:sys_enter_openat:k", |
f50246e2 | 1436 | .check = test__checkevent_tracepoint_modifier, |
615b8f99 | 1437 | .id = 12, |
f50246e2 | 1438 | }, |
615b8f99 | 1439 | { |
f50246e2 JO |
1440 | .name = "syscalls:*:u", |
1441 | .check = test__checkevent_tracepoint_multi_modifier, | |
615b8f99 | 1442 | .id = 13, |
f50246e2 | 1443 | }, |
615b8f99 | 1444 | { |
f50246e2 JO |
1445 | .name = "r1a:kp", |
1446 | .check = test__checkevent_raw_modifier, | |
615b8f99 | 1447 | .id = 14, |
f50246e2 | 1448 | }, |
615b8f99 | 1449 | { |
f50246e2 JO |
1450 | .name = "1:1:hp", |
1451 | .check = test__checkevent_numeric_modifier, | |
615b8f99 | 1452 | .id = 15, |
f50246e2 | 1453 | }, |
615b8f99 | 1454 | { |
f50246e2 JO |
1455 | .name = "instructions:h", |
1456 | .check = test__checkevent_symbolic_name_modifier, | |
615b8f99 | 1457 | .id = 16, |
f50246e2 | 1458 | }, |
615b8f99 | 1459 | { |
f50246e2 JO |
1460 | .name = "faults:u", |
1461 | .check = test__checkevent_symbolic_alias_modifier, | |
615b8f99 | 1462 | .id = 17, |
f50246e2 | 1463 | }, |
615b8f99 | 1464 | { |
f50246e2 JO |
1465 | .name = "L1-dcache-load-miss:kp", |
1466 | .check = test__checkevent_genhw_modifier, | |
615b8f99 | 1467 | .id = 18, |
f50246e2 | 1468 | }, |
615b8f99 | 1469 | { |
f50246e2 JO |
1470 | .name = "mem:0:u", |
1471 | .check = test__checkevent_breakpoint_modifier, | |
615b8f99 | 1472 | .id = 19, |
f50246e2 | 1473 | }, |
615b8f99 | 1474 | { |
f50246e2 JO |
1475 | .name = "mem:0:x:k", |
1476 | .check = test__checkevent_breakpoint_x_modifier, | |
615b8f99 | 1477 | .id = 20, |
f50246e2 | 1478 | }, |
615b8f99 | 1479 | { |
f50246e2 JO |
1480 | .name = "mem:0:r:hp", |
1481 | .check = test__checkevent_breakpoint_r_modifier, | |
615b8f99 | 1482 | .id = 21, |
f50246e2 | 1483 | }, |
615b8f99 | 1484 | { |
f50246e2 JO |
1485 | .name = "mem:0:w:up", |
1486 | .check = test__checkevent_breakpoint_w_modifier, | |
615b8f99 | 1487 | .id = 22, |
f50246e2 | 1488 | }, |
615b8f99 | 1489 | { |
43f322b4 | 1490 | .name = "r1,syscalls:sys_enter_openat:k,1:1:hp", |
f50246e2 | 1491 | .check = test__checkevent_list, |
615b8f99 | 1492 | .id = 23, |
f50246e2 | 1493 | }, |
615b8f99 | 1494 | { |
f50246e2 JO |
1495 | .name = "instructions:G", |
1496 | .check = test__checkevent_exclude_host_modifier, | |
615b8f99 | 1497 | .id = 24, |
f50246e2 | 1498 | }, |
615b8f99 | 1499 | { |
f50246e2 JO |
1500 | .name = "instructions:H", |
1501 | .check = test__checkevent_exclude_guest_modifier, | |
615b8f99 | 1502 | .id = 25, |
f50246e2 | 1503 | }, |
615b8f99 | 1504 | { |
7582732f JO |
1505 | .name = "mem:0:rw", |
1506 | .check = test__checkevent_breakpoint_rw, | |
615b8f99 | 1507 | .id = 26, |
7582732f | 1508 | }, |
615b8f99 | 1509 | { |
7582732f JO |
1510 | .name = "mem:0:rw:kp", |
1511 | .check = test__checkevent_breakpoint_rw_modifier, | |
615b8f99 | 1512 | .id = 27, |
7582732f | 1513 | }, |
615b8f99 | 1514 | { |
905f5ee2 JO |
1515 | .name = "{instructions:k,cycles:upp}", |
1516 | .check = test__group1, | |
615b8f99 | 1517 | .id = 28, |
905f5ee2 | 1518 | }, |
615b8f99 | 1519 | { |
905f5ee2 JO |
1520 | .name = "{faults:k,cache-references}:u,cycles:k", |
1521 | .check = test__group2, | |
615b8f99 | 1522 | .id = 29, |
905f5ee2 | 1523 | }, |
615b8f99 | 1524 | { |
43f322b4 | 1525 | .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", |
905f5ee2 | 1526 | .check = test__group3, |
615b8f99 | 1527 | .id = 30, |
905f5ee2 | 1528 | }, |
615b8f99 | 1529 | { |
905f5ee2 JO |
1530 | .name = "{cycles:u,instructions:kp}:p", |
1531 | .check = test__group4, | |
615b8f99 | 1532 | .id = 31, |
905f5ee2 | 1533 | }, |
615b8f99 | 1534 | { |
905f5ee2 JO |
1535 | .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", |
1536 | .check = test__group5, | |
615b8f99 | 1537 | .id = 32, |
905f5ee2 | 1538 | }, |
615b8f99 | 1539 | { |
82ce75d9 JO |
1540 | .name = "*:*", |
1541 | .check = test__all_tracepoints, | |
615b8f99 | 1542 | .id = 33, |
82ce75d9 | 1543 | }, |
615b8f99 | 1544 | { |
5a30a99f JO |
1545 | .name = "{cycles,cache-misses:G}:H", |
1546 | .check = test__group_gh1, | |
615b8f99 | 1547 | .id = 34, |
5a30a99f | 1548 | }, |
615b8f99 | 1549 | { |
5a30a99f JO |
1550 | .name = "{cycles,cache-misses:H}:G", |
1551 | .check = test__group_gh2, | |
615b8f99 | 1552 | .id = 35, |
5a30a99f | 1553 | }, |
615b8f99 | 1554 | { |
5a30a99f JO |
1555 | .name = "{cycles:G,cache-misses:H}:u", |
1556 | .check = test__group_gh3, | |
615b8f99 | 1557 | .id = 36, |
5a30a99f | 1558 | }, |
615b8f99 | 1559 | { |
5a30a99f JO |
1560 | .name = "{cycles:G,cache-misses:H}:uG", |
1561 | .check = test__group_gh4, | |
615b8f99 | 1562 | .id = 37, |
5a30a99f | 1563 | }, |
615b8f99 | 1564 | { |
a9f93f97 JO |
1565 | .name = "{cycles,cache-misses,branch-misses}:S", |
1566 | .check = test__leader_sample1, | |
615b8f99 | 1567 | .id = 38, |
a9f93f97 | 1568 | }, |
615b8f99 | 1569 | { |
a9f93f97 JO |
1570 | .name = "{instructions,branch-misses}:Su", |
1571 | .check = test__leader_sample2, | |
615b8f99 | 1572 | .id = 39, |
a9f93f97 | 1573 | }, |
615b8f99 | 1574 | { |
c9ee780f ME |
1575 | .name = "instructions:uDp", |
1576 | .check = test__checkevent_pinned_modifier, | |
615b8f99 | 1577 | .id = 40, |
c9ee780f | 1578 | }, |
615b8f99 | 1579 | { |
c9ee780f ME |
1580 | .name = "{cycles,cache-misses,branch-misses}:D", |
1581 | .check = test__pinned_group, | |
615b8f99 | 1582 | .id = 41, |
c9ee780f | 1583 | }, |
ec32398c JS |
1584 | { |
1585 | .name = "mem:0/1", | |
1586 | .check = test__checkevent_breakpoint_len, | |
1587 | .id = 42, | |
1588 | }, | |
1589 | { | |
1590 | .name = "mem:0/2:w", | |
1591 | .check = test__checkevent_breakpoint_len_w, | |
1592 | .id = 43, | |
1593 | }, | |
1594 | { | |
1595 | .name = "mem:0/4:rw:u", | |
1596 | .check = test__checkevent_breakpoint_len_rw_modifier, | |
1597 | .id = 44 | |
1598 | }, | |
c0bc8c6d AY |
1599 | #if defined(__s390x__) |
1600 | { | |
1601 | .name = "kvm-s390:kvm_s390_create_vm", | |
1602 | .check = test__checkevent_tracepoint, | |
1603 | .id = 100, | |
1604 | }, | |
1605 | #endif | |
a1e12da4 JO |
1606 | { |
1607 | .name = "instructions:I", | |
1608 | .check = test__checkevent_exclude_idle_modifier, | |
1609 | .id = 45, | |
1610 | }, | |
1611 | { | |
1612 | .name = "instructions:kIG", | |
1613 | .check = test__checkevent_exclude_idle_modifier_1, | |
1614 | .id = 46, | |
1615 | }, | |
ddd83c97 JO |
1616 | { |
1617 | .name = "task-clock:P,cycles", | |
1618 | .check = test__checkevent_precise_max_modifier, | |
1619 | .id = 47, | |
1620 | }, | |
10bf358a WN |
1621 | { |
1622 | .name = "instructions/name=insn/", | |
1623 | .check = test__checkevent_config_symbol, | |
1624 | .id = 48, | |
1625 | }, | |
1626 | { | |
1627 | .name = "r1234/name=rawpmu/", | |
1628 | .check = test__checkevent_config_raw, | |
1629 | .id = 49, | |
1630 | }, | |
1631 | { | |
1632 | .name = "4:0x6530160/name=numpmu/", | |
1633 | .check = test__checkevent_config_num, | |
1634 | .id = 50, | |
1635 | }, | |
43d0b978 WN |
1636 | { |
1637 | .name = "L1-dcache-misses/name=cachepmu/", | |
1638 | .check = test__checkevent_config_cache, | |
1639 | .id = 51, | |
1640 | }, | |
f50246e2 JO |
1641 | }; |
1642 | ||
23b6339b | 1643 | static struct evlist_test test__events_pmu[] = { |
615b8f99 | 1644 | { |
f50246e2 JO |
1645 | .name = "cpu/config=10,config1,config2=3,period=1000/u", |
1646 | .check = test__checkevent_pmu, | |
615b8f99 | 1647 | .id = 0, |
f50246e2 | 1648 | }, |
615b8f99 | 1649 | { |
6b5fc39b JO |
1650 | .name = "cpu/config=1,name=krava/u,cpu/config=2/u", |
1651 | .check = test__checkevent_pmu_name, | |
615b8f99 | 1652 | .id = 1, |
6b5fc39b | 1653 | }, |
71ef150e KL |
1654 | { |
1655 | .name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/", | |
1656 | .check = test__checkevent_pmu_partial_time_callgraph, | |
1657 | .id = 2, | |
1658 | }, | |
f50246e2 JO |
1659 | }; |
1660 | ||
23b6339b | 1661 | struct terms_test { |
4429392e JO |
1662 | const char *str; |
1663 | __u32 type; | |
1664 | int (*check)(struct list_head *terms); | |
1665 | }; | |
1666 | ||
23b6339b | 1667 | static struct terms_test test__terms[] = { |
4429392e JO |
1668 | [0] = { |
1669 | .str = "config=10,config1,config2=3,umask=1", | |
1670 | .check = test__checkterms_simple, | |
1671 | }, | |
1672 | }; | |
1673 | ||
23b6339b | 1674 | static int test_event(struct evlist_test *e) |
f50246e2 JO |
1675 | { |
1676 | struct perf_evlist *evlist; | |
1677 | int ret; | |
1678 | ||
334fe7a3 | 1679 | evlist = perf_evlist__new(); |
f50246e2 JO |
1680 | if (evlist == NULL) |
1681 | return -ENOMEM; | |
1682 | ||
b39b8393 | 1683 | ret = parse_events(evlist, e->name, NULL); |
f50246e2 JO |
1684 | if (ret) { |
1685 | pr_debug("failed to parse event '%s', err %d\n", | |
1686 | e->name, ret); | |
2d4352c0 ACM |
1687 | } else { |
1688 | ret = e->check(evlist); | |
f50246e2 | 1689 | } |
48000a1a | 1690 | |
f50246e2 JO |
1691 | perf_evlist__delete(evlist); |
1692 | ||
1693 | return ret; | |
1694 | } | |
1695 | ||
23b6339b | 1696 | static int test_events(struct evlist_test *events, unsigned cnt) |
f50246e2 | 1697 | { |
9bfbbc6d | 1698 | int ret1, ret2 = 0; |
f50246e2 JO |
1699 | unsigned i; |
1700 | ||
1701 | for (i = 0; i < cnt; i++) { | |
23b6339b | 1702 | struct evlist_test *e = &events[i]; |
f50246e2 | 1703 | |
615b8f99 | 1704 | pr_debug("running test %d '%s'\n", e->id, e->name); |
9bfbbc6d RR |
1705 | ret1 = test_event(e); |
1706 | if (ret1) | |
1707 | ret2 = ret1; | |
4429392e JO |
1708 | } |
1709 | ||
9bfbbc6d | 1710 | return ret2; |
4429392e JO |
1711 | } |
1712 | ||
23b6339b | 1713 | static int test_term(struct terms_test *t) |
4429392e | 1714 | { |
c549aca5 | 1715 | struct list_head terms; |
4429392e JO |
1716 | int ret; |
1717 | ||
c549aca5 | 1718 | INIT_LIST_HEAD(&terms); |
4429392e | 1719 | |
c549aca5 | 1720 | ret = parse_events_terms(&terms, t->str); |
4429392e JO |
1721 | if (ret) { |
1722 | pr_debug("failed to parse terms '%s', err %d\n", | |
1723 | t->str , ret); | |
1724 | return ret; | |
1725 | } | |
1726 | ||
c549aca5 | 1727 | ret = t->check(&terms); |
682dc24c | 1728 | parse_events_terms__purge(&terms); |
4429392e JO |
1729 | |
1730 | return ret; | |
1731 | } | |
1732 | ||
23b6339b | 1733 | static int test_terms(struct terms_test *terms, unsigned cnt) |
4429392e JO |
1734 | { |
1735 | int ret = 0; | |
1736 | unsigned i; | |
1737 | ||
1738 | for (i = 0; i < cnt; i++) { | |
23b6339b | 1739 | struct terms_test *t = &terms[i]; |
4429392e JO |
1740 | |
1741 | pr_debug("running test %d '%s'\n", i, t->str); | |
1742 | ret = test_term(t); | |
f50246e2 JO |
1743 | if (ret) |
1744 | break; | |
1745 | } | |
1746 | ||
1747 | return ret; | |
1748 | } | |
1749 | ||
1750 | static int test_pmu(void) | |
1751 | { | |
1752 | struct stat st; | |
1753 | char path[PATH_MAX]; | |
1754 | int ret; | |
1755 | ||
1756 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", | |
cf38fada | 1757 | sysfs__mountpoint()); |
f50246e2 JO |
1758 | |
1759 | ret = stat(path, &st); | |
1760 | if (ret) | |
3fd44cd4 | 1761 | pr_debug("omitting PMU cpu tests\n"); |
f50246e2 JO |
1762 | return !ret; |
1763 | } | |
1764 | ||
3f3a2064 JO |
1765 | static int test_pmu_events(void) |
1766 | { | |
1767 | struct stat st; | |
1768 | char path[PATH_MAX]; | |
1769 | struct dirent *ent; | |
1770 | DIR *dir; | |
1771 | int ret; | |
1772 | ||
1773 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", | |
cf38fada | 1774 | sysfs__mountpoint()); |
3f3a2064 JO |
1775 | |
1776 | ret = stat(path, &st); | |
1777 | if (ret) { | |
a895d57d | 1778 | pr_debug("omitting PMU cpu events tests\n"); |
3f3a2064 JO |
1779 | return 0; |
1780 | } | |
1781 | ||
1782 | dir = opendir(path); | |
1783 | if (!dir) { | |
1784 | pr_debug("can't open pmu event dir"); | |
1785 | return -1; | |
1786 | } | |
1787 | ||
1788 | while (!ret && (ent = readdir(dir))) { | |
23b6339b | 1789 | struct evlist_test e; |
2e2bbc03 | 1790 | char name[2 * NAME_MAX + 1 + 12 + 3]; |
3f3a2064 | 1791 | |
17a2634b AK |
1792 | /* Names containing . are special and cannot be used directly */ |
1793 | if (strchr(ent->d_name, '.')) | |
3f3a2064 JO |
1794 | continue; |
1795 | ||
2e2bbc03 | 1796 | snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name); |
3f3a2064 JO |
1797 | |
1798 | e.name = name; | |
1799 | e.check = test__checkevent_pmu_events; | |
1800 | ||
1801 | ret = test_event(&e); | |
ffe59788 KL |
1802 | if (ret) |
1803 | break; | |
2e2bbc03 | 1804 | snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name); |
ffe59788 KL |
1805 | e.name = name; |
1806 | e.check = test__checkevent_pmu_events_mix; | |
1807 | ret = test_event(&e); | |
3f3a2064 JO |
1808 | } |
1809 | ||
1810 | closedir(dir); | |
1811 | return ret; | |
1812 | } | |
1813 | ||
81f17c90 | 1814 | int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused) |
f50246e2 | 1815 | { |
9bfbbc6d | 1816 | int ret1, ret2 = 0; |
f50246e2 | 1817 | |
ebf124ff JO |
1818 | #define TEST_EVENTS(tests) \ |
1819 | do { \ | |
9bfbbc6d RR |
1820 | ret1 = test_events(tests, ARRAY_SIZE(tests)); \ |
1821 | if (!ret2) \ | |
1822 | ret2 = ret1; \ | |
ebf124ff | 1823 | } while (0) |
4429392e | 1824 | |
ebf124ff | 1825 | TEST_EVENTS(test__events); |
4429392e | 1826 | |
ebf124ff JO |
1827 | if (test_pmu()) |
1828 | TEST_EVENTS(test__events_pmu); | |
f50246e2 | 1829 | |
3f3a2064 JO |
1830 | if (test_pmu()) { |
1831 | int ret = test_pmu_events(); | |
1832 | if (ret) | |
1833 | return ret; | |
1834 | } | |
1835 | ||
9bfbbc6d RR |
1836 | ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); |
1837 | if (!ret2) | |
1838 | ret2 = ret1; | |
1839 | ||
1840 | return ret2; | |
f50246e2 | 1841 | } |