6 #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);
31 static int test__checkevent_tracepoint_multi(
struct perf_evlist *evlist)
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);
58 static int test__checkevent_numeric(
struct perf_evlist *evlist)
60 struct perf_evsel *evsel = perf_evlist__first(evlist);
68 static int test__checkevent_symbolic_name(
struct perf_evlist *evlist)
70 struct perf_evsel *evsel = perf_evlist__first(evlist);
79 static int test__checkevent_symbolic_name_config(
struct perf_evlist *evlist)
81 struct perf_evsel *evsel = perf_evlist__first(evlist);
88 100000 == evsel->
attr.sample_period);
90 0 == evsel->
attr.config1);
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);
107 static int test__checkevent_genhw(
struct perf_evlist *evlist)
109 struct perf_evsel *evsel = perf_evlist__first(evlist);
117 static int test__checkevent_breakpoint(
struct perf_evlist *evlist)
119 struct perf_evsel *evsel = perf_evlist__first(evlist);
125 evsel->
attr.bp_type);
131 static int test__checkevent_breakpoint_x(
struct perf_evlist *evlist)
133 struct perf_evsel *evsel = perf_evlist__first(evlist);
144 static int test__checkevent_breakpoint_r(
struct perf_evlist *evlist)
146 struct perf_evsel *evsel = perf_evlist__first(evlist);
159 static int test__checkevent_breakpoint_w(
struct perf_evlist *evlist)
161 struct perf_evsel *evsel = perf_evlist__first(evlist);
174 static int test__checkevent_breakpoint_rw(
struct perf_evlist *evlist)
176 struct perf_evsel *evsel = perf_evlist__first(evlist);
189 static int test__checkevent_tracepoint_modifier(
struct perf_evlist *evlist)
191 struct perf_evsel *evsel = perf_evlist__first(evlist);
198 return test__checkevent_tracepoint(evlist);
202 test__checkevent_tracepoint_multi_modifier(
struct perf_evlist *evlist)
210 !evsel->
attr.exclude_user);
212 evsel->
attr.exclude_kernel);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
386 static int test__checkevent_list(
struct perf_evlist *evlist)
388 struct perf_evsel *evsel = perf_evlist__first(evlist);
403 evsel = perf_evsel__next(evsel);
414 evsel = perf_evsel__next(evsel);
425 static int test__checkevent_pmu_name(
struct perf_evlist *evlist)
427 struct perf_evsel *evsel = perf_evlist__first(evlist);
436 evsel = perf_evsel__next(evsel);
446 static int test__checkterms_simple(
struct list_head *terms)
489 static int test__group1(
struct perf_evlist *evlist)
496 evsel = leader = perf_evlist__first(evlist);
509 evsel = perf_evsel__next(evsel);
525 static int test__group2(
struct perf_evlist *evlist)
532 evsel = leader = perf_evlist__first(evlist);
545 evsel = perf_evsel__next(evsel);
558 evsel = perf_evsel__next(evsel);
580 evsel = leader = perf_evlist__first(evlist);
596 evsel = perf_evsel__next(evsel);
611 evsel = leader = perf_evsel__next(evsel);
626 evsel = perf_evsel__next(evsel);
638 evsel = perf_evsel__next(evsel);
653 static int test__group4(
struct perf_evlist *evlist __maybe_unused)
660 evsel = leader = perf_evlist__first(evlist);
675 evsel = perf_evsel__next(evsel);
691 static int test__group5(
struct perf_evlist *evlist __maybe_unused)
698 evsel = leader = perf_evlist__first(evlist);
712 evsel = perf_evsel__next(evsel);
725 evsel = leader = perf_evsel__next(evsel);
739 evsel = perf_evsel__next(evsel);
752 evsel = perf_evsel__next(evsel);
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,
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,
927 .str =
"config=10,config1,config2=3,umask=1",
928 .check = test__checkterms_simple,
943 pr_debug(
"failed to parse event '%s', err %d\n",
948 ret = e->
check(evlist);
959 for (i = 0; i <
cnt; i++) {
963 ret1 = test_event(e);
976 terms =
malloc(
sizeof(*terms));
980 INIT_LIST_HEAD(terms);
984 pr_debug(
"failed to parse terms '%s', err %d\n",
989 ret = t->
check(terms);
995 static int test_terms(
struct test__term *terms,
unsigned cnt)
1000 for (i = 0; i <
cnt; i++) {
1012 static int test_pmu(
void)
1023 pr_debug(
"omitting PMU cpu tests\n");
1031 #define TEST_EVENTS(tests) \
1033 ret1 = test_events(tests, ARRAY_SIZE(tests)); \
1043 ret1 = test_terms(test__terms,
ARRAY_SIZE(test__terms));