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 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
17 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
19 static int test__checkevent_tracepoint(struct perf_evlist
*evlist
)
21 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
23 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
24 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT
== evsel
->attr
.type
);
25 TEST_ASSERT_VAL("wrong sample_type",
26 PERF_TP_SAMPLE_TYPE
== evsel
->attr
.sample_type
);
27 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel
->attr
.sample_period
);
31 static int test__checkevent_tracepoint_multi(struct perf_evlist
*evlist
)
33 struct perf_evsel
*evsel
;
35 TEST_ASSERT_VAL("wrong number of entries", evlist
->nr_entries
> 1);
37 list_for_each_entry(evsel
, &evlist
->entries
, node
) {
38 TEST_ASSERT_VAL("wrong type",
39 PERF_TYPE_TRACEPOINT
== evsel
->attr
.type
);
40 TEST_ASSERT_VAL("wrong sample_type",
41 PERF_TP_SAMPLE_TYPE
== 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
= perf_evlist__first(evlist
);
52 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
53 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW
== evsel
->attr
.type
);
54 TEST_ASSERT_VAL("wrong config", 0x1a == evsel
->attr
.config
);
58 static int test__checkevent_numeric(struct perf_evlist
*evlist
)
60 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
62 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
63 TEST_ASSERT_VAL("wrong type", 1 == evsel
->attr
.type
);
64 TEST_ASSERT_VAL("wrong config", 1 == evsel
->attr
.config
);
68 static int test__checkevent_symbolic_name(struct perf_evlist
*evlist
)
70 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
72 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
73 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
74 TEST_ASSERT_VAL("wrong config",
75 PERF_COUNT_HW_INSTRUCTIONS
== evsel
->attr
.config
);
79 static int test__checkevent_symbolic_name_config(struct perf_evlist
*evlist
)
81 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
83 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
84 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
85 TEST_ASSERT_VAL("wrong config",
86 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
87 TEST_ASSERT_VAL("wrong period",
88 100000 == evsel
->attr
.sample_period
);
89 TEST_ASSERT_VAL("wrong config1",
90 0 == evsel
->attr
.config1
);
91 TEST_ASSERT_VAL("wrong config2",
92 1 == evsel
->attr
.config2
);
96 static int test__checkevent_symbolic_alias(struct perf_evlist
*evlist
)
98 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
100 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
101 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE
== evsel
->attr
.type
);
102 TEST_ASSERT_VAL("wrong config",
103 PERF_COUNT_SW_PAGE_FAULTS
== evsel
->attr
.config
);
107 static int test__checkevent_genhw(struct perf_evlist
*evlist
)
109 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
111 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
112 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE
== evsel
->attr
.type
);
113 TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel
->attr
.config
);
117 static int test__checkevent_breakpoint(struct perf_evlist
*evlist
)
119 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
121 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
122 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT
== evsel
->attr
.type
);
123 TEST_ASSERT_VAL("wrong config", 0 == evsel
->attr
.config
);
124 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R
| HW_BREAKPOINT_W
) ==
125 evsel
->attr
.bp_type
);
126 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4
==
131 static int test__checkevent_breakpoint_x(struct perf_evlist
*evlist
)
133 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
135 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
136 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT
== evsel
->attr
.type
);
137 TEST_ASSERT_VAL("wrong config", 0 == evsel
->attr
.config
);
138 TEST_ASSERT_VAL("wrong bp_type",
139 HW_BREAKPOINT_X
== evsel
->attr
.bp_type
);
140 TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel
->attr
.bp_len
);
144 static int test__checkevent_breakpoint_r(struct perf_evlist
*evlist
)
146 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
148 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
149 TEST_ASSERT_VAL("wrong type",
150 PERF_TYPE_BREAKPOINT
== evsel
->attr
.type
);
151 TEST_ASSERT_VAL("wrong config", 0 == evsel
->attr
.config
);
152 TEST_ASSERT_VAL("wrong bp_type",
153 HW_BREAKPOINT_R
== evsel
->attr
.bp_type
);
154 TEST_ASSERT_VAL("wrong bp_len",
155 HW_BREAKPOINT_LEN_4
== evsel
->attr
.bp_len
);
159 static int test__checkevent_breakpoint_w(struct perf_evlist
*evlist
)
161 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
163 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
164 TEST_ASSERT_VAL("wrong type",
165 PERF_TYPE_BREAKPOINT
== evsel
->attr
.type
);
166 TEST_ASSERT_VAL("wrong config", 0 == evsel
->attr
.config
);
167 TEST_ASSERT_VAL("wrong bp_type",
168 HW_BREAKPOINT_W
== evsel
->attr
.bp_type
);
169 TEST_ASSERT_VAL("wrong bp_len",
170 HW_BREAKPOINT_LEN_4
== evsel
->attr
.bp_len
);
174 static int test__checkevent_breakpoint_rw(struct perf_evlist
*evlist
)
176 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
178 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
179 TEST_ASSERT_VAL("wrong type",
180 PERF_TYPE_BREAKPOINT
== evsel
->attr
.type
);
181 TEST_ASSERT_VAL("wrong config", 0 == evsel
->attr
.config
);
182 TEST_ASSERT_VAL("wrong bp_type",
183 (HW_BREAKPOINT_R
|HW_BREAKPOINT_W
) == evsel
->attr
.bp_type
);
184 TEST_ASSERT_VAL("wrong bp_len",
185 HW_BREAKPOINT_LEN_4
== evsel
->attr
.bp_len
);
189 static int test__checkevent_tracepoint_modifier(struct perf_evlist
*evlist
)
191 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
193 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
194 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
195 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
196 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
198 return test__checkevent_tracepoint(evlist
);
202 test__checkevent_tracepoint_multi_modifier(struct perf_evlist
*evlist
)
204 struct perf_evsel
*evsel
;
206 TEST_ASSERT_VAL("wrong number of entries", evlist
->nr_entries
> 1);
208 list_for_each_entry(evsel
, &evlist
->entries
, node
) {
209 TEST_ASSERT_VAL("wrong exclude_user",
210 !evsel
->attr
.exclude_user
);
211 TEST_ASSERT_VAL("wrong exclude_kernel",
212 evsel
->attr
.exclude_kernel
);
213 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
214 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
217 return test__checkevent_tracepoint_multi(evlist
);
220 static int test__checkevent_raw_modifier(struct perf_evlist
*evlist
)
222 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
224 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
225 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
226 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
227 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
);
229 return test__checkevent_raw(evlist
);
232 static int test__checkevent_numeric_modifier(struct perf_evlist
*evlist
)
234 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
236 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
237 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
238 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
239 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
);
241 return test__checkevent_numeric(evlist
);
244 static int test__checkevent_symbolic_name_modifier(struct perf_evlist
*evlist
)
246 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
248 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
249 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
250 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
251 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
253 return test__checkevent_symbolic_name(evlist
);
256 static int test__checkevent_exclude_host_modifier(struct perf_evlist
*evlist
)
258 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
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
= perf_evlist__first(evlist
);
270 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
271 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
273 return test__checkevent_symbolic_name(evlist
);
276 static int test__checkevent_symbolic_alias_modifier(struct perf_evlist
*evlist
)
278 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
280 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
281 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
282 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
283 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
285 return test__checkevent_symbolic_alias(evlist
);
288 static int test__checkevent_genhw_modifier(struct perf_evlist
*evlist
)
290 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
292 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
293 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
294 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
295 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
);
297 return test__checkevent_genhw(evlist
);
300 static int test__checkevent_breakpoint_modifier(struct perf_evlist
*evlist
)
302 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
305 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
306 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
307 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
308 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
309 TEST_ASSERT_VAL("wrong name",
310 !strcmp(perf_evsel__name(evsel
), "mem:0:u"));
312 return test__checkevent_breakpoint(evlist
);
315 static int test__checkevent_breakpoint_x_modifier(struct perf_evlist
*evlist
)
317 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
319 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
320 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
321 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
322 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
323 TEST_ASSERT_VAL("wrong name",
324 !strcmp(perf_evsel__name(evsel
), "mem:0:x:k"));
326 return test__checkevent_breakpoint_x(evlist
);
329 static int test__checkevent_breakpoint_r_modifier(struct perf_evlist
*evlist
)
331 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
333 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
334 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
335 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
336 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
);
337 TEST_ASSERT_VAL("wrong name",
338 !strcmp(perf_evsel__name(evsel
), "mem:0:r:hp"));
340 return test__checkevent_breakpoint_r(evlist
);
343 static int test__checkevent_breakpoint_w_modifier(struct perf_evlist
*evlist
)
345 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
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
);
351 TEST_ASSERT_VAL("wrong name",
352 !strcmp(perf_evsel__name(evsel
), "mem:0:w:up"));
354 return test__checkevent_breakpoint_w(evlist
);
357 static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist
*evlist
)
359 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
361 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
362 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
363 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
364 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
);
365 TEST_ASSERT_VAL("wrong name",
366 !strcmp(perf_evsel__name(evsel
), "mem:0:rw:kp"));
368 return test__checkevent_breakpoint_rw(evlist
);
371 static int test__checkevent_pmu(struct perf_evlist
*evlist
)
374 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
376 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist
->nr_entries
);
377 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW
== evsel
->attr
.type
);
378 TEST_ASSERT_VAL("wrong config", 10 == evsel
->attr
.config
);
379 TEST_ASSERT_VAL("wrong config1", 1 == evsel
->attr
.config1
);
380 TEST_ASSERT_VAL("wrong config2", 3 == evsel
->attr
.config2
);
381 TEST_ASSERT_VAL("wrong period", 1000 == evsel
->attr
.sample_period
);
386 static int test__checkevent_list(struct perf_evlist
*evlist
)
388 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
390 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist
->nr_entries
);
393 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW
== evsel
->attr
.type
);
394 TEST_ASSERT_VAL("wrong config", 1 == evsel
->attr
.config
);
395 TEST_ASSERT_VAL("wrong config1", 0 == evsel
->attr
.config1
);
396 TEST_ASSERT_VAL("wrong config2", 0 == evsel
->attr
.config2
);
397 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
398 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
399 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
400 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
402 /* syscalls:sys_enter_open:k */
403 evsel
= perf_evsel__next(evsel
);
404 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT
== evsel
->attr
.type
);
405 TEST_ASSERT_VAL("wrong sample_type",
406 PERF_TP_SAMPLE_TYPE
== evsel
->attr
.sample_type
);
407 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel
->attr
.sample_period
);
408 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
409 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
410 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
411 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
414 evsel
= perf_evsel__next(evsel
);
415 TEST_ASSERT_VAL("wrong type", 1 == evsel
->attr
.type
);
416 TEST_ASSERT_VAL("wrong config", 1 == evsel
->attr
.config
);
417 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
418 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
419 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
420 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
);
425 static int test__checkevent_pmu_name(struct perf_evlist
*evlist
)
427 struct perf_evsel
*evsel
= perf_evlist__first(evlist
);
429 /* cpu/config=1,name=krava/u */
430 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist
->nr_entries
);
431 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW
== evsel
->attr
.type
);
432 TEST_ASSERT_VAL("wrong config", 1 == evsel
->attr
.config
);
433 TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel
), "krava"));
435 /* cpu/config=2/u" */
436 evsel
= perf_evsel__next(evsel
);
437 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist
->nr_entries
);
438 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW
== evsel
->attr
.type
);
439 TEST_ASSERT_VAL("wrong config", 2 == evsel
->attr
.config
);
440 TEST_ASSERT_VAL("wrong name",
441 !strcmp(perf_evsel__name(evsel
), "cpu/config=2/u"));
446 static int test__checkterms_simple(struct list_head
*terms
)
448 struct parse_events__term
*term
;
451 term
= list_entry(terms
->next
, struct parse_events__term
, list
);
452 TEST_ASSERT_VAL("wrong type term",
453 term
->type_term
== PARSE_EVENTS__TERM_TYPE_CONFIG
);
454 TEST_ASSERT_VAL("wrong type val",
455 term
->type_val
== PARSE_EVENTS__TERM_TYPE_NUM
);
456 TEST_ASSERT_VAL("wrong val", term
->val
.num
== 10);
457 TEST_ASSERT_VAL("wrong config", !term
->config
);
460 term
= list_entry(term
->list
.next
, struct parse_events__term
, list
);
461 TEST_ASSERT_VAL("wrong type term",
462 term
->type_term
== PARSE_EVENTS__TERM_TYPE_CONFIG1
);
463 TEST_ASSERT_VAL("wrong type val",
464 term
->type_val
== PARSE_EVENTS__TERM_TYPE_NUM
);
465 TEST_ASSERT_VAL("wrong val", term
->val
.num
== 1);
466 TEST_ASSERT_VAL("wrong config", !term
->config
);
469 term
= list_entry(term
->list
.next
, struct parse_events__term
, list
);
470 TEST_ASSERT_VAL("wrong type term",
471 term
->type_term
== PARSE_EVENTS__TERM_TYPE_CONFIG2
);
472 TEST_ASSERT_VAL("wrong type val",
473 term
->type_val
== PARSE_EVENTS__TERM_TYPE_NUM
);
474 TEST_ASSERT_VAL("wrong val", term
->val
.num
== 3);
475 TEST_ASSERT_VAL("wrong config", !term
->config
);
478 term
= list_entry(term
->list
.next
, struct parse_events__term
, list
);
479 TEST_ASSERT_VAL("wrong type term",
480 term
->type_term
== PARSE_EVENTS__TERM_TYPE_USER
);
481 TEST_ASSERT_VAL("wrong type val",
482 term
->type_val
== PARSE_EVENTS__TERM_TYPE_NUM
);
483 TEST_ASSERT_VAL("wrong val", term
->val
.num
== 1);
484 TEST_ASSERT_VAL("wrong config", !strcmp(term
->config
, "umask"));
489 static int test__group1(struct perf_evlist
*evlist
)
491 struct perf_evsel
*evsel
, *leader
;
493 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist
->nr_entries
);
496 evsel
= leader
= perf_evlist__first(evlist
);
497 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
498 TEST_ASSERT_VAL("wrong config",
499 PERF_COUNT_HW_INSTRUCTIONS
== evsel
->attr
.config
);
500 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
501 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
502 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
503 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
504 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
505 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
506 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
509 evsel
= perf_evsel__next(evsel
);
510 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
511 TEST_ASSERT_VAL("wrong config",
512 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
513 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
514 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
515 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
516 /* use of precise requires exclude_guest */
517 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
518 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
519 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
== 2);
520 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
525 static int test__group2(struct perf_evlist
*evlist
)
527 struct perf_evsel
*evsel
, *leader
;
529 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist
->nr_entries
);
531 /* faults + :ku modifier */
532 evsel
= leader
= perf_evlist__first(evlist
);
533 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE
== evsel
->attr
.type
);
534 TEST_ASSERT_VAL("wrong config",
535 PERF_COUNT_SW_PAGE_FAULTS
== evsel
->attr
.config
);
536 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
537 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
538 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
539 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
540 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
541 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
542 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
544 /* cache-references + :u modifier */
545 evsel
= perf_evsel__next(evsel
);
546 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
547 TEST_ASSERT_VAL("wrong config",
548 PERF_COUNT_HW_CACHE_REFERENCES
== evsel
->attr
.config
);
549 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
550 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
551 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
552 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
553 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
554 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
555 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
558 evsel
= perf_evsel__next(evsel
);
559 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
560 TEST_ASSERT_VAL("wrong config",
561 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
562 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
563 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
564 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
565 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
566 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
567 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
568 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
573 static int test__group3(struct perf_evlist
*evlist __maybe_unused
)
575 struct perf_evsel
*evsel
, *leader
;
577 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist
->nr_entries
);
579 /* group1 syscalls:sys_enter_open:H */
580 evsel
= leader
= perf_evlist__first(evlist
);
581 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT
== evsel
->attr
.type
);
582 TEST_ASSERT_VAL("wrong sample_type",
583 PERF_TP_SAMPLE_TYPE
== evsel
->attr
.sample_type
);
584 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel
->attr
.sample_period
);
585 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
586 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
587 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
588 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
589 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
590 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
591 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
592 TEST_ASSERT_VAL("wrong group name",
593 !strcmp(leader
->group_name
, "group1"));
595 /* group1 cycles:kppp */
596 evsel
= perf_evsel__next(evsel
);
597 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
598 TEST_ASSERT_VAL("wrong config",
599 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
600 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
601 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
602 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
603 /* use of precise requires exclude_guest */
604 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
605 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
606 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
== 3);
607 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
608 TEST_ASSERT_VAL("wrong group name", !evsel
->group_name
);
610 /* group2 cycles + G modifier */
611 evsel
= leader
= perf_evsel__next(evsel
);
612 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
613 TEST_ASSERT_VAL("wrong config",
614 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
615 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
616 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
617 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
618 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
619 TEST_ASSERT_VAL("wrong exclude host", evsel
->attr
.exclude_host
);
620 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
621 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
622 TEST_ASSERT_VAL("wrong group name",
623 !strcmp(leader
->group_name
, "group2"));
625 /* group2 1:3 + G modifier */
626 evsel
= perf_evsel__next(evsel
);
627 TEST_ASSERT_VAL("wrong type", 1 == evsel
->attr
.type
);
628 TEST_ASSERT_VAL("wrong config", 3 == evsel
->attr
.config
);
629 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
630 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
631 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
632 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
633 TEST_ASSERT_VAL("wrong exclude host", evsel
->attr
.exclude_host
);
634 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
635 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
638 evsel
= perf_evsel__next(evsel
);
639 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
640 TEST_ASSERT_VAL("wrong config",
641 PERF_COUNT_HW_INSTRUCTIONS
== evsel
->attr
.config
);
642 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
643 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
644 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
645 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
646 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
647 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
648 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
653 static int test__group4(struct perf_evlist
*evlist __maybe_unused
)
655 struct perf_evsel
*evsel
, *leader
;
657 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist
->nr_entries
);
660 evsel
= leader
= perf_evlist__first(evlist
);
661 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
662 TEST_ASSERT_VAL("wrong config",
663 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
664 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
665 TEST_ASSERT_VAL("wrong exclude_kernel", evsel
->attr
.exclude_kernel
);
666 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
667 /* use of precise requires exclude_guest */
668 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
669 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
670 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
== 1);
671 TEST_ASSERT_VAL("wrong group name", !evsel
->group_name
);
672 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
674 /* instructions:kp + p */
675 evsel
= perf_evsel__next(evsel
);
676 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
677 TEST_ASSERT_VAL("wrong config",
678 PERF_COUNT_HW_INSTRUCTIONS
== evsel
->attr
.config
);
679 TEST_ASSERT_VAL("wrong exclude_user", evsel
->attr
.exclude_user
);
680 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
681 TEST_ASSERT_VAL("wrong exclude_hv", evsel
->attr
.exclude_hv
);
682 /* use of precise requires exclude_guest */
683 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
684 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
685 TEST_ASSERT_VAL("wrong precise_ip", evsel
->attr
.precise_ip
== 2);
686 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
691 static int test__group5(struct perf_evlist
*evlist __maybe_unused
)
693 struct perf_evsel
*evsel
, *leader
;
695 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist
->nr_entries
);
698 evsel
= leader
= perf_evlist__first(evlist
);
699 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
700 TEST_ASSERT_VAL("wrong config",
701 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
702 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
703 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
704 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
705 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
706 TEST_ASSERT_VAL("wrong exclude host", evsel
->attr
.exclude_host
);
707 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
708 TEST_ASSERT_VAL("wrong group name", !evsel
->group_name
);
709 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
711 /* instructions + G */
712 evsel
= perf_evsel__next(evsel
);
713 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
714 TEST_ASSERT_VAL("wrong config",
715 PERF_COUNT_HW_INSTRUCTIONS
== evsel
->attr
.config
);
716 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
717 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
718 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
719 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
720 TEST_ASSERT_VAL("wrong exclude host", evsel
->attr
.exclude_host
);
721 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
722 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
725 evsel
= leader
= perf_evsel__next(evsel
);
726 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
727 TEST_ASSERT_VAL("wrong config",
728 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
729 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
730 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
731 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
732 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
733 TEST_ASSERT_VAL("wrong exclude host", evsel
->attr
.exclude_host
);
734 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
735 TEST_ASSERT_VAL("wrong group name", !evsel
->group_name
);
736 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
739 evsel
= perf_evsel__next(evsel
);
740 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
741 TEST_ASSERT_VAL("wrong config",
742 PERF_COUNT_HW_INSTRUCTIONS
== evsel
->attr
.config
);
743 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
744 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
745 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
746 TEST_ASSERT_VAL("wrong exclude guest", !evsel
->attr
.exclude_guest
);
747 TEST_ASSERT_VAL("wrong exclude host", evsel
->attr
.exclude_host
);
748 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
749 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== leader
);
752 evsel
= perf_evsel__next(evsel
);
753 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE
== evsel
->attr
.type
);
754 TEST_ASSERT_VAL("wrong config",
755 PERF_COUNT_HW_CPU_CYCLES
== evsel
->attr
.config
);
756 TEST_ASSERT_VAL("wrong exclude_user", !evsel
->attr
.exclude_user
);
757 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel
->attr
.exclude_kernel
);
758 TEST_ASSERT_VAL("wrong exclude_hv", !evsel
->attr
.exclude_hv
);
759 TEST_ASSERT_VAL("wrong exclude guest", evsel
->attr
.exclude_guest
);
760 TEST_ASSERT_VAL("wrong exclude host", !evsel
->attr
.exclude_host
);
761 TEST_ASSERT_VAL("wrong precise_ip", !evsel
->attr
.precise_ip
);
762 TEST_ASSERT_VAL("wrong leader", evsel
->leader
== NULL
);
767 struct test__event_st
{
770 int (*check
)(struct perf_evlist
*evlist
);
773 static struct test__event_st test__events
[] = {
775 .name
= "syscalls:sys_enter_open",
776 .check
= test__checkevent_tracepoint
,
779 .name
= "syscalls:*",
780 .check
= test__checkevent_tracepoint_multi
,
784 .check
= test__checkevent_raw
,
788 .check
= test__checkevent_numeric
,
791 .name
= "instructions",
792 .check
= test__checkevent_symbolic_name
,
795 .name
= "cycles/period=100000,config2/",
796 .check
= test__checkevent_symbolic_name_config
,
800 .check
= test__checkevent_symbolic_alias
,
803 .name
= "L1-dcache-load-miss",
804 .check
= test__checkevent_genhw
,
808 .check
= test__checkevent_breakpoint
,
812 .check
= test__checkevent_breakpoint_x
,
816 .check
= test__checkevent_breakpoint_r
,
820 .check
= test__checkevent_breakpoint_w
,
823 .name
= "syscalls:sys_enter_open:k",
824 .check
= test__checkevent_tracepoint_modifier
,
827 .name
= "syscalls:*:u",
828 .check
= test__checkevent_tracepoint_multi_modifier
,
832 .check
= test__checkevent_raw_modifier
,
836 .check
= test__checkevent_numeric_modifier
,
839 .name
= "instructions:h",
840 .check
= test__checkevent_symbolic_name_modifier
,
844 .check
= test__checkevent_symbolic_alias_modifier
,
847 .name
= "L1-dcache-load-miss:kp",
848 .check
= test__checkevent_genhw_modifier
,
852 .check
= test__checkevent_breakpoint_modifier
,
856 .check
= test__checkevent_breakpoint_x_modifier
,
859 .name
= "mem:0:r:hp",
860 .check
= test__checkevent_breakpoint_r_modifier
,
863 .name
= "mem:0:w:up",
864 .check
= test__checkevent_breakpoint_w_modifier
,
867 .name
= "r1,syscalls:sys_enter_open:k,1:1:hp",
868 .check
= test__checkevent_list
,
871 .name
= "instructions:G",
872 .check
= test__checkevent_exclude_host_modifier
,
875 .name
= "instructions:H",
876 .check
= test__checkevent_exclude_guest_modifier
,
880 .check
= test__checkevent_breakpoint_rw
,
883 .name
= "mem:0:rw:kp",
884 .check
= test__checkevent_breakpoint_rw_modifier
,
887 .name
= "{instructions:k,cycles:upp}",
888 .check
= test__group1
,
891 .name
= "{faults:k,cache-references}:u,cycles:k",
892 .check
= test__group2
,
895 .name
= "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
896 .check
= test__group3
,
899 .name
= "{cycles:u,instructions:kp}:p",
900 .check
= test__group4
,
903 .name
= "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
904 .check
= test__group5
,
908 static struct test__event_st test__events_pmu
[] = {
910 .name
= "cpu/config=10,config1,config2=3,period=1000/u",
911 .check
= test__checkevent_pmu
,
914 .name
= "cpu/config=1,name=krava/u,cpu/config=2/u",
915 .check
= test__checkevent_pmu_name
,
922 int (*check
)(struct list_head
*terms
);
925 static struct test__term test__terms
[] = {
927 .str
= "config=10,config1,config2=3,umask=1",
928 .check
= test__checkterms_simple
,
932 static int test_event(struct test__event_st
*e
)
934 struct perf_evlist
*evlist
;
937 evlist
= perf_evlist__new(NULL
, NULL
);
941 ret
= parse_events(evlist
, e
->name
, 0);
943 pr_debug("failed to parse event '%s', err %d\n",
948 ret
= e
->check(evlist
);
949 perf_evlist__delete(evlist
);
954 static int test_events(struct test__event_st
*events
, unsigned cnt
)
959 for (i
= 0; i
< cnt
; i
++) {
960 struct test__event_st
*e
= &events
[i
];
962 pr_debug("running test %d '%s'\n", i
, e
->name
);
963 ret1
= test_event(e
);
971 static int test_term(struct test__term
*t
)
973 struct list_head
*terms
;
976 terms
= malloc(sizeof(*terms
));
980 INIT_LIST_HEAD(terms
);
982 ret
= parse_events_terms(terms
, t
->str
);
984 pr_debug("failed to parse terms '%s', err %d\n",
989 ret
= t
->check(terms
);
990 parse_events__free_terms(terms
);
995 static int test_terms(struct test__term
*terms
, unsigned cnt
)
1000 for (i
= 0; i
< cnt
; i
++) {
1001 struct test__term
*t
= &terms
[i
];
1003 pr_debug("running test %d '%s'\n", i
, t
->str
);
1012 static int test_pmu(void)
1015 char path
[PATH_MAX
];
1018 snprintf(path
, PATH_MAX
, "%s/bus/event_source/devices/cpu/format/",
1019 sysfs_find_mountpoint());
1021 ret
= stat(path
, &st
);
1023 pr_debug("omitting PMU cpu tests\n");
1027 int parse_events__test(void)
1031 #define TEST_EVENTS(tests) \
1033 ret1 = test_events(tests, ARRAY_SIZE(tests)); \
1038 TEST_EVENTS(test__events
);
1041 TEST_EVENTS(test__events_pmu
);
1043 ret1
= test_terms(test__terms
, ARRAY_SIZE(test__terms
));