2 #include "parse-events.h"
6 #include "../../../include/linux/hw_breakpoint.h"
8 #define TEST_ASSERT_VAL(text, cond) \
11 pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \
16 static int test__checkevent_tracepoint(struct perf_evlist *evlist)
18 struct perf_evsel *evsel = list_entry(evlist->entries.next,
19 struct perf_evsel, node);
21 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
22 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
23 TEST_ASSERT_VAL("wrong sample_type",
24 (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | PERF_SAMPLE_CPU) ==
25 evsel->attr.sample_type);
26 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
30 static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist)
32 struct perf_evsel *evsel;
34 TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
36 list_for_each_entry(evsel, &evlist->entries, node) {
37 TEST_ASSERT_VAL("wrong type",
38 PERF_TYPE_TRACEPOINT == evsel->attr.type);
39 TEST_ASSERT_VAL("wrong sample_type",
40 (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | PERF_SAMPLE_CPU)
41 == evsel->attr.sample_type);
42 TEST_ASSERT_VAL("wrong sample_period",
43 1 == evsel->attr.sample_period);
48 static int test__checkevent_raw(struct perf_evlist *evlist)
50 struct perf_evsel *evsel = list_entry(evlist->entries.next,
51 struct perf_evsel, node);
53 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
54 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
55 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config);
59 static int test__checkevent_numeric(struct perf_evlist *evlist)
61 struct perf_evsel *evsel = list_entry(evlist->entries.next,
62 struct perf_evsel, node);
64 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
65 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
66 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
70 static int test__checkevent_symbolic_name(struct perf_evlist *evlist)
72 struct perf_evsel *evsel = list_entry(evlist->entries.next,
73 struct perf_evsel, node);
75 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
76 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
77 TEST_ASSERT_VAL("wrong config",
78 PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
82 static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
84 struct perf_evsel *evsel = list_entry(evlist->entries.next,
85 struct perf_evsel, node);
87 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
88 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
89 TEST_ASSERT_VAL("wrong config",
90 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
91 TEST_ASSERT_VAL("wrong period",
92 100000 == evsel->attr.sample_period);
93 TEST_ASSERT_VAL("wrong config1",
94 0 == evsel->attr.config1);
95 TEST_ASSERT_VAL("wrong config2",
96 1 == evsel->attr.config2);
100 static int test__checkevent_symbolic_alias(struct perf_evlist *evlist)
102 struct perf_evsel *evsel = list_entry(evlist->entries.next,
103 struct perf_evsel, node);
105 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
106 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
107 TEST_ASSERT_VAL("wrong config",
108 PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
112 static int test__checkevent_genhw(struct perf_evlist *evlist)
114 struct perf_evsel *evsel = list_entry(evlist->entries.next,
115 struct perf_evsel, node);
117 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
118 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type);
119 TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config);
123 static int test__checkevent_breakpoint(struct perf_evlist *evlist)
125 struct perf_evsel *evsel = list_entry(evlist->entries.next,
126 struct perf_evsel, node);
128 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
129 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
130 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
131 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
132 evsel->attr.bp_type);
133 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
138 static int test__checkevent_breakpoint_x(struct perf_evlist *evlist)
140 struct perf_evsel *evsel = list_entry(evlist->entries.next,
141 struct perf_evsel, node);
143 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
144 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
145 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
146 TEST_ASSERT_VAL("wrong bp_type",
147 HW_BREAKPOINT_X == evsel->attr.bp_type);
148 TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len);
152 static int test__checkevent_breakpoint_r(struct perf_evlist *evlist)
154 struct perf_evsel *evsel = list_entry(evlist->entries.next,
155 struct perf_evsel, node);
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);
168 static int test__checkevent_breakpoint_w(struct perf_evlist *evlist)
170 struct perf_evsel *evsel = list_entry(evlist->entries.next,
171 struct perf_evsel, node);
173 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
174 TEST_ASSERT_VAL("wrong type",
175 PERF_TYPE_BREAKPOINT == evsel->attr.type);
176 TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
177 TEST_ASSERT_VAL("wrong bp_type",
178 HW_BREAKPOINT_W == evsel->attr.bp_type);
179 TEST_ASSERT_VAL("wrong bp_len",
180 HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
184 static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist)
186 struct perf_evsel *evsel = list_entry(evlist->entries.next,
187 struct perf_evsel, node);
189 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
190 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
191 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
192 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
194 return test__checkevent_tracepoint(evlist);
198 test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist)
200 struct perf_evsel *evsel;
202 TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
204 list_for_each_entry(evsel, &evlist->entries, node) {
205 TEST_ASSERT_VAL("wrong exclude_user",
206 !evsel->attr.exclude_user);
207 TEST_ASSERT_VAL("wrong exclude_kernel",
208 evsel->attr.exclude_kernel);
209 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
210 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
213 return test__checkevent_tracepoint_multi(evlist);
216 static int test__checkevent_raw_modifier(struct perf_evlist *evlist)
218 struct perf_evsel *evsel = list_entry(evlist->entries.next,
219 struct perf_evsel, node);
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 = list_entry(evlist->entries.next,
232 struct perf_evsel, node);
234 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
235 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
236 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
237 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
239 return test__checkevent_numeric(evlist);
242 static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
244 struct perf_evsel *evsel = list_entry(evlist->entries.next,
245 struct perf_evsel, node);
247 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
248 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
249 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
250 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
252 return test__checkevent_symbolic_name(evlist);
255 static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist)
257 struct perf_evsel *evsel = list_entry(evlist->entries.next,
258 struct perf_evsel, node);
260 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
261 TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
263 return test__checkevent_symbolic_name(evlist);
266 static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist)
268 struct perf_evsel *evsel = list_entry(evlist->entries.next,
269 struct perf_evsel, node);
271 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
272 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
274 return test__checkevent_symbolic_name(evlist);
277 static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
279 struct perf_evsel *evsel = list_entry(evlist->entries.next,
280 struct perf_evsel, node);
282 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
283 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
284 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
285 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
287 return test__checkevent_symbolic_alias(evlist);
290 static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
292 struct perf_evsel *evsel = list_entry(evlist->entries.next,
293 struct perf_evsel, node);
295 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
296 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
297 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
298 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
300 return test__checkevent_genhw(evlist);
303 static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist)
305 struct perf_evsel *evsel = list_entry(evlist->entries.next,
306 struct perf_evsel, node);
308 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
309 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
310 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
311 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
313 return test__checkevent_breakpoint(evlist);
316 static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist)
318 struct perf_evsel *evsel = list_entry(evlist->entries.next,
319 struct perf_evsel, node);
321 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
322 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
323 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
324 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
326 return test__checkevent_breakpoint_x(evlist);
329 static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
331 struct perf_evsel *evsel = list_entry(evlist->entries.next,
332 struct perf_evsel, node);
334 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
335 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
336 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
337 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
339 return test__checkevent_breakpoint_r(evlist);
342 static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
344 struct perf_evsel *evsel = list_entry(evlist->entries.next,
345 struct perf_evsel, node);
347 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
348 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
349 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
350 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
352 return test__checkevent_breakpoint_w(evlist);
355 static int test__checkevent_pmu(struct perf_evlist *evlist)
358 struct perf_evsel *evsel = list_entry(evlist->entries.next,
359 struct perf_evsel, node);
361 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
362 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
363 TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
364 TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
365 TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
366 TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period);
371 static int test__checkevent_list(struct perf_evlist *evlist)
373 struct perf_evsel *evsel;
375 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
378 evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
379 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
380 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
381 TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1);
382 TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2);
383 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
384 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
385 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
386 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
388 /* syscalls:sys_enter_open:k */
389 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
390 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
391 TEST_ASSERT_VAL("wrong sample_type",
392 (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | PERF_SAMPLE_CPU) ==
393 evsel->attr.sample_type);
394 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
395 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
396 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
397 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
398 TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
401 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
402 TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
403 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
404 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
405 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
406 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
407 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
412 static int test__checkevent_pmu_name(struct perf_evlist *evlist)
414 struct perf_evsel *evsel;
416 /* cpu/config=1,name=krava1/u */
417 evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
418 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
419 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
420 TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
421 TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava"));
424 evsel = list_entry(evsel->node.next, struct perf_evsel, node);
425 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
426 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
427 TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config);
428 TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "raw 0x2"));
433 static int test__checkterms_simple(struct list_head *terms)
435 struct parse_events__term *term;
438 term = list_entry(terms->next, struct parse_events__term, list);
439 TEST_ASSERT_VAL("wrong type term",
440 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
441 TEST_ASSERT_VAL("wrong type val",
442 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
443 TEST_ASSERT_VAL("wrong val", term->val.num == 10);
444 TEST_ASSERT_VAL("wrong config", !term->config);
447 term = list_entry(term->list.next, struct parse_events__term, list);
448 TEST_ASSERT_VAL("wrong type term",
449 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
450 TEST_ASSERT_VAL("wrong type val",
451 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
452 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
453 TEST_ASSERT_VAL("wrong config", !term->config);
456 term = list_entry(term->list.next, struct parse_events__term, list);
457 TEST_ASSERT_VAL("wrong type term",
458 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
459 TEST_ASSERT_VAL("wrong type val",
460 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
461 TEST_ASSERT_VAL("wrong val", term->val.num == 3);
462 TEST_ASSERT_VAL("wrong config", !term->config);
465 term = list_entry(term->list.next, struct parse_events__term, list);
466 TEST_ASSERT_VAL("wrong type term",
467 term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
468 TEST_ASSERT_VAL("wrong type val",
469 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
470 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
471 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
476 struct test__event_st {
479 int (*check)(struct perf_evlist *evlist);
482 static struct test__event_st test__events[] = {
484 .name = "syscalls:sys_enter_open",
485 .check = test__checkevent_tracepoint,
488 .name = "syscalls:*",
489 .check = test__checkevent_tracepoint_multi,
493 .check = test__checkevent_raw,
497 .check = test__checkevent_numeric,
500 .name = "instructions",
501 .check = test__checkevent_symbolic_name,
504 .name = "cycles/period=100000,config2/",
505 .check = test__checkevent_symbolic_name_config,
509 .check = test__checkevent_symbolic_alias,
512 .name = "L1-dcache-load-miss",
513 .check = test__checkevent_genhw,
517 .check = test__checkevent_breakpoint,
521 .check = test__checkevent_breakpoint_x,
525 .check = test__checkevent_breakpoint_r,
529 .check = test__checkevent_breakpoint_w,
532 .name = "syscalls:sys_enter_open:k",
533 .check = test__checkevent_tracepoint_modifier,
536 .name = "syscalls:*:u",
537 .check = test__checkevent_tracepoint_multi_modifier,
541 .check = test__checkevent_raw_modifier,
545 .check = test__checkevent_numeric_modifier,
548 .name = "instructions:h",
549 .check = test__checkevent_symbolic_name_modifier,
553 .check = test__checkevent_symbolic_alias_modifier,
556 .name = "L1-dcache-load-miss:kp",
557 .check = test__checkevent_genhw_modifier,
561 .check = test__checkevent_breakpoint_modifier,
565 .check = test__checkevent_breakpoint_x_modifier,
568 .name = "mem:0:r:hp",
569 .check = test__checkevent_breakpoint_r_modifier,
572 .name = "mem:0:w:up",
573 .check = test__checkevent_breakpoint_w_modifier,
576 .name = "r1,syscalls:sys_enter_open:k,1:1:hp",
577 .check = test__checkevent_list,
580 .name = "instructions:G",
581 .check = test__checkevent_exclude_host_modifier,
584 .name = "instructions:H",
585 .check = test__checkevent_exclude_guest_modifier,
589 #define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
591 static struct test__event_st test__events_pmu[] = {
593 .name = "cpu/config=10,config1,config2=3,period=1000/u",
594 .check = test__checkevent_pmu,
597 .name = "cpu/config=1,name=krava/u,cpu/config=2/u",
598 .check = test__checkevent_pmu_name,
602 #define TEST__EVENTS_PMU_CNT (sizeof(test__events_pmu) / \
603 sizeof(struct test__event_st))
608 int (*check)(struct list_head *terms);
611 static struct test__term test__terms[] = {
613 .str = "config=10,config1,config2=3,umask=1",
614 .check = test__checkterms_simple,
618 #define TEST__TERMS_CNT (sizeof(test__terms) / \
619 sizeof(struct test__term))
621 static int test_event(struct test__event_st *e)
623 struct perf_evlist *evlist;
626 evlist = perf_evlist__new(NULL, NULL);
630 ret = parse_events(evlist, e->name, 0);
632 pr_debug("failed to parse event '%s', err %d\n",
637 ret = e->check(evlist);
638 perf_evlist__delete(evlist);
643 static int test_events(struct test__event_st *events, unsigned cnt)
648 for (i = 0; i < cnt; i++) {
649 struct test__event_st *e = &events[i];
651 pr_debug("running test %d '%s'\n", i, e->name);
660 static int test_term(struct test__term *t)
662 struct list_head *terms;
665 terms = malloc(sizeof(*terms));
669 INIT_LIST_HEAD(terms);
671 ret = parse_events_terms(terms, t->str);
673 pr_debug("failed to parse terms '%s', err %d\n",
678 ret = t->check(terms);
679 parse_events__free_terms(terms);
684 static int test_terms(struct test__term *terms, unsigned cnt)
689 for (i = 0; i < cnt; i++) {
690 struct test__term *t = &terms[i];
692 pr_debug("running test %d '%s'\n", i, t->str);
701 static int test_pmu(void)
707 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
708 sysfs_find_mountpoint());
710 ret = stat(path, &st);
712 pr_debug("ommiting PMU cpu tests\n");
716 int parse_events__test(void)
721 ret = test_events(test__events, TEST__EVENTS_CNT);
726 ret = test_events(test__events_pmu,
727 TEST__EVENTS_PMU_CNT);
732 ret = test_terms(test__terms, TEST__TERMS_CNT);