Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / perf / tests / parse-events.c
bloba7f6661e6112db084bfbd63572bbfeeaf3c1eb43
1 // SPDX-License-Identifier: GPL-2.0
2 #include "parse-events.h"
3 #include "evsel.h"
4 #include "evlist.h"
5 #include <api/fs/fs.h>
6 #include "tests.h"
7 #include "debug.h"
8 #include "pmu.h"
9 #include <dirent.h>
10 #include <errno.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <unistd.h>
14 #include <linux/kernel.h>
15 #include <linux/hw_breakpoint.h>
16 #include <api/fs/tracing_path.h>
18 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
19 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
21 #if defined(__s390x__)
22 /* Return true if kvm module is available and loaded. Test this
23 * and retun success when trace point kvm_s390_create_vm
24 * exists. Otherwise this test always fails.
26 static bool kvm_s390_create_vm_valid(void)
28 char *eventfile;
29 bool rc = false;
31 eventfile = get_events_file("kvm-s390");
33 if (eventfile) {
34 DIR *mydir = opendir(eventfile);
36 if (mydir) {
37 rc = true;
38 closedir(mydir);
40 put_events_file(eventfile);
43 return rc;
45 #endif
47 static int test__checkevent_tracepoint(struct evlist *evlist)
49 struct evsel *evsel = evlist__first(evlist);
51 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
52 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
53 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
54 TEST_ASSERT_VAL("wrong sample_type",
55 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
56 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
57 return 0;
60 static int test__checkevent_tracepoint_multi(struct evlist *evlist)
62 struct evsel *evsel;
64 TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
65 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
67 evlist__for_each_entry(evlist, evsel) {
68 TEST_ASSERT_VAL("wrong type",
69 PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
70 TEST_ASSERT_VAL("wrong sample_type",
71 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
72 TEST_ASSERT_VAL("wrong sample_period",
73 1 == evsel->core.attr.sample_period);
75 return 0;
78 static int test__checkevent_raw(struct evlist *evlist)
80 struct evsel *evsel = evlist__first(evlist);
82 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
83 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
84 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
85 return 0;
88 static int test__checkevent_numeric(struct evlist *evlist)
90 struct evsel *evsel = evlist__first(evlist);
92 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
93 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
94 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
95 return 0;
98 static int test__checkevent_symbolic_name(struct evlist *evlist)
100 struct evsel *evsel = evlist__first(evlist);
102 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
103 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
104 TEST_ASSERT_VAL("wrong config",
105 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
106 return 0;
109 static int test__checkevent_symbolic_name_config(struct evlist *evlist)
111 struct evsel *evsel = evlist__first(evlist);
113 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
114 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
115 TEST_ASSERT_VAL("wrong config",
116 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
118 * The period value gets configured within evlist__config,
119 * while this test executes only parse events method.
121 TEST_ASSERT_VAL("wrong period",
122 0 == evsel->core.attr.sample_period);
123 TEST_ASSERT_VAL("wrong config1",
124 0 == evsel->core.attr.config1);
125 TEST_ASSERT_VAL("wrong config2",
126 1 == evsel->core.attr.config2);
127 return 0;
130 static int test__checkevent_symbolic_alias(struct evlist *evlist)
132 struct evsel *evsel = evlist__first(evlist);
134 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
135 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
136 TEST_ASSERT_VAL("wrong config",
137 PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
138 return 0;
141 static int test__checkevent_genhw(struct evlist *evlist)
143 struct evsel *evsel = evlist__first(evlist);
145 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
146 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
147 TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->core.attr.config);
148 return 0;
151 static int test__checkevent_breakpoint(struct evlist *evlist)
153 struct evsel *evsel = evlist__first(evlist);
155 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
156 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
157 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
158 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
159 evsel->core.attr.bp_type);
160 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
161 evsel->core.attr.bp_len);
162 return 0;
165 static int test__checkevent_breakpoint_x(struct evlist *evlist)
167 struct evsel *evsel = evlist__first(evlist);
169 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
170 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
171 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
172 TEST_ASSERT_VAL("wrong bp_type",
173 HW_BREAKPOINT_X == evsel->core.attr.bp_type);
174 TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->core.attr.bp_len);
175 return 0;
178 static int test__checkevent_breakpoint_r(struct evlist *evlist)
180 struct evsel *evsel = evlist__first(evlist);
182 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
183 TEST_ASSERT_VAL("wrong type",
184 PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
185 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
186 TEST_ASSERT_VAL("wrong bp_type",
187 HW_BREAKPOINT_R == evsel->core.attr.bp_type);
188 TEST_ASSERT_VAL("wrong bp_len",
189 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
190 return 0;
193 static int test__checkevent_breakpoint_w(struct evlist *evlist)
195 struct evsel *evsel = evlist__first(evlist);
197 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
198 TEST_ASSERT_VAL("wrong type",
199 PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
200 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
201 TEST_ASSERT_VAL("wrong bp_type",
202 HW_BREAKPOINT_W == evsel->core.attr.bp_type);
203 TEST_ASSERT_VAL("wrong bp_len",
204 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
205 return 0;
208 static int test__checkevent_breakpoint_rw(struct evlist *evlist)
210 struct evsel *evsel = evlist__first(evlist);
212 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
213 TEST_ASSERT_VAL("wrong type",
214 PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
215 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
216 TEST_ASSERT_VAL("wrong bp_type",
217 (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->core.attr.bp_type);
218 TEST_ASSERT_VAL("wrong bp_len",
219 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
220 return 0;
223 static int test__checkevent_tracepoint_modifier(struct evlist *evlist)
225 struct evsel *evsel = evlist__first(evlist);
227 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
228 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
229 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
230 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
232 return test__checkevent_tracepoint(evlist);
235 static int
236 test__checkevent_tracepoint_multi_modifier(struct evlist *evlist)
238 struct evsel *evsel;
240 TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
242 evlist__for_each_entry(evlist, evsel) {
243 TEST_ASSERT_VAL("wrong exclude_user",
244 !evsel->core.attr.exclude_user);
245 TEST_ASSERT_VAL("wrong exclude_kernel",
246 evsel->core.attr.exclude_kernel);
247 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
248 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
251 return test__checkevent_tracepoint_multi(evlist);
254 static int test__checkevent_raw_modifier(struct evlist *evlist)
256 struct evsel *evsel = evlist__first(evlist);
258 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
259 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
260 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
261 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
263 return test__checkevent_raw(evlist);
266 static int test__checkevent_numeric_modifier(struct evlist *evlist)
268 struct evsel *evsel = evlist__first(evlist);
270 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
271 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
272 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
273 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
275 return test__checkevent_numeric(evlist);
278 static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
280 struct evsel *evsel = evlist__first(evlist);
282 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
283 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
284 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
285 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
287 return test__checkevent_symbolic_name(evlist);
290 static int test__checkevent_exclude_host_modifier(struct evlist *evlist)
292 struct evsel *evsel = evlist__first(evlist);
294 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
295 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
297 return test__checkevent_symbolic_name(evlist);
300 static int test__checkevent_exclude_guest_modifier(struct evlist *evlist)
302 struct evsel *evsel = evlist__first(evlist);
304 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
305 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
307 return test__checkevent_symbolic_name(evlist);
310 static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist)
312 struct evsel *evsel = evlist__first(evlist);
314 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
315 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
316 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
317 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
319 return test__checkevent_symbolic_alias(evlist);
322 static int test__checkevent_genhw_modifier(struct evlist *evlist)
324 struct evsel *evsel = evlist__first(evlist);
326 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
327 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
328 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
329 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
331 return test__checkevent_genhw(evlist);
334 static int test__checkevent_exclude_idle_modifier(struct evlist *evlist)
336 struct evsel *evsel = evlist__first(evlist);
338 TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
339 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
340 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
341 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
342 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
343 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
344 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
346 return test__checkevent_symbolic_name(evlist);
349 static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist)
351 struct evsel *evsel = evlist__first(evlist);
353 TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
354 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
355 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
356 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
357 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
358 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
359 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
361 return test__checkevent_symbolic_name(evlist);
364 static int test__checkevent_breakpoint_modifier(struct evlist *evlist)
366 struct evsel *evsel = evlist__first(evlist);
369 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
370 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
371 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
372 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
373 TEST_ASSERT_VAL("wrong name",
374 !strcmp(evsel__name(evsel), "mem:0:u"));
376 return test__checkevent_breakpoint(evlist);
379 static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist)
381 struct evsel *evsel = evlist__first(evlist);
383 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
384 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
385 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
386 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
387 TEST_ASSERT_VAL("wrong name",
388 !strcmp(evsel__name(evsel), "mem:0:x:k"));
390 return test__checkevent_breakpoint_x(evlist);
393 static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist)
395 struct evsel *evsel = evlist__first(evlist);
397 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
398 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
399 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
400 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
401 TEST_ASSERT_VAL("wrong name",
402 !strcmp(evsel__name(evsel), "mem:0:r:hp"));
404 return test__checkevent_breakpoint_r(evlist);
407 static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist)
409 struct evsel *evsel = evlist__first(evlist);
411 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
412 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
413 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
414 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
415 TEST_ASSERT_VAL("wrong name",
416 !strcmp(evsel__name(evsel), "mem:0:w:up"));
418 return test__checkevent_breakpoint_w(evlist);
421 static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist)
423 struct evsel *evsel = evlist__first(evlist);
425 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
426 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
427 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
428 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
429 TEST_ASSERT_VAL("wrong name",
430 !strcmp(evsel__name(evsel), "mem:0:rw:kp"));
432 return test__checkevent_breakpoint_rw(evlist);
435 static int test__checkevent_pmu(struct evlist *evlist)
438 struct evsel *evsel = evlist__first(evlist);
440 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
441 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
442 TEST_ASSERT_VAL("wrong config", 10 == evsel->core.attr.config);
443 TEST_ASSERT_VAL("wrong config1", 1 == evsel->core.attr.config1);
444 TEST_ASSERT_VAL("wrong config2", 3 == evsel->core.attr.config2);
446 * The period value gets configured within evlist__config,
447 * while this test executes only parse events method.
449 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
451 return 0;
454 static int test__checkevent_list(struct evlist *evlist)
456 struct evsel *evsel = evlist__first(evlist);
458 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
460 /* r1 */
461 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
462 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
463 TEST_ASSERT_VAL("wrong config1", 0 == evsel->core.attr.config1);
464 TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
465 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
466 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
467 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
468 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
470 /* syscalls:sys_enter_openat:k */
471 evsel = evsel__next(evsel);
472 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
473 TEST_ASSERT_VAL("wrong sample_type",
474 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
475 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
476 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
477 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
478 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
479 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
481 /* 1:1:hp */
482 evsel = evsel__next(evsel);
483 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
484 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
485 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
486 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
487 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
488 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
490 return 0;
493 static int test__checkevent_pmu_name(struct evlist *evlist)
495 struct evsel *evsel = evlist__first(evlist);
497 /* cpu/config=1,name=krava/u */
498 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
499 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
500 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
501 TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "krava"));
503 /* cpu/config=2/u" */
504 evsel = evsel__next(evsel);
505 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
506 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
507 TEST_ASSERT_VAL("wrong config", 2 == evsel->core.attr.config);
508 TEST_ASSERT_VAL("wrong name",
509 !strcmp(evsel__name(evsel), "cpu/config=2/u"));
511 return 0;
514 static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
516 struct evsel *evsel = evlist__first(evlist);
518 /* cpu/config=1,call-graph=fp,time,period=100000/ */
519 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
520 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
521 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
523 * The period, time and callgraph value gets configured within evlist__config,
524 * while this test executes only parse events method.
526 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
527 TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
528 TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
530 /* cpu/config=2,call-graph=no,time=0,period=2000/ */
531 evsel = evsel__next(evsel);
532 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
533 TEST_ASSERT_VAL("wrong config", 2 == evsel->core.attr.config);
535 * The period, time and callgraph value gets configured within evlist__config,
536 * while this test executes only parse events method.
538 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
539 TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
540 TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
542 return 0;
545 static int test__checkevent_pmu_events(struct evlist *evlist)
547 struct evsel *evsel = evlist__first(evlist);
549 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
550 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
551 TEST_ASSERT_VAL("wrong exclude_user",
552 !evsel->core.attr.exclude_user);
553 TEST_ASSERT_VAL("wrong exclude_kernel",
554 evsel->core.attr.exclude_kernel);
555 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
556 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
557 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
558 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
560 return 0;
564 static int test__checkevent_pmu_events_mix(struct evlist *evlist)
566 struct evsel *evsel = evlist__first(evlist);
568 /* pmu-event:u */
569 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
570 TEST_ASSERT_VAL("wrong exclude_user",
571 !evsel->core.attr.exclude_user);
572 TEST_ASSERT_VAL("wrong exclude_kernel",
573 evsel->core.attr.exclude_kernel);
574 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
575 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
576 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
577 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
579 /* cpu/pmu-event/u*/
580 evsel = evsel__next(evsel);
581 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
582 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
583 TEST_ASSERT_VAL("wrong exclude_user",
584 !evsel->core.attr.exclude_user);
585 TEST_ASSERT_VAL("wrong exclude_kernel",
586 evsel->core.attr.exclude_kernel);
587 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
588 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
589 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
590 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned);
592 return 0;
595 static int test__checkterms_simple(struct list_head *terms)
597 struct parse_events_term *term;
599 /* config=10 */
600 term = list_entry(terms->next, struct parse_events_term, list);
601 TEST_ASSERT_VAL("wrong type term",
602 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
603 TEST_ASSERT_VAL("wrong type val",
604 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
605 TEST_ASSERT_VAL("wrong val", term->val.num == 10);
606 TEST_ASSERT_VAL("wrong config", !term->config);
608 /* config1 */
609 term = list_entry(term->list.next, struct parse_events_term, list);
610 TEST_ASSERT_VAL("wrong type term",
611 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
612 TEST_ASSERT_VAL("wrong type val",
613 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
614 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
615 TEST_ASSERT_VAL("wrong config", !term->config);
617 /* config2=3 */
618 term = list_entry(term->list.next, struct parse_events_term, list);
619 TEST_ASSERT_VAL("wrong type term",
620 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
621 TEST_ASSERT_VAL("wrong type val",
622 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
623 TEST_ASSERT_VAL("wrong val", term->val.num == 3);
624 TEST_ASSERT_VAL("wrong config", !term->config);
626 /* umask=1*/
627 term = list_entry(term->list.next, struct parse_events_term, list);
628 TEST_ASSERT_VAL("wrong type term",
629 term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
630 TEST_ASSERT_VAL("wrong type val",
631 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
632 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
633 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
636 * read
638 * The perf_pmu__test_parse_init injects 'read' term into
639 * perf_pmu_events_list, so 'read' is evaluated as read term
640 * and not as raw event with 'ead' hex value.
642 term = list_entry(term->list.next, struct parse_events_term, list);
643 TEST_ASSERT_VAL("wrong type term",
644 term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
645 TEST_ASSERT_VAL("wrong type val",
646 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
647 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
648 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "read"));
651 * r0xead
653 * To be still able to pass 'ead' value with 'r' syntax,
654 * we added support to parse 'r0xHEX' event.
656 term = list_entry(term->list.next, struct parse_events_term, list);
657 TEST_ASSERT_VAL("wrong type term",
658 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
659 TEST_ASSERT_VAL("wrong type val",
660 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
661 TEST_ASSERT_VAL("wrong val", term->val.num == 0xead);
662 TEST_ASSERT_VAL("wrong config", !term->config);
663 return 0;
666 static int test__group1(struct evlist *evlist)
668 struct evsel *evsel, *leader;
670 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
671 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
673 /* instructions:k */
674 evsel = leader = evlist__first(evlist);
675 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
676 TEST_ASSERT_VAL("wrong config",
677 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
678 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
679 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
680 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
681 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
682 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
683 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
684 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
685 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
686 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
687 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
689 /* cycles:upp */
690 evsel = evsel__next(evsel);
691 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
692 TEST_ASSERT_VAL("wrong config",
693 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
694 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
695 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
696 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
697 /* use of precise requires exclude_guest */
698 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
699 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
700 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
701 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
702 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
703 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
705 return 0;
708 static int test__group2(struct evlist *evlist)
710 struct evsel *evsel, *leader;
712 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
713 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
715 /* faults + :ku modifier */
716 evsel = leader = evlist__first(evlist);
717 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
718 TEST_ASSERT_VAL("wrong config",
719 PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
720 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
721 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
722 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
723 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
724 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
725 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
726 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
727 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
728 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
729 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
731 /* cache-references + :u modifier */
732 evsel = evsel__next(evsel);
733 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
734 TEST_ASSERT_VAL("wrong config",
735 PERF_COUNT_HW_CACHE_REFERENCES == evsel->core.attr.config);
736 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
737 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
738 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
739 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
740 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
741 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
742 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
743 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
744 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
746 /* cycles:k */
747 evsel = evsel__next(evsel);
748 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
749 TEST_ASSERT_VAL("wrong config",
750 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
751 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
752 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
753 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
754 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
755 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
756 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
757 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
758 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
760 return 0;
763 static int test__group3(struct evlist *evlist __maybe_unused)
765 struct evsel *evsel, *leader;
767 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
768 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
770 /* group1 syscalls:sys_enter_openat:H */
771 evsel = leader = evlist__first(evlist);
772 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
773 TEST_ASSERT_VAL("wrong sample_type",
774 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
775 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
776 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
777 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
778 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
779 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
780 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
781 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
782 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
783 TEST_ASSERT_VAL("wrong group name",
784 !strcmp(leader->group_name, "group1"));
785 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
786 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
787 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
789 /* group1 cycles:kppp */
790 evsel = evsel__next(evsel);
791 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
792 TEST_ASSERT_VAL("wrong config",
793 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
794 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
795 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
796 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
797 /* use of precise requires exclude_guest */
798 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
799 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
800 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 3);
801 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
802 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
803 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
804 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
806 /* group2 cycles + G modifier */
807 evsel = leader = evsel__next(evsel);
808 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
809 TEST_ASSERT_VAL("wrong config",
810 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
811 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
812 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
813 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
814 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
815 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
816 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
817 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
818 TEST_ASSERT_VAL("wrong group name",
819 !strcmp(leader->group_name, "group2"));
820 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
821 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
822 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
824 /* group2 1:3 + G modifier */
825 evsel = evsel__next(evsel);
826 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
827 TEST_ASSERT_VAL("wrong config", 3 == evsel->core.attr.config);
828 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
829 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
830 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
831 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
832 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
833 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
834 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
835 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
836 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
838 /* instructions:u */
839 evsel = evsel__next(evsel);
840 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
841 TEST_ASSERT_VAL("wrong config",
842 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
843 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
844 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
845 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
846 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
847 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
848 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
849 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
850 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
852 return 0;
855 static int test__group4(struct evlist *evlist __maybe_unused)
857 struct evsel *evsel, *leader;
859 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
860 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
862 /* cycles:u + p */
863 evsel = leader = evlist__first(evlist);
864 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
865 TEST_ASSERT_VAL("wrong config",
866 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
867 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
868 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
869 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
870 /* use of precise requires exclude_guest */
871 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
872 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
873 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 1);
874 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
875 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
876 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
877 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
878 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
880 /* instructions:kp + p */
881 evsel = evsel__next(evsel);
882 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
883 TEST_ASSERT_VAL("wrong config",
884 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
885 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
886 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
887 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
888 /* use of precise requires exclude_guest */
889 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
890 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
891 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
892 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
893 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
894 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
896 return 0;
899 static int test__group5(struct evlist *evlist __maybe_unused)
901 struct evsel *evsel, *leader;
903 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
904 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
906 /* cycles + G */
907 evsel = leader = evlist__first(evlist);
908 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
909 TEST_ASSERT_VAL("wrong config",
910 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
911 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
912 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
913 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
914 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
915 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
916 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
917 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
918 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
919 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
920 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
921 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
923 /* instructions + G */
924 evsel = evsel__next(evsel);
925 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
926 TEST_ASSERT_VAL("wrong config",
927 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
928 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
929 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
930 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
931 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
932 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
933 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
934 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
935 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
936 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
938 /* cycles:G */
939 evsel = leader = evsel__next(evsel);
940 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
941 TEST_ASSERT_VAL("wrong config",
942 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
943 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
944 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
945 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
946 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
947 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
948 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
949 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
950 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
951 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
952 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
953 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
955 /* instructions:G */
956 evsel = evsel__next(evsel);
957 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
958 TEST_ASSERT_VAL("wrong config",
959 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
960 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
961 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
962 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
963 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
964 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
965 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
966 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
967 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
969 /* cycles */
970 evsel = evsel__next(evsel);
971 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
972 TEST_ASSERT_VAL("wrong config",
973 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
974 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
975 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
976 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
977 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
978 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
979 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
980 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
982 return 0;
985 static int test__group_gh1(struct evlist *evlist)
987 struct evsel *evsel, *leader;
989 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
990 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
992 /* cycles + :H group modifier */
993 evsel = leader = evlist__first(evlist);
994 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
995 TEST_ASSERT_VAL("wrong config",
996 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
997 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
998 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
999 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1000 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1001 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1002 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1003 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1004 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
1005 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1006 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
1008 /* cache-misses:G + :H group modifier */
1009 evsel = evsel__next(evsel);
1010 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1011 TEST_ASSERT_VAL("wrong config",
1012 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1013 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1014 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1015 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1016 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1017 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1018 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1019 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1020 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
1022 return 0;
1025 static int test__group_gh2(struct evlist *evlist)
1027 struct evsel *evsel, *leader;
1029 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1030 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
1032 /* cycles + :G group modifier */
1033 evsel = leader = evlist__first(evlist);
1034 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1035 TEST_ASSERT_VAL("wrong config",
1036 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1037 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1038 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1039 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1040 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1041 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
1042 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1043 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1044 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
1045 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1046 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
1048 /* cache-misses:H + :G group modifier */
1049 evsel = evsel__next(evsel);
1050 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1051 TEST_ASSERT_VAL("wrong config",
1052 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1053 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1054 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1055 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1056 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1057 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1058 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1059 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1060 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
1062 return 0;
1065 static int test__group_gh3(struct evlist *evlist)
1067 struct evsel *evsel, *leader;
1069 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1070 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
1072 /* cycles:G + :u group modifier */
1073 evsel = leader = evlist__first(evlist);
1074 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1075 TEST_ASSERT_VAL("wrong config",
1076 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1077 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1078 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1079 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1080 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1081 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
1082 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1083 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1084 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
1085 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1086 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
1088 /* cache-misses:H + :u group modifier */
1089 evsel = evsel__next(evsel);
1090 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1091 TEST_ASSERT_VAL("wrong config",
1092 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1093 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1094 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1095 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1096 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1097 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1098 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1099 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1100 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
1102 return 0;
1105 static int test__group_gh4(struct evlist *evlist)
1107 struct evsel *evsel, *leader;
1109 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1110 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
1112 /* cycles:G + :uG group modifier */
1113 evsel = leader = evlist__first(evlist);
1114 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1115 TEST_ASSERT_VAL("wrong config",
1116 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1117 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1118 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1119 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1120 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1121 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
1122 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1123 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1124 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
1125 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1126 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
1128 /* cache-misses:H + :uG group modifier */
1129 evsel = evsel__next(evsel);
1130 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1131 TEST_ASSERT_VAL("wrong config",
1132 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1133 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1134 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1135 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1136 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1137 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1138 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1139 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1140 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
1142 return 0;
1145 static int test__leader_sample1(struct evlist *evlist)
1147 struct evsel *evsel, *leader;
1149 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1151 /* cycles - sampling group leader */
1152 evsel = leader = evlist__first(evlist);
1153 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1154 TEST_ASSERT_VAL("wrong config",
1155 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1156 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1157 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1158 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1159 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1160 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1161 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1162 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1163 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1164 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1166 /* cache-misses - not sampling */
1167 evsel = evsel__next(evsel);
1168 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1169 TEST_ASSERT_VAL("wrong config",
1170 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1171 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1172 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1173 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1174 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1175 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1176 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1177 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1178 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1180 /* branch-misses - not sampling */
1181 evsel = evsel__next(evsel);
1182 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1183 TEST_ASSERT_VAL("wrong config",
1184 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1185 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1186 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1187 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1188 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1189 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1190 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1191 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1192 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1193 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1195 return 0;
1198 static int test__leader_sample2(struct evlist *evlist __maybe_unused)
1200 struct evsel *evsel, *leader;
1202 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1204 /* instructions - sampling group leader */
1205 evsel = leader = evlist__first(evlist);
1206 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1207 TEST_ASSERT_VAL("wrong config",
1208 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
1209 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1210 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1211 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1212 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1213 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1214 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1215 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1216 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1217 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1219 /* branch-misses - not sampling */
1220 evsel = evsel__next(evsel);
1221 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1222 TEST_ASSERT_VAL("wrong config",
1223 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1224 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1225 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1226 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1227 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1228 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1229 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1230 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1231 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1232 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1234 return 0;
1237 static int test__checkevent_pinned_modifier(struct evlist *evlist)
1239 struct evsel *evsel = evlist__first(evlist);
1241 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1242 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1243 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1244 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
1245 TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
1247 return test__checkevent_symbolic_name(evlist);
1250 static int test__pinned_group(struct evlist *evlist)
1252 struct evsel *evsel, *leader;
1254 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1256 /* cycles - group leader */
1257 evsel = leader = evlist__first(evlist);
1258 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1259 TEST_ASSERT_VAL("wrong config",
1260 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1261 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1262 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1263 TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
1265 /* cache-misses - can not be pinned, but will go on with the leader */
1266 evsel = evsel__next(evsel);
1267 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1268 TEST_ASSERT_VAL("wrong config",
1269 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1270 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
1272 /* branch-misses - ditto */
1273 evsel = evsel__next(evsel);
1274 TEST_ASSERT_VAL("wrong config",
1275 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1276 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
1278 return 0;
1281 static int test__checkevent_exclusive_modifier(struct evlist *evlist)
1283 struct evsel *evsel = evlist__first(evlist);
1285 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1286 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1287 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1288 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
1289 TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive);
1291 return test__checkevent_symbolic_name(evlist);
1294 static int test__exclusive_group(struct evlist *evlist)
1296 struct evsel *evsel, *leader;
1298 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1300 /* cycles - group leader */
1301 evsel = leader = evlist__first(evlist);
1302 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1303 TEST_ASSERT_VAL("wrong config",
1304 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1305 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1306 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1307 TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive);
1309 /* cache-misses - can not be pinned, but will go on with the leader */
1310 evsel = evsel__next(evsel);
1311 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1312 TEST_ASSERT_VAL("wrong config",
1313 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1314 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
1316 /* branch-misses - ditto */
1317 evsel = evsel__next(evsel);
1318 TEST_ASSERT_VAL("wrong config",
1319 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1320 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
1322 return 0;
1324 static int test__checkevent_breakpoint_len(struct evlist *evlist)
1326 struct evsel *evsel = evlist__first(evlist);
1328 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1329 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1330 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
1331 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
1332 evsel->core.attr.bp_type);
1333 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
1334 evsel->core.attr.bp_len);
1336 return 0;
1339 static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
1341 struct evsel *evsel = evlist__first(evlist);
1343 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1344 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1345 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
1346 TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
1347 evsel->core.attr.bp_type);
1348 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
1349 evsel->core.attr.bp_len);
1351 return 0;
1354 static int
1355 test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
1357 struct evsel *evsel = evlist__first(evlist);
1359 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1360 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1361 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1362 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1364 return test__checkevent_breakpoint_rw(evlist);
1367 static int test__checkevent_precise_max_modifier(struct evlist *evlist)
1369 struct evsel *evsel = evlist__first(evlist);
1371 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1372 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
1373 TEST_ASSERT_VAL("wrong config",
1374 PERF_COUNT_SW_TASK_CLOCK == evsel->core.attr.config);
1375 return 0;
1378 static int test__checkevent_config_symbol(struct evlist *evlist)
1380 struct evsel *evsel = evlist__first(evlist);
1382 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
1383 return 0;
1386 static int test__checkevent_config_raw(struct evlist *evlist)
1388 struct evsel *evsel = evlist__first(evlist);
1390 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
1391 return 0;
1394 static int test__checkevent_config_num(struct evlist *evlist)
1396 struct evsel *evsel = evlist__first(evlist);
1398 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
1399 return 0;
1402 static int test__checkevent_config_cache(struct evlist *evlist)
1404 struct evsel *evsel = evlist__first(evlist);
1406 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
1407 return 0;
1410 static bool test__intel_pt_valid(void)
1412 return !!perf_pmu__find("intel_pt");
1415 static int test__intel_pt(struct evlist *evlist)
1417 struct evsel *evsel = evlist__first(evlist);
1419 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0);
1420 return 0;
1423 static int test__checkevent_complex_name(struct evlist *evlist)
1425 struct evsel *evsel = evlist__first(evlist);
1427 TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0);
1428 return 0;
1431 static int test__checkevent_raw_pmu(struct evlist *evlist)
1433 struct evsel *evsel = evlist__first(evlist);
1435 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1436 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
1437 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
1438 return 0;
1441 static int test__sym_event_slash(struct evlist *evlist)
1443 struct evsel *evsel = evlist__first(evlist);
1445 TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
1446 TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
1447 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1448 return 0;
1451 static int test__sym_event_dc(struct evlist *evlist)
1453 struct evsel *evsel = evlist__first(evlist);
1455 TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
1456 TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
1457 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
1458 return 0;
1461 static int count_tracepoints(void)
1463 struct dirent *events_ent;
1464 DIR *events_dir;
1465 int cnt = 0;
1467 events_dir = tracing_events__opendir();
1469 TEST_ASSERT_VAL("Can't open events dir", events_dir);
1471 while ((events_ent = readdir(events_dir))) {
1472 char *sys_path;
1473 struct dirent *sys_ent;
1474 DIR *sys_dir;
1476 if (!strcmp(events_ent->d_name, ".")
1477 || !strcmp(events_ent->d_name, "..")
1478 || !strcmp(events_ent->d_name, "enable")
1479 || !strcmp(events_ent->d_name, "header_event")
1480 || !strcmp(events_ent->d_name, "header_page"))
1481 continue;
1483 sys_path = get_events_file(events_ent->d_name);
1484 TEST_ASSERT_VAL("Can't get sys path", sys_path);
1486 sys_dir = opendir(sys_path);
1487 TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
1489 while ((sys_ent = readdir(sys_dir))) {
1490 if (!strcmp(sys_ent->d_name, ".")
1491 || !strcmp(sys_ent->d_name, "..")
1492 || !strcmp(sys_ent->d_name, "enable")
1493 || !strcmp(sys_ent->d_name, "filter"))
1494 continue;
1496 cnt++;
1499 closedir(sys_dir);
1500 put_events_file(sys_path);
1503 closedir(events_dir);
1504 return cnt;
1507 static int test__all_tracepoints(struct evlist *evlist)
1509 TEST_ASSERT_VAL("wrong events count",
1510 count_tracepoints() == evlist->core.nr_entries);
1512 return test__checkevent_tracepoint_multi(evlist);
1515 struct evlist_test {
1516 const char *name;
1517 __u32 type;
1518 const int id;
1519 bool (*valid)(void);
1520 int (*check)(struct evlist *evlist);
1523 static struct evlist_test test__events[] = {
1525 .name = "syscalls:sys_enter_openat",
1526 .check = test__checkevent_tracepoint,
1527 .id = 0,
1530 .name = "syscalls:*",
1531 .check = test__checkevent_tracepoint_multi,
1532 .id = 1,
1535 .name = "r1a",
1536 .check = test__checkevent_raw,
1537 .id = 2,
1540 .name = "1:1",
1541 .check = test__checkevent_numeric,
1542 .id = 3,
1545 .name = "instructions",
1546 .check = test__checkevent_symbolic_name,
1547 .id = 4,
1550 .name = "cycles/period=100000,config2/",
1551 .check = test__checkevent_symbolic_name_config,
1552 .id = 5,
1555 .name = "faults",
1556 .check = test__checkevent_symbolic_alias,
1557 .id = 6,
1560 .name = "L1-dcache-load-miss",
1561 .check = test__checkevent_genhw,
1562 .id = 7,
1565 .name = "mem:0",
1566 .check = test__checkevent_breakpoint,
1567 .id = 8,
1570 .name = "mem:0:x",
1571 .check = test__checkevent_breakpoint_x,
1572 .id = 9,
1575 .name = "mem:0:r",
1576 .check = test__checkevent_breakpoint_r,
1577 .id = 10,
1580 .name = "mem:0:w",
1581 .check = test__checkevent_breakpoint_w,
1582 .id = 11,
1585 .name = "syscalls:sys_enter_openat:k",
1586 .check = test__checkevent_tracepoint_modifier,
1587 .id = 12,
1590 .name = "syscalls:*:u",
1591 .check = test__checkevent_tracepoint_multi_modifier,
1592 .id = 13,
1595 .name = "r1a:kp",
1596 .check = test__checkevent_raw_modifier,
1597 .id = 14,
1600 .name = "1:1:hp",
1601 .check = test__checkevent_numeric_modifier,
1602 .id = 15,
1605 .name = "instructions:h",
1606 .check = test__checkevent_symbolic_name_modifier,
1607 .id = 16,
1610 .name = "faults:u",
1611 .check = test__checkevent_symbolic_alias_modifier,
1612 .id = 17,
1615 .name = "L1-dcache-load-miss:kp",
1616 .check = test__checkevent_genhw_modifier,
1617 .id = 18,
1620 .name = "mem:0:u",
1621 .check = test__checkevent_breakpoint_modifier,
1622 .id = 19,
1625 .name = "mem:0:x:k",
1626 .check = test__checkevent_breakpoint_x_modifier,
1627 .id = 20,
1630 .name = "mem:0:r:hp",
1631 .check = test__checkevent_breakpoint_r_modifier,
1632 .id = 21,
1635 .name = "mem:0:w:up",
1636 .check = test__checkevent_breakpoint_w_modifier,
1637 .id = 22,
1640 .name = "r1,syscalls:sys_enter_openat:k,1:1:hp",
1641 .check = test__checkevent_list,
1642 .id = 23,
1645 .name = "instructions:G",
1646 .check = test__checkevent_exclude_host_modifier,
1647 .id = 24,
1650 .name = "instructions:H",
1651 .check = test__checkevent_exclude_guest_modifier,
1652 .id = 25,
1655 .name = "mem:0:rw",
1656 .check = test__checkevent_breakpoint_rw,
1657 .id = 26,
1660 .name = "mem:0:rw:kp",
1661 .check = test__checkevent_breakpoint_rw_modifier,
1662 .id = 27,
1665 .name = "{instructions:k,cycles:upp}",
1666 .check = test__group1,
1667 .id = 28,
1670 .name = "{faults:k,cache-references}:u,cycles:k",
1671 .check = test__group2,
1672 .id = 29,
1675 .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
1676 .check = test__group3,
1677 .id = 30,
1680 .name = "{cycles:u,instructions:kp}:p",
1681 .check = test__group4,
1682 .id = 31,
1685 .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
1686 .check = test__group5,
1687 .id = 32,
1690 .name = "*:*",
1691 .check = test__all_tracepoints,
1692 .id = 33,
1695 .name = "{cycles,cache-misses:G}:H",
1696 .check = test__group_gh1,
1697 .id = 34,
1700 .name = "{cycles,cache-misses:H}:G",
1701 .check = test__group_gh2,
1702 .id = 35,
1705 .name = "{cycles:G,cache-misses:H}:u",
1706 .check = test__group_gh3,
1707 .id = 36,
1710 .name = "{cycles:G,cache-misses:H}:uG",
1711 .check = test__group_gh4,
1712 .id = 37,
1715 .name = "{cycles,cache-misses,branch-misses}:S",
1716 .check = test__leader_sample1,
1717 .id = 38,
1720 .name = "{instructions,branch-misses}:Su",
1721 .check = test__leader_sample2,
1722 .id = 39,
1725 .name = "instructions:uDp",
1726 .check = test__checkevent_pinned_modifier,
1727 .id = 40,
1730 .name = "{cycles,cache-misses,branch-misses}:D",
1731 .check = test__pinned_group,
1732 .id = 41,
1735 .name = "mem:0/1",
1736 .check = test__checkevent_breakpoint_len,
1737 .id = 42,
1740 .name = "mem:0/2:w",
1741 .check = test__checkevent_breakpoint_len_w,
1742 .id = 43,
1745 .name = "mem:0/4:rw:u",
1746 .check = test__checkevent_breakpoint_len_rw_modifier,
1747 .id = 44
1749 #if defined(__s390x__)
1751 .name = "kvm-s390:kvm_s390_create_vm",
1752 .check = test__checkevent_tracepoint,
1753 .valid = kvm_s390_create_vm_valid,
1754 .id = 100,
1756 #endif
1758 .name = "instructions:I",
1759 .check = test__checkevent_exclude_idle_modifier,
1760 .id = 45,
1763 .name = "instructions:kIG",
1764 .check = test__checkevent_exclude_idle_modifier_1,
1765 .id = 46,
1768 .name = "task-clock:P,cycles",
1769 .check = test__checkevent_precise_max_modifier,
1770 .id = 47,
1773 .name = "instructions/name=insn/",
1774 .check = test__checkevent_config_symbol,
1775 .id = 48,
1778 .name = "r1234/name=rawpmu/",
1779 .check = test__checkevent_config_raw,
1780 .id = 49,
1783 .name = "4:0x6530160/name=numpmu/",
1784 .check = test__checkevent_config_num,
1785 .id = 50,
1788 .name = "L1-dcache-misses/name=cachepmu/",
1789 .check = test__checkevent_config_cache,
1790 .id = 51,
1793 .name = "intel_pt//u",
1794 .valid = test__intel_pt_valid,
1795 .check = test__intel_pt,
1796 .id = 52,
1799 .name = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk",
1800 .check = test__checkevent_complex_name,
1801 .id = 53
1804 .name = "cycles//u",
1805 .check = test__sym_event_slash,
1806 .id = 54,
1809 .name = "cycles:k",
1810 .check = test__sym_event_dc,
1811 .id = 55,
1814 .name = "instructions:uep",
1815 .check = test__checkevent_exclusive_modifier,
1816 .id = 56,
1819 .name = "{cycles,cache-misses,branch-misses}:e",
1820 .check = test__exclusive_group,
1821 .id = 57,
1825 static struct evlist_test test__events_pmu[] = {
1827 .name = "cpu/config=10,config1,config2=3,period=1000/u",
1828 .check = test__checkevent_pmu,
1829 .id = 0,
1832 .name = "cpu/config=1,name=krava/u,cpu/config=2/u",
1833 .check = test__checkevent_pmu_name,
1834 .id = 1,
1837 .name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
1838 .check = test__checkevent_pmu_partial_time_callgraph,
1839 .id = 2,
1842 .name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
1843 .check = test__checkevent_complex_name,
1844 .id = 3,
1847 .name = "software/r1a/",
1848 .check = test__checkevent_raw_pmu,
1849 .id = 4,
1852 .name = "software/r0x1a/",
1853 .check = test__checkevent_raw_pmu,
1854 .id = 4,
1858 struct terms_test {
1859 const char *str;
1860 __u32 type;
1861 int (*check)(struct list_head *terms);
1864 static struct terms_test test__terms[] = {
1865 [0] = {
1866 .str = "config=10,config1,config2=3,umask=1,read,r0xead",
1867 .check = test__checkterms_simple,
1871 static int test_event(struct evlist_test *e)
1873 struct parse_events_error err;
1874 struct evlist *evlist;
1875 int ret;
1877 bzero(&err, sizeof(err));
1878 if (e->valid && !e->valid()) {
1879 pr_debug("... SKIP");
1880 return 0;
1883 evlist = evlist__new();
1884 if (evlist == NULL)
1885 return -ENOMEM;
1887 ret = parse_events(evlist, e->name, &err);
1888 if (ret) {
1889 pr_debug("failed to parse event '%s', err %d, str '%s'\n",
1890 e->name, ret, err.str);
1891 parse_events_print_error(&err, e->name);
1892 } else {
1893 ret = e->check(evlist);
1896 evlist__delete(evlist);
1898 return ret;
1901 static int test_events(struct evlist_test *events, unsigned cnt)
1903 int ret1, ret2 = 0;
1904 unsigned i;
1906 for (i = 0; i < cnt; i++) {
1907 struct evlist_test *e = &events[i];
1909 pr_debug("running test %d '%s'", e->id, e->name);
1910 ret1 = test_event(e);
1911 if (ret1)
1912 ret2 = ret1;
1913 pr_debug("\n");
1916 return ret2;
1919 static int test_term(struct terms_test *t)
1921 struct list_head terms;
1922 int ret;
1924 INIT_LIST_HEAD(&terms);
1927 * The perf_pmu__test_parse_init prepares perf_pmu_events_list
1928 * which gets freed in parse_events_terms.
1930 if (perf_pmu__test_parse_init())
1931 return -1;
1933 ret = parse_events_terms(&terms, t->str);
1934 if (ret) {
1935 pr_debug("failed to parse terms '%s', err %d\n",
1936 t->str , ret);
1937 return ret;
1940 ret = t->check(&terms);
1941 parse_events_terms__purge(&terms);
1943 return ret;
1946 static int test_terms(struct terms_test *terms, unsigned cnt)
1948 int ret = 0;
1949 unsigned i;
1951 for (i = 0; i < cnt; i++) {
1952 struct terms_test *t = &terms[i];
1954 pr_debug("running test %d '%s'\n", i, t->str);
1955 ret = test_term(t);
1956 if (ret)
1957 break;
1960 return ret;
1963 static int test_pmu(void)
1965 struct stat st;
1966 char path[PATH_MAX];
1967 int ret;
1969 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
1970 sysfs__mountpoint());
1972 ret = stat(path, &st);
1973 if (ret)
1974 pr_debug("omitting PMU cpu tests\n");
1975 return !ret;
1978 static int test_pmu_events(void)
1980 struct stat st;
1981 char path[PATH_MAX];
1982 struct dirent *ent;
1983 DIR *dir;
1984 int ret;
1986 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
1987 sysfs__mountpoint());
1989 ret = stat(path, &st);
1990 if (ret) {
1991 pr_debug("omitting PMU cpu events tests\n");
1992 return 0;
1995 dir = opendir(path);
1996 if (!dir) {
1997 pr_debug("can't open pmu event dir");
1998 return -1;
2001 while (!ret && (ent = readdir(dir))) {
2002 struct evlist_test e = { .id = 0, };
2003 char name[2 * NAME_MAX + 1 + 12 + 3];
2005 /* Names containing . are special and cannot be used directly */
2006 if (strchr(ent->d_name, '.'))
2007 continue;
2009 snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
2011 e.name = name;
2012 e.check = test__checkevent_pmu_events;
2014 ret = test_event(&e);
2015 if (ret)
2016 break;
2017 snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
2018 e.name = name;
2019 e.check = test__checkevent_pmu_events_mix;
2020 ret = test_event(&e);
2023 closedir(dir);
2024 return ret;
2027 int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
2029 int ret1, ret2 = 0;
2031 #define TEST_EVENTS(tests) \
2032 do { \
2033 ret1 = test_events(tests, ARRAY_SIZE(tests)); \
2034 if (!ret2) \
2035 ret2 = ret1; \
2036 } while (0)
2038 TEST_EVENTS(test__events);
2040 if (test_pmu())
2041 TEST_EVENTS(test__events_pmu);
2043 if (test_pmu()) {
2044 int ret = test_pmu_events();
2045 if (ret)
2046 return ret;
2049 ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));
2050 if (!ret2)
2051 ret2 = ret1;
2053 return ret2;