2 #include "parse-events.h"
6 #include <api/fs/debugfs.h>
9 #include <linux/hw_breakpoint.h>
11 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
12 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
14 static int test__checkevent_tracepoint(struct perf_evlist *evlist)
16 struct perf_evsel *evsel = perf_evlist__first(evlist);
18 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
19 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
20 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
21 TEST_ASSERT_VAL("wrong sample_type",
22 PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
23 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
27 static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist)
29 struct perf_evsel *evsel;
31 TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
32 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
34 evlist__for_each(evlist, evsel) {
35 TEST_ASSERT_VAL("wrong type",
36 PERF_TYPE_TRACEPOINT == evsel->attr.type);
37 TEST_ASSERT_VAL("wrong sample_type",
38 PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
39 TEST_ASSERT_VAL("wrong sample_period",
40 1 == evsel->attr.sample_period);
45 static int test__checkevent_raw(struct perf_evlist *evlist)
47 struct perf_evsel *evsel = perf_evlist__first(evlist);
49 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
50 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
51 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config);
55 static int test__checkevent_numeric(struct perf_evlist *evlist)
57 struct perf_evsel *evsel = perf_evlist__first(evlist);
59 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
60 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
61 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
65 static int test__checkevent_symbolic_name(struct perf_evlist *evlist)
67 struct perf_evsel *evsel = perf_evlist__first(evlist);
69 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
70 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
71 TEST_ASSERT_VAL("wrong config",
72 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
76 static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
78 struct perf_evsel *evsel = perf_evlist__first(evlist);
80 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
81 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
82 TEST_ASSERT_VAL("wrong config",
83 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
84 TEST_ASSERT_VAL("wrong period",
85 100000 == evsel->attr.sample_period);
86 TEST_ASSERT_VAL("wrong config1",
87 0 == evsel->attr.config1);
88 TEST_ASSERT_VAL("wrong config2",
89 1 == evsel->attr.config2);
93 static int test__checkevent_symbolic_alias(struct perf_evlist *evlist)
95 struct perf_evsel *evsel = perf_evlist__first(evlist);
97 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
98 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
99 TEST_ASSERT_VAL("wrong config",
100 PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
104 static int test__checkevent_genhw(struct perf_evlist *evlist)
106 struct perf_evsel *evsel = perf_evlist__first(evlist);
108 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
109 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type);
110 TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config);
114 static int test__checkevent_breakpoint(struct perf_evlist *evlist)
116 struct perf_evsel *evsel = perf_evlist__first(evlist);
118 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
119 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
120 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
121 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
122 evsel->attr.bp_type);
123 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
128 static int test__checkevent_breakpoint_x(struct perf_evlist *evlist)
130 struct perf_evsel *evsel = perf_evlist__first(evlist);
132 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
133 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
134 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
135 TEST_ASSERT_VAL("wrong bp_type",
136 HW_BREAKPOINT_X == evsel->attr.bp_type);
137 TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len);
141 static int test__checkevent_breakpoint_r(struct perf_evlist *evlist)
143 struct perf_evsel *evsel = perf_evlist__first(evlist);
145 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
146 TEST_ASSERT_VAL("wrong type",
147 PERF_TYPE_BREAKPOINT == evsel->attr.type);
148 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
149 TEST_ASSERT_VAL("wrong bp_type",
150 HW_BREAKPOINT_R == evsel->attr.bp_type);
151 TEST_ASSERT_VAL("wrong bp_len",
152 HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
156 static int test__checkevent_breakpoint_w(struct perf_evlist *evlist)
158 struct perf_evsel *evsel = perf_evlist__first(evlist);
160 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
161 TEST_ASSERT_VAL("wrong type",
162 PERF_TYPE_BREAKPOINT == evsel->attr.type);
163 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
164 TEST_ASSERT_VAL("wrong bp_type",
165 HW_BREAKPOINT_W == evsel->attr.bp_type);
166 TEST_ASSERT_VAL("wrong bp_len",
167 HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
171 static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist)
173 struct perf_evsel *evsel = perf_evlist__first(evlist);
175 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
176 TEST_ASSERT_VAL("wrong type",
177 PERF_TYPE_BREAKPOINT == evsel->attr.type);
178 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
179 TEST_ASSERT_VAL("wrong bp_type",
180 (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type);
181 TEST_ASSERT_VAL("wrong bp_len",
182 HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
186 static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist)
188 struct perf_evsel *evsel = perf_evlist__first(evlist);
190 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
191 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
192 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
193 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
195 return test__checkevent_tracepoint(evlist);
199 test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist)
201 struct perf_evsel *evsel;
203 TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
205 evlist__for_each(evlist, evsel) {
206 TEST_ASSERT_VAL("wrong exclude_user",
207 !evsel->attr.exclude_user);
208 TEST_ASSERT_VAL("wrong exclude_kernel",
209 evsel->attr.exclude_kernel);
210 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
211 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
214 return test__checkevent_tracepoint_multi(evlist);
217 static int test__checkevent_raw_modifier(struct perf_evlist *evlist)
219 struct perf_evsel *evsel = perf_evlist__first(evlist);
221 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
222 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
223 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
224 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
226 return test__checkevent_raw(evlist);
229 static int test__checkevent_numeric_modifier(struct perf_evlist *evlist)
231 struct perf_evsel *evsel = perf_evlist__first(evlist);
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);
238 return test__checkevent_numeric(evlist);
241 static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
243 struct perf_evsel *evsel = perf_evlist__first(evlist);
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);
250 return test__checkevent_symbolic_name(evlist);
253 static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist)
255 struct perf_evsel *evsel = perf_evlist__first(evlist);
257 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
258 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
260 return test__checkevent_symbolic_name(evlist);
263 static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist)
265 struct perf_evsel *evsel = perf_evlist__first(evlist);
267 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
268 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
270 return test__checkevent_symbolic_name(evlist);
273 static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
275 struct perf_evsel *evsel = perf_evlist__first(evlist);
277 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
278 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
279 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
280 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
282 return test__checkevent_symbolic_alias(evlist);
285 static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
287 struct perf_evsel *evsel = perf_evlist__first(evlist);
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);
294 return test__checkevent_genhw(evlist);
297 static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist)
299 struct perf_evsel *evsel = perf_evlist__first(evlist);
302 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
303 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
304 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
305 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
306 TEST_ASSERT_VAL("wrong name",
307 !strcmp(perf_evsel__name(evsel), "mem:0:u"));
309 return test__checkevent_breakpoint(evlist);
312 static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist)
314 struct perf_evsel *evsel = perf_evlist__first(evlist);
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 TEST_ASSERT_VAL("wrong name",
321 !strcmp(perf_evsel__name(evsel), "mem:0:x:k"));
323 return test__checkevent_breakpoint_x(evlist);
326 static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
328 struct perf_evsel *evsel = perf_evlist__first(evlist);
330 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
331 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
332 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
333 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
334 TEST_ASSERT_VAL("wrong name",
335 !strcmp(perf_evsel__name(evsel), "mem:0:r:hp"));
337 return test__checkevent_breakpoint_r(evlist);
340 static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
342 struct perf_evsel *evsel = perf_evlist__first(evlist);
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);
348 TEST_ASSERT_VAL("wrong name",
349 !strcmp(perf_evsel__name(evsel), "mem:0:w:up"));
351 return test__checkevent_breakpoint_w(evlist);
354 static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist)
356 struct perf_evsel *evsel = perf_evlist__first(evlist);
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);
362 TEST_ASSERT_VAL("wrong name",
363 !strcmp(perf_evsel__name(evsel), "mem:0:rw:kp"));
365 return test__checkevent_breakpoint_rw(evlist);
368 static int test__checkevent_pmu(struct perf_evlist *evlist)
371 struct perf_evsel *evsel = perf_evlist__first(evlist);
373 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
374 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
375 TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
376 TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
377 TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
378 TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period);
383 static int test__checkevent_list(struct perf_evlist *evlist)
385 struct perf_evsel *evsel = perf_evlist__first(evlist);
387 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
390 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
391 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
392 TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1);
393 TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2);
394 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
395 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
396 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
397 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
399 /* syscalls:sys_enter_open:k */
400 evsel = perf_evsel__next(evsel);
401 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
402 TEST_ASSERT_VAL("wrong sample_type",
403 PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
404 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
405 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
406 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
407 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
408 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
411 evsel = perf_evsel__next(evsel);
412 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
413 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
414 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
415 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
416 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
417 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
422 static int test__checkevent_pmu_name(struct perf_evlist *evlist)
424 struct perf_evsel *evsel = perf_evlist__first(evlist);
426 /* cpu/config=1,name=krava/u */
427 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
428 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
429 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
430 TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava"));
432 /* cpu/config=2/u" */
433 evsel = perf_evsel__next(evsel);
434 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
435 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
436 TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config);
437 TEST_ASSERT_VAL("wrong name",
438 !strcmp(perf_evsel__name(evsel), "cpu/config=2/u"));
443 static int test__checkevent_pmu_events(struct perf_evlist *evlist)
445 struct perf_evsel *evsel = perf_evlist__first(evlist);
447 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
448 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
449 TEST_ASSERT_VAL("wrong exclude_user",
450 !evsel->attr.exclude_user);
451 TEST_ASSERT_VAL("wrong exclude_kernel",
452 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 TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
461 static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist)
463 struct perf_evsel *evsel = perf_evlist__first(evlist);
466 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
467 TEST_ASSERT_VAL("wrong exclude_user",
468 !evsel->attr.exclude_user);
469 TEST_ASSERT_VAL("wrong exclude_kernel",
470 evsel->attr.exclude_kernel);
471 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
472 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
473 TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
476 evsel = perf_evsel__next(evsel);
477 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
478 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
479 TEST_ASSERT_VAL("wrong exclude_user",
480 !evsel->attr.exclude_user);
481 TEST_ASSERT_VAL("wrong exclude_kernel",
482 evsel->attr.exclude_kernel);
483 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
484 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
485 TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
490 static int test__checkterms_simple(struct list_head *terms)
492 struct parse_events_term *term;
495 term = list_entry(terms->next, struct parse_events_term, list);
496 TEST_ASSERT_VAL("wrong type term",
497 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
498 TEST_ASSERT_VAL("wrong type val",
499 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
500 TEST_ASSERT_VAL("wrong val", term->val.num == 10);
501 TEST_ASSERT_VAL("wrong config", !term->config);
504 term = list_entry(term->list.next, struct parse_events_term, list);
505 TEST_ASSERT_VAL("wrong type term",
506 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
507 TEST_ASSERT_VAL("wrong type val",
508 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
509 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
510 TEST_ASSERT_VAL("wrong config", !term->config);
513 term = list_entry(term->list.next, struct parse_events_term, list);
514 TEST_ASSERT_VAL("wrong type term",
515 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
516 TEST_ASSERT_VAL("wrong type val",
517 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
518 TEST_ASSERT_VAL("wrong val", term->val.num == 3);
519 TEST_ASSERT_VAL("wrong config", !term->config);
522 term = list_entry(term->list.next, struct parse_events_term, list);
523 TEST_ASSERT_VAL("wrong type term",
524 term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
525 TEST_ASSERT_VAL("wrong type val",
526 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
527 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
528 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
533 static int test__group1(struct perf_evlist *evlist)
535 struct perf_evsel *evsel, *leader;
537 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
538 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
541 evsel = leader = perf_evlist__first(evlist);
542 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
543 TEST_ASSERT_VAL("wrong config",
544 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
545 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
546 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
547 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
548 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
549 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
550 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
551 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
552 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
553 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
554 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
557 evsel = perf_evsel__next(evsel);
558 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
559 TEST_ASSERT_VAL("wrong config",
560 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
561 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
562 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
563 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
564 /* use of precise requires exclude_guest */
565 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
566 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
567 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
568 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
569 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
570 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
575 static int test__group2(struct perf_evlist *evlist)
577 struct perf_evsel *evsel, *leader;
579 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
580 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
582 /* faults + :ku modifier */
583 evsel = leader = perf_evlist__first(evlist);
584 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
585 TEST_ASSERT_VAL("wrong config",
586 PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
587 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
588 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
589 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
590 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
591 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
592 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
593 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
594 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
595 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
596 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
598 /* cache-references + :u modifier */
599 evsel = perf_evsel__next(evsel);
600 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
601 TEST_ASSERT_VAL("wrong config",
602 PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config);
603 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
604 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
605 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
606 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
607 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
608 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
609 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
610 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
611 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
614 evsel = perf_evsel__next(evsel);
615 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
616 TEST_ASSERT_VAL("wrong config",
617 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
618 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
619 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
620 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
621 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
622 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
623 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
624 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
625 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
630 static int test__group3(struct perf_evlist *evlist __maybe_unused)
632 struct perf_evsel *evsel, *leader;
634 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
635 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
637 /* group1 syscalls:sys_enter_open:H */
638 evsel = leader = perf_evlist__first(evlist);
639 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
640 TEST_ASSERT_VAL("wrong sample_type",
641 PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
642 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
643 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
644 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
645 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
646 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
647 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
648 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
649 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
650 TEST_ASSERT_VAL("wrong group name",
651 !strcmp(leader->group_name, "group1"));
652 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
653 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
654 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
656 /* group1 cycles:kppp */
657 evsel = perf_evsel__next(evsel);
658 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
659 TEST_ASSERT_VAL("wrong config",
660 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
661 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
662 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
663 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
664 /* use of precise requires exclude_guest */
665 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
666 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
667 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3);
668 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
669 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
670 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
671 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
673 /* group2 cycles + G modifier */
674 evsel = leader = perf_evsel__next(evsel);
675 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
676 TEST_ASSERT_VAL("wrong config",
677 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
678 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
679 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
680 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
681 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
682 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
683 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
684 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
685 TEST_ASSERT_VAL("wrong group name",
686 !strcmp(leader->group_name, "group2"));
687 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
688 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
689 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
691 /* group2 1:3 + G modifier */
692 evsel = perf_evsel__next(evsel);
693 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
694 TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config);
695 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
696 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
697 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
698 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
699 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
700 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
701 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
702 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
703 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
706 evsel = perf_evsel__next(evsel);
707 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
708 TEST_ASSERT_VAL("wrong config",
709 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
710 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
711 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
712 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
713 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
714 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
715 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
716 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
717 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
722 static int test__group4(struct perf_evlist *evlist __maybe_unused)
724 struct perf_evsel *evsel, *leader;
726 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
727 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
730 evsel = leader = perf_evlist__first(evlist);
731 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
732 TEST_ASSERT_VAL("wrong config",
733 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
734 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
735 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
736 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
737 /* use of precise requires exclude_guest */
738 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
739 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
740 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1);
741 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
742 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
743 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
744 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
745 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
747 /* instructions:kp + p */
748 evsel = perf_evsel__next(evsel);
749 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
750 TEST_ASSERT_VAL("wrong config",
751 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
752 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
753 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
754 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
755 /* use of precise requires exclude_guest */
756 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
757 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
758 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
759 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
760 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
761 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
766 static int test__group5(struct perf_evlist *evlist __maybe_unused)
768 struct perf_evsel *evsel, *leader;
770 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
771 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
774 evsel = leader = perf_evlist__first(evlist);
775 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
776 TEST_ASSERT_VAL("wrong config",
777 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
778 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
779 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
780 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
781 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
782 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
783 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
784 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
785 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
786 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
787 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
788 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
790 /* instructions + G */
791 evsel = perf_evsel__next(evsel);
792 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
793 TEST_ASSERT_VAL("wrong config",
794 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
795 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
796 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
797 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
798 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
799 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
800 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
801 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
802 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
803 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
806 evsel = leader = perf_evsel__next(evsel);
807 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
808 TEST_ASSERT_VAL("wrong config",
809 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
810 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
811 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
812 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
813 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
814 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
815 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
816 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
817 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
818 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
819 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
820 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
823 evsel = perf_evsel__next(evsel);
824 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
825 TEST_ASSERT_VAL("wrong config",
826 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
827 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
828 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
829 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
830 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
831 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
832 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
833 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
834 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
837 evsel = perf_evsel__next(evsel);
838 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
839 TEST_ASSERT_VAL("wrong config",
840 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
841 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
842 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
843 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
844 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
845 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
846 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
847 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
852 static int test__group_gh1(struct perf_evlist *evlist)
854 struct perf_evsel *evsel, *leader;
856 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
857 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
859 /* cycles + :H group modifier */
860 evsel = leader = perf_evlist__first(evlist);
861 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
862 TEST_ASSERT_VAL("wrong config",
863 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
864 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
865 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
866 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
867 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
868 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
869 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
870 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
871 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
872 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
873 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
875 /* cache-misses:G + :H group modifier */
876 evsel = perf_evsel__next(evsel);
877 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
878 TEST_ASSERT_VAL("wrong config",
879 PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
880 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
881 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
882 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
883 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
884 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
885 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
886 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
887 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
892 static int test__group_gh2(struct perf_evlist *evlist)
894 struct perf_evsel *evsel, *leader;
896 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
897 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
899 /* cycles + :G group modifier */
900 evsel = leader = perf_evlist__first(evlist);
901 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
902 TEST_ASSERT_VAL("wrong config",
903 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
904 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
905 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
906 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
907 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
908 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
909 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
910 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
911 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
912 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
913 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
915 /* cache-misses:H + :G group modifier */
916 evsel = perf_evsel__next(evsel);
917 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
918 TEST_ASSERT_VAL("wrong config",
919 PERF_COUNT_HW_CACHE_MISSES == 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);
926 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
927 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
932 static int test__group_gh3(struct perf_evlist *evlist)
934 struct perf_evsel *evsel, *leader;
936 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
937 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
939 /* cycles:G + :u group modifier */
940 evsel = leader = perf_evlist__first(evlist);
941 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
942 TEST_ASSERT_VAL("wrong config",
943 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
944 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
945 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
946 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
947 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
948 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
949 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
950 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
951 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
952 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
953 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
955 /* cache-misses:H + :u group modifier */
956 evsel = perf_evsel__next(evsel);
957 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
958 TEST_ASSERT_VAL("wrong config",
959 PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
960 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
961 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
962 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
963 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
964 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
965 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
966 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
967 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
972 static int test__group_gh4(struct perf_evlist *evlist)
974 struct perf_evsel *evsel, *leader;
976 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
977 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
979 /* cycles:G + :uG group modifier */
980 evsel = leader = perf_evlist__first(evlist);
981 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
982 TEST_ASSERT_VAL("wrong config",
983 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
984 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
985 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
986 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
987 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
988 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
989 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
990 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
991 TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
992 TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
993 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
995 /* cache-misses:H + :uG group modifier */
996 evsel = perf_evsel__next(evsel);
997 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
998 TEST_ASSERT_VAL("wrong config",
999 PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
1000 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1001 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
1002 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
1003 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
1004 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
1005 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
1006 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1007 TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
1012 static int test__leader_sample1(struct perf_evlist *evlist)
1014 struct perf_evsel *evsel, *leader;
1016 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
1018 /* cycles - sampling group leader */
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", evsel->leader == leader);
1031 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1033 /* cache-misses - not sampling */
1034 evsel = perf_evsel__next(evsel);
1035 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
1036 TEST_ASSERT_VAL("wrong config",
1037 PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
1038 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1039 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
1040 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
1041 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
1042 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
1043 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
1044 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1045 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1047 /* branch-misses - not sampling */
1048 evsel = perf_evsel__next(evsel);
1049 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
1050 TEST_ASSERT_VAL("wrong config",
1051 PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config);
1052 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1053 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
1054 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
1055 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
1056 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
1057 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
1058 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1059 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1060 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1065 static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused)
1067 struct perf_evsel *evsel, *leader;
1069 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
1071 /* instructions - sampling group leader */
1072 evsel = leader = perf_evlist__first(evlist);
1073 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
1074 TEST_ASSERT_VAL("wrong config",
1075 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
1076 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1077 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
1078 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
1079 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
1080 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
1081 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
1082 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1083 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1084 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1086 /* branch-misses - not sampling */
1087 evsel = perf_evsel__next(evsel);
1088 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
1089 TEST_ASSERT_VAL("wrong config",
1090 PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config);
1091 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1092 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
1093 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
1094 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
1095 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
1096 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
1097 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1098 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1099 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1104 static int test__checkevent_pinned_modifier(struct perf_evlist *evlist)
1106 struct perf_evsel *evsel = perf_evlist__first(evlist);
1108 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1109 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
1110 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
1111 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
1112 TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned);
1114 return test__checkevent_symbolic_name(evlist);
1117 static int test__pinned_group(struct perf_evlist *evlist)
1119 struct perf_evsel *evsel, *leader;
1121 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
1123 /* cycles - group leader */
1124 evsel = leader = perf_evlist__first(evlist);
1125 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
1126 TEST_ASSERT_VAL("wrong config",
1127 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
1128 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1129 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1130 TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned);
1132 /* cache-misses - can not be pinned, but will go on with the leader */
1133 evsel = perf_evsel__next(evsel);
1134 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
1135 TEST_ASSERT_VAL("wrong config",
1136 PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
1137 TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
1139 /* branch-misses - ditto */
1140 evsel = perf_evsel__next(evsel);
1141 TEST_ASSERT_VAL("wrong config",
1142 PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config);
1143 TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
1148 static int test__checkevent_breakpoint_len(struct perf_evlist *evlist)
1150 struct perf_evsel *evsel = perf_evlist__first(evlist);
1152 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
1153 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
1154 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
1155 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
1156 evsel->attr.bp_type);
1157 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
1158 evsel->attr.bp_len);
1163 static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist)
1165 struct perf_evsel *evsel = perf_evlist__first(evlist);
1167 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
1168 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
1169 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
1170 TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
1171 evsel->attr.bp_type);
1172 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
1173 evsel->attr.bp_len);
1179 test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)
1181 struct perf_evsel *evsel = perf_evlist__first(evlist);
1183 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
1184 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
1185 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
1186 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
1188 return test__checkevent_breakpoint_rw(evlist);
1191 static int count_tracepoints(void)
1193 char events_path[PATH_MAX];
1194 struct dirent *events_ent;
1198 scnprintf(events_path, PATH_MAX, "%s/tracing/events",
1199 debugfs_find_mountpoint());
1201 events_dir = opendir(events_path);
1203 TEST_ASSERT_VAL("Can't open events dir", events_dir);
1205 while ((events_ent = readdir(events_dir))) {
1206 char sys_path[PATH_MAX];
1207 struct dirent *sys_ent;
1210 if (!strcmp(events_ent->d_name, ".")
1211 || !strcmp(events_ent->d_name, "..")
1212 || !strcmp(events_ent->d_name, "enable")
1213 || !strcmp(events_ent->d_name, "header_event")
1214 || !strcmp(events_ent->d_name, "header_page"))
1217 scnprintf(sys_path, PATH_MAX, "%s/%s",
1218 events_path, events_ent->d_name);
1220 sys_dir = opendir(sys_path);
1221 TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
1223 while ((sys_ent = readdir(sys_dir))) {
1224 if (!strcmp(sys_ent->d_name, ".")
1225 || !strcmp(sys_ent->d_name, "..")
1226 || !strcmp(sys_ent->d_name, "enable")
1227 || !strcmp(sys_ent->d_name, "filter"))
1236 closedir(events_dir);
1240 static int test__all_tracepoints(struct perf_evlist *evlist)
1242 TEST_ASSERT_VAL("wrong events count",
1243 count_tracepoints() == evlist->nr_entries);
1245 return test__checkevent_tracepoint_multi(evlist);
1248 struct evlist_test {
1252 int (*check)(struct perf_evlist *evlist);
1255 static struct evlist_test test__events[] = {
1257 .name = "syscalls:sys_enter_open",
1258 .check = test__checkevent_tracepoint,
1262 .name = "syscalls:*",
1263 .check = test__checkevent_tracepoint_multi,
1268 .check = test__checkevent_raw,
1273 .check = test__checkevent_numeric,
1277 .name = "instructions",
1278 .check = test__checkevent_symbolic_name,
1282 .name = "cycles/period=100000,config2/",
1283 .check = test__checkevent_symbolic_name_config,
1288 .check = test__checkevent_symbolic_alias,
1292 .name = "L1-dcache-load-miss",
1293 .check = test__checkevent_genhw,
1298 .check = test__checkevent_breakpoint,
1303 .check = test__checkevent_breakpoint_x,
1308 .check = test__checkevent_breakpoint_r,
1313 .check = test__checkevent_breakpoint_w,
1317 .name = "syscalls:sys_enter_open:k",
1318 .check = test__checkevent_tracepoint_modifier,
1322 .name = "syscalls:*:u",
1323 .check = test__checkevent_tracepoint_multi_modifier,
1328 .check = test__checkevent_raw_modifier,
1333 .check = test__checkevent_numeric_modifier,
1337 .name = "instructions:h",
1338 .check = test__checkevent_symbolic_name_modifier,
1343 .check = test__checkevent_symbolic_alias_modifier,
1347 .name = "L1-dcache-load-miss:kp",
1348 .check = test__checkevent_genhw_modifier,
1353 .check = test__checkevent_breakpoint_modifier,
1357 .name = "mem:0:x:k",
1358 .check = test__checkevent_breakpoint_x_modifier,
1362 .name = "mem:0:r:hp",
1363 .check = test__checkevent_breakpoint_r_modifier,
1367 .name = "mem:0:w:up",
1368 .check = test__checkevent_breakpoint_w_modifier,
1372 .name = "r1,syscalls:sys_enter_open:k,1:1:hp",
1373 .check = test__checkevent_list,
1377 .name = "instructions:G",
1378 .check = test__checkevent_exclude_host_modifier,
1382 .name = "instructions:H",
1383 .check = test__checkevent_exclude_guest_modifier,
1388 .check = test__checkevent_breakpoint_rw,
1392 .name = "mem:0:rw:kp",
1393 .check = test__checkevent_breakpoint_rw_modifier,
1397 .name = "{instructions:k,cycles:upp}",
1398 .check = test__group1,
1402 .name = "{faults:k,cache-references}:u,cycles:k",
1403 .check = test__group2,
1407 .name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
1408 .check = test__group3,
1412 .name = "{cycles:u,instructions:kp}:p",
1413 .check = test__group4,
1417 .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
1418 .check = test__group5,
1423 .check = test__all_tracepoints,
1427 .name = "{cycles,cache-misses:G}:H",
1428 .check = test__group_gh1,
1432 .name = "{cycles,cache-misses:H}:G",
1433 .check = test__group_gh2,
1437 .name = "{cycles:G,cache-misses:H}:u",
1438 .check = test__group_gh3,
1442 .name = "{cycles:G,cache-misses:H}:uG",
1443 .check = test__group_gh4,
1447 .name = "{cycles,cache-misses,branch-misses}:S",
1448 .check = test__leader_sample1,
1452 .name = "{instructions,branch-misses}:Su",
1453 .check = test__leader_sample2,
1457 .name = "instructions:uDp",
1458 .check = test__checkevent_pinned_modifier,
1462 .name = "{cycles,cache-misses,branch-misses}:D",
1463 .check = test__pinned_group,
1468 .check = test__checkevent_breakpoint_len,
1472 .name = "mem:0/2:w",
1473 .check = test__checkevent_breakpoint_len_w,
1477 .name = "mem:0/4:rw:u",
1478 .check = test__checkevent_breakpoint_len_rw_modifier,
1481 #if defined(__s390x__)
1483 .name = "kvm-s390:kvm_s390_create_vm",
1484 .check = test__checkevent_tracepoint,
1490 static struct evlist_test test__events_pmu[] = {
1492 .name = "cpu/config=10,config1,config2=3,period=1000/u",
1493 .check = test__checkevent_pmu,
1497 .name = "cpu/config=1,name=krava/u,cpu/config=2/u",
1498 .check = test__checkevent_pmu_name,
1506 int (*check)(struct list_head *terms);
1509 static struct terms_test test__terms[] = {
1511 .str = "config=10,config1,config2=3,umask=1",
1512 .check = test__checkterms_simple,
1516 static int test_event(struct evlist_test *e)
1518 struct perf_evlist *evlist;
1521 evlist = perf_evlist__new();
1525 ret = parse_events(evlist, e->name);
1527 pr_debug("failed to parse event '%s', err %d\n",
1530 ret = e->check(evlist);
1533 perf_evlist__delete(evlist);
1538 static int test_events(struct evlist_test *events, unsigned cnt)
1543 for (i = 0; i < cnt; i++) {
1544 struct evlist_test *e = &events[i];
1546 pr_debug("running test %d '%s'\n", e->id, e->name);
1547 ret1 = test_event(e);
1555 static int test_term(struct terms_test *t)
1557 struct list_head terms;
1560 INIT_LIST_HEAD(&terms);
1562 ret = parse_events_terms(&terms, t->str);
1564 pr_debug("failed to parse terms '%s', err %d\n",
1569 ret = t->check(&terms);
1570 parse_events__free_terms(&terms);
1575 static int test_terms(struct terms_test *terms, unsigned cnt)
1580 for (i = 0; i < cnt; i++) {
1581 struct terms_test *t = &terms[i];
1583 pr_debug("running test %d '%s'\n", i, t->str);
1592 static int test_pmu(void)
1595 char path[PATH_MAX];
1598 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
1599 sysfs__mountpoint());
1601 ret = stat(path, &st);
1603 pr_debug("omitting PMU cpu tests\n");
1607 static int test_pmu_events(void)
1610 char path[PATH_MAX];
1615 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
1616 sysfs__mountpoint());
1618 ret = stat(path, &st);
1620 pr_debug("omitting PMU cpu events tests\n");
1624 dir = opendir(path);
1626 pr_debug("can't open pmu event dir");
1630 while (!ret && (ent = readdir(dir))) {
1631 #define MAX_NAME 100
1632 struct evlist_test e;
1633 char name[MAX_NAME];
1635 if (!strcmp(ent->d_name, ".") ||
1636 !strcmp(ent->d_name, ".."))
1639 snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
1642 e.check = test__checkevent_pmu_events;
1644 ret = test_event(&e);
1647 snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
1649 e.check = test__checkevent_pmu_events_mix;
1650 ret = test_event(&e);
1658 int test__parse_events(void)
1662 #define TEST_EVENTS(tests) \
1664 ret1 = test_events(tests, ARRAY_SIZE(tests)); \
1669 TEST_EVENTS(test__events);
1672 TEST_EVENTS(test__events_pmu);
1675 int ret = test_pmu_events();
1680 ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));