xref: /openbmc/linux/tools/perf/tests/parse-events.c (revision 4d39c89f0b94bf4a6e1ccf42702e7d80d210a5fd)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2945aea22SJiri Olsa #include "parse-events.h"
3945aea22SJiri Olsa #include "evsel.h"
4945aea22SJiri Olsa #include "evlist.h"
5cd0cfad7SBorislav Petkov #include <api/fs/fs.h>
6c81251e8SJiri Olsa #include "tests.h"
784f5d36fSJiri Olsa #include "debug.h"
8f2a39fe8SArnaldo Carvalho de Melo #include "pmu.h"
976b31a29SArnaldo Carvalho de Melo #include <dirent.h>
10a43783aeSArnaldo Carvalho de Melo #include <errno.h>
117a8ef4c4SArnaldo Carvalho de Melo #include <sys/types.h>
127a8ef4c4SArnaldo Carvalho de Melo #include <sys/stat.h>
137a8ef4c4SArnaldo Carvalho de Melo #include <unistd.h>
14877a7a11SArnaldo Carvalho de Melo #include <linux/kernel.h>
15f0b9abfbSIngo Molnar #include <linux/hw_breakpoint.h>
1620a9ed28SArnaldo Carvalho de Melo #include <api/fs/tracing_path.h>
17945aea22SJiri Olsa 
18945aea22SJiri Olsa #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
19945aea22SJiri Olsa 			     PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
20945aea22SJiri Olsa 
2153fe307dSThomas Richter #if defined(__s390x__)
2253fe307dSThomas Richter /* Return true if kvm module is available and loaded. Test this
23*4d39c89fSIngo Molnar  * and return success when trace point kvm_s390_create_vm
2453fe307dSThomas Richter  * exists. Otherwise this test always fails.
2553fe307dSThomas Richter  */
2653fe307dSThomas Richter static bool kvm_s390_create_vm_valid(void)
2753fe307dSThomas Richter {
2853fe307dSThomas Richter 	char *eventfile;
2953fe307dSThomas Richter 	bool rc = false;
3053fe307dSThomas Richter 
3153fe307dSThomas Richter 	eventfile = get_events_file("kvm-s390");
3253fe307dSThomas Richter 
3353fe307dSThomas Richter 	if (eventfile) {
3453fe307dSThomas Richter 		DIR *mydir = opendir(eventfile);
3553fe307dSThomas Richter 
3653fe307dSThomas Richter 		if (mydir) {
3753fe307dSThomas Richter 			rc = true;
3853fe307dSThomas Richter 			closedir(mydir);
3953fe307dSThomas Richter 		}
4053fe307dSThomas Richter 		put_events_file(eventfile);
4153fe307dSThomas Richter 	}
4253fe307dSThomas Richter 
4353fe307dSThomas Richter 	return rc;
4453fe307dSThomas Richter }
4553fe307dSThomas Richter #endif
4653fe307dSThomas Richter 
4763503dbaSJiri Olsa static int test__checkevent_tracepoint(struct evlist *evlist)
48945aea22SJiri Olsa {
49515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
50945aea22SJiri Olsa 
516484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
528d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
54945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_type",
551fc632ceSJiri Olsa 		PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
57945aea22SJiri Olsa 	return 0;
58945aea22SJiri Olsa }
59945aea22SJiri Olsa 
6063503dbaSJiri Olsa static int test__checkevent_tracepoint_multi(struct evlist *evlist)
61945aea22SJiri Olsa {
6232dcd021SJiri Olsa 	struct evsel *evsel;
63945aea22SJiri Olsa 
646484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
658d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
66945aea22SJiri Olsa 
67e5cadb93SArnaldo Carvalho de Melo 	evlist__for_each_entry(evlist, evsel) {
68945aea22SJiri Olsa 		TEST_ASSERT_VAL("wrong type",
691fc632ceSJiri Olsa 			PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
70945aea22SJiri Olsa 		TEST_ASSERT_VAL("wrong sample_type",
711fc632ceSJiri Olsa 			PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
72945aea22SJiri Olsa 		TEST_ASSERT_VAL("wrong sample_period",
731fc632ceSJiri Olsa 			1 == evsel->core.attr.sample_period);
74945aea22SJiri Olsa 	}
75945aea22SJiri Olsa 	return 0;
76945aea22SJiri Olsa }
77945aea22SJiri Olsa 
7863503dbaSJiri Olsa static int test__checkevent_raw(struct evlist *evlist)
79945aea22SJiri Olsa {
80515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
81945aea22SJiri Olsa 
826484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
85945aea22SJiri Olsa 	return 0;
86945aea22SJiri Olsa }
87945aea22SJiri Olsa 
8863503dbaSJiri Olsa static int test__checkevent_numeric(struct evlist *evlist)
89945aea22SJiri Olsa {
90515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
91945aea22SJiri Olsa 
926484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
931fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
95945aea22SJiri Olsa 	return 0;
96945aea22SJiri Olsa }
97945aea22SJiri Olsa 
9863503dbaSJiri Olsa static int test__checkevent_symbolic_name(struct evlist *evlist)
99945aea22SJiri Olsa {
100515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
101945aea22SJiri Olsa 
1026484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1031fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
104945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
1051fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
106945aea22SJiri Olsa 	return 0;
107945aea22SJiri Olsa }
108945aea22SJiri Olsa 
10963503dbaSJiri Olsa static int test__checkevent_symbolic_name_config(struct evlist *evlist)
110945aea22SJiri Olsa {
111515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
112945aea22SJiri Olsa 
1136484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
115945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
1161fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
117ee4c7588SJiri Olsa 	/*
11878e1bc25SArnaldo Carvalho de Melo 	 * The period value gets configured within evlist__config,
119ee4c7588SJiri Olsa 	 * while this test executes only parse events method.
120ee4c7588SJiri Olsa 	 */
121945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong period",
1221fc632ceSJiri Olsa 			0 == evsel->core.attr.sample_period);
123945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config1",
1241fc632ceSJiri Olsa 			0 == evsel->core.attr.config1);
125945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config2",
1261fc632ceSJiri Olsa 			1 == evsel->core.attr.config2);
127945aea22SJiri Olsa 	return 0;
128945aea22SJiri Olsa }
129945aea22SJiri Olsa 
13063503dbaSJiri Olsa static int test__checkevent_symbolic_alias(struct evlist *evlist)
131945aea22SJiri Olsa {
132515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
133945aea22SJiri Olsa 
1346484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1351fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
136945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
1371fc632ceSJiri Olsa 			PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
138945aea22SJiri Olsa 	return 0;
139945aea22SJiri Olsa }
140945aea22SJiri Olsa 
14163503dbaSJiri Olsa static int test__checkevent_genhw(struct evlist *evlist)
142945aea22SJiri Olsa {
143515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
144945aea22SJiri Olsa 
1456484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
1471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->core.attr.config);
148945aea22SJiri Olsa 	return 0;
149945aea22SJiri Olsa }
150945aea22SJiri Olsa 
15163503dbaSJiri Olsa static int test__checkevent_breakpoint(struct evlist *evlist)
152945aea22SJiri Olsa {
153515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
154945aea22SJiri Olsa 
1556484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
158945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
1591fc632ceSJiri Olsa 					 evsel->core.attr.bp_type);
160945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
1611fc632ceSJiri Olsa 					evsel->core.attr.bp_len);
162945aea22SJiri Olsa 	return 0;
163945aea22SJiri Olsa }
164945aea22SJiri Olsa 
16563503dbaSJiri Olsa static int test__checkevent_breakpoint_x(struct evlist *evlist)
166945aea22SJiri Olsa {
167515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
168945aea22SJiri Olsa 
1696484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
172945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_type",
1731fc632ceSJiri Olsa 			HW_BREAKPOINT_X == evsel->core.attr.bp_type);
1741fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->core.attr.bp_len);
175945aea22SJiri Olsa 	return 0;
176945aea22SJiri Olsa }
177945aea22SJiri Olsa 
17863503dbaSJiri Olsa static int test__checkevent_breakpoint_r(struct evlist *evlist)
179945aea22SJiri Olsa {
180515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
181945aea22SJiri Olsa 
1826484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
183945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type",
1841fc632ceSJiri Olsa 			PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
186945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_type",
1871fc632ceSJiri Olsa 			HW_BREAKPOINT_R == evsel->core.attr.bp_type);
188945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_len",
1891fc632ceSJiri Olsa 			HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
190945aea22SJiri Olsa 	return 0;
191945aea22SJiri Olsa }
192945aea22SJiri Olsa 
19363503dbaSJiri Olsa static int test__checkevent_breakpoint_w(struct evlist *evlist)
194945aea22SJiri Olsa {
195515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
196945aea22SJiri Olsa 
1976484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
198945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type",
1991fc632ceSJiri Olsa 			PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
2001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
201945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_type",
2021fc632ceSJiri Olsa 			HW_BREAKPOINT_W == evsel->core.attr.bp_type);
203945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_len",
2041fc632ceSJiri Olsa 			HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
205945aea22SJiri Olsa 	return 0;
206945aea22SJiri Olsa }
207945aea22SJiri Olsa 
20863503dbaSJiri Olsa static int test__checkevent_breakpoint_rw(struct evlist *evlist)
209945aea22SJiri Olsa {
210515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
211945aea22SJiri Olsa 
2126484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
213945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type",
2141fc632ceSJiri Olsa 			PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
2151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
216945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_type",
2171fc632ceSJiri Olsa 		(HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->core.attr.bp_type);
218945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong bp_len",
2191fc632ceSJiri Olsa 			HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
220945aea22SJiri Olsa 	return 0;
221945aea22SJiri Olsa }
222945aea22SJiri Olsa 
22363503dbaSJiri Olsa static int test__checkevent_tracepoint_modifier(struct evlist *evlist)
224945aea22SJiri Olsa {
225515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
226945aea22SJiri Olsa 
2271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
2281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
2291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
2301fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
231945aea22SJiri Olsa 
232945aea22SJiri Olsa 	return test__checkevent_tracepoint(evlist);
233945aea22SJiri Olsa }
234945aea22SJiri Olsa 
235945aea22SJiri Olsa static int
23663503dbaSJiri Olsa test__checkevent_tracepoint_multi_modifier(struct evlist *evlist)
237945aea22SJiri Olsa {
23832dcd021SJiri Olsa 	struct evsel *evsel;
239945aea22SJiri Olsa 
2406484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
241945aea22SJiri Olsa 
242e5cadb93SArnaldo Carvalho de Melo 	evlist__for_each_entry(evlist, evsel) {
243945aea22SJiri Olsa 		TEST_ASSERT_VAL("wrong exclude_user",
2441fc632ceSJiri Olsa 				!evsel->core.attr.exclude_user);
245945aea22SJiri Olsa 		TEST_ASSERT_VAL("wrong exclude_kernel",
2461fc632ceSJiri Olsa 				evsel->core.attr.exclude_kernel);
2471fc632ceSJiri Olsa 		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
2481fc632ceSJiri Olsa 		TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
249945aea22SJiri Olsa 	}
250945aea22SJiri Olsa 
251945aea22SJiri Olsa 	return test__checkevent_tracepoint_multi(evlist);
252945aea22SJiri Olsa }
253945aea22SJiri Olsa 
25463503dbaSJiri Olsa static int test__checkevent_raw_modifier(struct evlist *evlist)
255945aea22SJiri Olsa {
256515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
257945aea22SJiri Olsa 
2581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
2591fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
2601fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
2611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
262945aea22SJiri Olsa 
263945aea22SJiri Olsa 	return test__checkevent_raw(evlist);
264945aea22SJiri Olsa }
265945aea22SJiri Olsa 
26663503dbaSJiri Olsa static int test__checkevent_numeric_modifier(struct evlist *evlist)
267945aea22SJiri Olsa {
268515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
269945aea22SJiri Olsa 
2701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
2711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
2721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
2731fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
274945aea22SJiri Olsa 
275945aea22SJiri Olsa 	return test__checkevent_numeric(evlist);
276945aea22SJiri Olsa }
277945aea22SJiri Olsa 
27863503dbaSJiri Olsa static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
279945aea22SJiri Olsa {
280515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
281945aea22SJiri Olsa 
2821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
2831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
2841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
2851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
286945aea22SJiri Olsa 
287945aea22SJiri Olsa 	return test__checkevent_symbolic_name(evlist);
288945aea22SJiri Olsa }
289945aea22SJiri Olsa 
29063503dbaSJiri Olsa static int test__checkevent_exclude_host_modifier(struct evlist *evlist)
291945aea22SJiri Olsa {
292515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
293945aea22SJiri Olsa 
2941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
2951fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
296945aea22SJiri Olsa 
297945aea22SJiri Olsa 	return test__checkevent_symbolic_name(evlist);
298945aea22SJiri Olsa }
299945aea22SJiri Olsa 
30063503dbaSJiri Olsa static int test__checkevent_exclude_guest_modifier(struct evlist *evlist)
301945aea22SJiri Olsa {
302515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
303945aea22SJiri Olsa 
3041fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
3051fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
306945aea22SJiri Olsa 
307945aea22SJiri Olsa 	return test__checkevent_symbolic_name(evlist);
308945aea22SJiri Olsa }
309945aea22SJiri Olsa 
31063503dbaSJiri Olsa static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist)
311945aea22SJiri Olsa {
312515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
313945aea22SJiri Olsa 
3141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
3151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
3161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
3171fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
318945aea22SJiri Olsa 
319945aea22SJiri Olsa 	return test__checkevent_symbolic_alias(evlist);
320945aea22SJiri Olsa }
321945aea22SJiri Olsa 
32263503dbaSJiri Olsa static int test__checkevent_genhw_modifier(struct evlist *evlist)
323945aea22SJiri Olsa {
324515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
325945aea22SJiri Olsa 
3261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
3271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
3281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
3291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
330945aea22SJiri Olsa 
331945aea22SJiri Olsa 	return test__checkevent_genhw(evlist);
332945aea22SJiri Olsa }
333945aea22SJiri Olsa 
33463503dbaSJiri Olsa static int test__checkevent_exclude_idle_modifier(struct evlist *evlist)
335a1e12da4SJiri Olsa {
336515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
337a1e12da4SJiri Olsa 
3381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
3391fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
3401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
3411fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
3421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
3431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
3441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
345a1e12da4SJiri Olsa 
346a1e12da4SJiri Olsa 	return test__checkevent_symbolic_name(evlist);
347a1e12da4SJiri Olsa }
348a1e12da4SJiri Olsa 
34963503dbaSJiri Olsa static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist)
350a1e12da4SJiri Olsa {
351515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
352a1e12da4SJiri Olsa 
3531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
3541fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
3551fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
3561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
3571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
3581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
3591fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
360a1e12da4SJiri Olsa 
361a1e12da4SJiri Olsa 	return test__checkevent_symbolic_name(evlist);
362a1e12da4SJiri Olsa }
363a1e12da4SJiri Olsa 
36463503dbaSJiri Olsa static int test__checkevent_breakpoint_modifier(struct evlist *evlist)
365945aea22SJiri Olsa {
366515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
367945aea22SJiri Olsa 
368945aea22SJiri Olsa 
3691fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
3701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
3711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
3721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
373945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong name",
3748ab2e96dSArnaldo Carvalho de Melo 			!strcmp(evsel__name(evsel), "mem:0:u"));
375945aea22SJiri Olsa 
376945aea22SJiri Olsa 	return test__checkevent_breakpoint(evlist);
377945aea22SJiri Olsa }
378945aea22SJiri Olsa 
37963503dbaSJiri Olsa static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist)
380945aea22SJiri Olsa {
381515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
382945aea22SJiri Olsa 
3831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
3841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
3851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
3861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
387945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong name",
3888ab2e96dSArnaldo Carvalho de Melo 			!strcmp(evsel__name(evsel), "mem:0:x:k"));
389945aea22SJiri Olsa 
390945aea22SJiri Olsa 	return test__checkevent_breakpoint_x(evlist);
391945aea22SJiri Olsa }
392945aea22SJiri Olsa 
39363503dbaSJiri Olsa static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist)
394945aea22SJiri Olsa {
395515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
396945aea22SJiri Olsa 
3971fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
3981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
3991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
4001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
401945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong name",
4028ab2e96dSArnaldo Carvalho de Melo 			!strcmp(evsel__name(evsel), "mem:0:r:hp"));
403945aea22SJiri Olsa 
404945aea22SJiri Olsa 	return test__checkevent_breakpoint_r(evlist);
405945aea22SJiri Olsa }
406945aea22SJiri Olsa 
40763503dbaSJiri Olsa static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist)
408945aea22SJiri Olsa {
409515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
410945aea22SJiri Olsa 
4111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
4121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
4131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
4141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
415945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong name",
4168ab2e96dSArnaldo Carvalho de Melo 			!strcmp(evsel__name(evsel), "mem:0:w:up"));
417945aea22SJiri Olsa 
418945aea22SJiri Olsa 	return test__checkevent_breakpoint_w(evlist);
419945aea22SJiri Olsa }
420945aea22SJiri Olsa 
42163503dbaSJiri Olsa static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist)
422945aea22SJiri Olsa {
423515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
424945aea22SJiri Olsa 
4251fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
4261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
4271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
4281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
429945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong name",
4308ab2e96dSArnaldo Carvalho de Melo 			!strcmp(evsel__name(evsel), "mem:0:rw:kp"));
431945aea22SJiri Olsa 
432945aea22SJiri Olsa 	return test__checkevent_breakpoint_rw(evlist);
433945aea22SJiri Olsa }
434945aea22SJiri Olsa 
43563503dbaSJiri Olsa static int test__checkevent_pmu(struct evlist *evlist)
436945aea22SJiri Olsa {
437945aea22SJiri Olsa 
438515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
439945aea22SJiri Olsa 
4406484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
4411fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
4421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config",    10 == evsel->core.attr.config);
4431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config1",    1 == evsel->core.attr.config1);
4441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config2",    3 == evsel->core.attr.config2);
445ee4c7588SJiri Olsa 	/*
44678e1bc25SArnaldo Carvalho de Melo 	 * The period value gets configured within evlist__config,
447ee4c7588SJiri Olsa 	 * while this test executes only parse events method.
448ee4c7588SJiri Olsa 	 */
4491fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong period",     0 == evsel->core.attr.sample_period);
450945aea22SJiri Olsa 
451945aea22SJiri Olsa 	return 0;
452945aea22SJiri Olsa }
453945aea22SJiri Olsa 
45463503dbaSJiri Olsa static int test__checkevent_list(struct evlist *evlist)
455945aea22SJiri Olsa {
456515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
457945aea22SJiri Olsa 
4586484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
459945aea22SJiri Olsa 
460945aea22SJiri Olsa 	/* r1 */
4611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
4621fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
4631fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config1", 0 == evsel->core.attr.config1);
4641fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
4651fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
4661fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
4671fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
4681fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
469945aea22SJiri Olsa 
47043f322b4SRiku Voipio 	/* syscalls:sys_enter_openat:k */
471e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
4721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
473945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_type",
4741fc632ceSJiri Olsa 		PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
4751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
4761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
4771fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
4781fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
4791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
480945aea22SJiri Olsa 
481945aea22SJiri Olsa 	/* 1:1:hp */
482e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
4831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
4841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
4851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
4861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
4871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
4881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
489945aea22SJiri Olsa 
490945aea22SJiri Olsa 	return 0;
491945aea22SJiri Olsa }
492945aea22SJiri Olsa 
49363503dbaSJiri Olsa static int test__checkevent_pmu_name(struct evlist *evlist)
494945aea22SJiri Olsa {
495515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
496945aea22SJiri Olsa 
497945aea22SJiri Olsa 	/* cpu/config=1,name=krava/u */
4986484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
4991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
5001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config",  1 == evsel->core.attr.config);
5018ab2e96dSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "krava"));
502945aea22SJiri Olsa 
503945aea22SJiri Olsa 	/* cpu/config=2/u" */
504e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
5056484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
5061fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
5071fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config",  2 == evsel->core.attr.config);
508945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong name",
5098ab2e96dSArnaldo Carvalho de Melo 			!strcmp(evsel__name(evsel), "cpu/config=2/u"));
510945aea22SJiri Olsa 
511945aea22SJiri Olsa 	return 0;
512945aea22SJiri Olsa }
513945aea22SJiri Olsa 
51463503dbaSJiri Olsa static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
51571ef150eSKan Liang {
516515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
51771ef150eSKan Liang 
51871ef150eSKan Liang 	/* cpu/config=1,call-graph=fp,time,period=100000/ */
5196484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
5201fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
5211fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config",  1 == evsel->core.attr.config);
52271ef150eSKan Liang 	/*
52378e1bc25SArnaldo Carvalho de Melo 	 * The period, time and callgraph value gets configured within evlist__config,
52471ef150eSKan Liang 	 * while this test executes only parse events method.
52571ef150eSKan Liang 	 */
5261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong period",     0 == evsel->core.attr.sample_period);
52727de9b2bSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong callgraph",  !evsel__has_callchain(evsel));
5281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong time",  !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
52971ef150eSKan Liang 
53071ef150eSKan Liang 	/* cpu/config=2,call-graph=no,time=0,period=2000/ */
531e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
5321fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
5331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config",  2 == evsel->core.attr.config);
53471ef150eSKan Liang 	/*
53578e1bc25SArnaldo Carvalho de Melo 	 * The period, time and callgraph value gets configured within evlist__config,
53671ef150eSKan Liang 	 * while this test executes only parse events method.
53771ef150eSKan Liang 	 */
5381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong period",     0 == evsel->core.attr.sample_period);
53927de9b2bSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong callgraph",  !evsel__has_callchain(evsel));
5401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong time",  !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
54171ef150eSKan Liang 
54271ef150eSKan Liang 	return 0;
54371ef150eSKan Liang }
54471ef150eSKan Liang 
54563503dbaSJiri Olsa static int test__checkevent_pmu_events(struct evlist *evlist)
546945aea22SJiri Olsa {
547515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
548945aea22SJiri Olsa 
5496484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
5501fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
551945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user",
5521fc632ceSJiri Olsa 			!evsel->core.attr.exclude_user);
553945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel",
5541fc632ceSJiri Olsa 			evsel->core.attr.exclude_kernel);
5551fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
5561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
5571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
5580997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
559945aea22SJiri Olsa 
560945aea22SJiri Olsa 	return 0;
561945aea22SJiri Olsa }
562945aea22SJiri Olsa 
563ffe59788SKan Liang 
56463503dbaSJiri Olsa static int test__checkevent_pmu_events_mix(struct evlist *evlist)
565ffe59788SKan Liang {
566515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
567ffe59788SKan Liang 
568ffe59788SKan Liang 	/* pmu-event:u */
5696484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
570ffe59788SKan Liang 	TEST_ASSERT_VAL("wrong exclude_user",
5711fc632ceSJiri Olsa 			!evsel->core.attr.exclude_user);
572ffe59788SKan Liang 	TEST_ASSERT_VAL("wrong exclude_kernel",
5731fc632ceSJiri Olsa 			evsel->core.attr.exclude_kernel);
5741fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
5751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
5761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
5770997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
578ffe59788SKan Liang 
579ffe59788SKan Liang 	/* cpu/pmu-event/u*/
580e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
5816484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
5821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
583ffe59788SKan Liang 	TEST_ASSERT_VAL("wrong exclude_user",
5841fc632ceSJiri Olsa 			!evsel->core.attr.exclude_user);
585ffe59788SKan Liang 	TEST_ASSERT_VAL("wrong exclude_kernel",
5861fc632ceSJiri Olsa 			evsel->core.attr.exclude_kernel);
5871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
5881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
5891fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
5900997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned);
591ffe59788SKan Liang 
592ffe59788SKan Liang 	return 0;
593ffe59788SKan Liang }
594ffe59788SKan Liang 
595945aea22SJiri Olsa static int test__checkterms_simple(struct list_head *terms)
596945aea22SJiri Olsa {
5976cee6cd3SArnaldo Carvalho de Melo 	struct parse_events_term *term;
598945aea22SJiri Olsa 
599945aea22SJiri Olsa 	/* config=10 */
6006cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(terms->next, struct parse_events_term, list);
601945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
602945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
603945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
604945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
605945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 10);
606945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
607945aea22SJiri Olsa 
608945aea22SJiri Olsa 	/* config1 */
6096cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(term->list.next, struct parse_events_term, list);
610945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
611945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
612945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
613945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
614945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 1);
615945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
616945aea22SJiri Olsa 
617945aea22SJiri Olsa 	/* config2=3 */
6186cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(term->list.next, struct parse_events_term, list);
619945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
620945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
621945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
622945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
623945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 3);
624945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
625945aea22SJiri Olsa 
626945aea22SJiri Olsa 	/* umask=1*/
6276cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(term->list.next, struct parse_events_term, list);
628945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
629945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
630945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
631945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
632945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 1);
633945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
634945aea22SJiri Olsa 
6354929e95aSJiri Olsa 	/*
6364929e95aSJiri Olsa 	 * read
6374929e95aSJiri Olsa 	 *
6384929e95aSJiri Olsa 	 * The perf_pmu__test_parse_init injects 'read' term into
6394929e95aSJiri Olsa 	 * perf_pmu_events_list, so 'read' is evaluated as read term
6404929e95aSJiri Olsa 	 * and not as raw event with 'ead' hex value.
6414929e95aSJiri Olsa 	 */
6424929e95aSJiri Olsa 	term = list_entry(term->list.next, struct parse_events_term, list);
6434929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
6444929e95aSJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
6454929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
6464929e95aSJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
6474929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 1);
6484929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "read"));
6494929e95aSJiri Olsa 
6504929e95aSJiri Olsa 	/*
6514929e95aSJiri Olsa 	 * r0xead
6524929e95aSJiri Olsa 	 *
6534929e95aSJiri Olsa 	 * To be still able to pass 'ead' value with 'r' syntax,
6544929e95aSJiri Olsa 	 * we added support to parse 'r0xHEX' event.
6554929e95aSJiri Olsa 	 */
6564929e95aSJiri Olsa 	term = list_entry(term->list.next, struct parse_events_term, list);
6574929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
6584929e95aSJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
6594929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
6604929e95aSJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
6614929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 0xead);
6624929e95aSJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
663945aea22SJiri Olsa 	return 0;
664945aea22SJiri Olsa }
665945aea22SJiri Olsa 
66663503dbaSJiri Olsa static int test__group1(struct evlist *evlist)
667945aea22SJiri Olsa {
66832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
669945aea22SJiri Olsa 
6706484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
6718d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
672945aea22SJiri Olsa 
673945aea22SJiri Olsa 	/* instructions:k */
674515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
6751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
676945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
6771fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
6781fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
6791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
6801fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
6811fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
6821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
6831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
684c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
6855643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
6862bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
687a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
688945aea22SJiri Olsa 
689945aea22SJiri Olsa 	/* cycles:upp */
690e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
6911fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
692945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
6931fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
6941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
6951fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
6961fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
697945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
6981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
6991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
701945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
7022bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
703a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
704945aea22SJiri Olsa 
705945aea22SJiri Olsa 	return 0;
706945aea22SJiri Olsa }
707945aea22SJiri Olsa 
70863503dbaSJiri Olsa static int test__group2(struct evlist *evlist)
709945aea22SJiri Olsa {
71032dcd021SJiri Olsa 	struct evsel *evsel, *leader;
711945aea22SJiri Olsa 
7126484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
7138d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
714945aea22SJiri Olsa 
715945aea22SJiri Olsa 	/* faults + :ku modifier */
716515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
7171fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
718945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7191fc632ceSJiri Olsa 			PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
7201fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
7211fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7221fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
723943b69acSJin Yao 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7241fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7251fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
726c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
7275643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
7282bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
729a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
730945aea22SJiri Olsa 
731945aea22SJiri Olsa 	/* cache-references + :u modifier */
732e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
734945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7351fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_REFERENCES == evsel->core.attr.config);
7361fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
7371fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
7381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
7391fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7411fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
742945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
7432bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
744a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
745945aea22SJiri Olsa 
746945aea22SJiri Olsa 	/* cycles:k */
747e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7481fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
749945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7501fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
7511fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
7521fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
7541fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
7551fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
757c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
758a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
759945aea22SJiri Olsa 
760945aea22SJiri Olsa 	return 0;
761945aea22SJiri Olsa }
762945aea22SJiri Olsa 
76363503dbaSJiri Olsa static int test__group3(struct evlist *evlist __maybe_unused)
764945aea22SJiri Olsa {
76532dcd021SJiri Olsa 	struct evsel *evsel, *leader;
766945aea22SJiri Olsa 
7676484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
7688d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
769945aea22SJiri Olsa 
77043f322b4SRiku Voipio 	/* group1 syscalls:sys_enter_openat:H */
771515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
7721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
773945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_type",
7741fc632ceSJiri Olsa 		PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
7751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
7761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
7771fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7781fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
7791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7801fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7811fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
782c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
783945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name",
784945aea22SJiri Olsa 		!strcmp(leader->group_name, "group1"));
7855643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
7862bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
787a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
788945aea22SJiri Olsa 
789945aea22SJiri Olsa 	/* group1 cycles:kppp */
790e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7911fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
792945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7931fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
7941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
7951fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7961fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
797945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
7981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 3);
801945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
802945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
8032bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
804a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
805945aea22SJiri Olsa 
806945aea22SJiri Olsa 	/* group2 cycles + G modifier */
807e470daeaSArnaldo Carvalho de Melo 	evsel = leader = evsel__next(evsel);
8081fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
809945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8101fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
8111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
8131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
8141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
8151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
8161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
817c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
818945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name",
819945aea22SJiri Olsa 		!strcmp(leader->group_name, "group2"));
8205643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
8212bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
822a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
823945aea22SJiri Olsa 
824945aea22SJiri Olsa 	/* group2 1:3 + G modifier */
825e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
8261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
8271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 3 == evsel->core.attr.config);
8281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
8301fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
8311fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
8321fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
8331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
834945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
8352bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
836a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
837945aea22SJiri Olsa 
838945aea22SJiri Olsa 	/* instructions:u */
839e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
8401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
841945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8421fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
8431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
8451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
846943b69acSJin Yao 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
8471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8481fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
849c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
850a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
851945aea22SJiri Olsa 
852945aea22SJiri Olsa 	return 0;
853945aea22SJiri Olsa }
854945aea22SJiri Olsa 
85563503dbaSJiri Olsa static int test__group4(struct evlist *evlist __maybe_unused)
856945aea22SJiri Olsa {
85732dcd021SJiri Olsa 	struct evsel *evsel, *leader;
858945aea22SJiri Olsa 
8596484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
8608d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
861945aea22SJiri Olsa 
862945aea22SJiri Olsa 	/* cycles:u + p */
863515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
8641fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
865945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8661fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
8671fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8681fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
8691fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
870945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
8711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
8721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8731fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 1);
874945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
875c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
8765643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
8772bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
878a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
879945aea22SJiri Olsa 
880945aea22SJiri Olsa 	/* instructions:kp + p */
881e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
8821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
883945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8841fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
8851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
8861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
8871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
888945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
8891fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
8901fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8911fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
892945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
8932bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
894a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
895945aea22SJiri Olsa 
896945aea22SJiri Olsa 	return 0;
897945aea22SJiri Olsa }
898945aea22SJiri Olsa 
89963503dbaSJiri Olsa static int test__group5(struct evlist *evlist __maybe_unused)
900945aea22SJiri Olsa {
90132dcd021SJiri Olsa 	struct evsel *evsel, *leader;
902945aea22SJiri Olsa 
9036484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
9048d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
905945aea22SJiri Olsa 
906945aea22SJiri Olsa 	/* cycles + G */
907515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
9081fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
909945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9101fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
917945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
918c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
9195643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
9202bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
921a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
922945aea22SJiri Olsa 
923945aea22SJiri Olsa 	/* instructions + G */
924e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
9251fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
926945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9271fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
9281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9301fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9311fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9321fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
934945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
9352bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
936a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
937945aea22SJiri Olsa 
938945aea22SJiri Olsa 	/* cycles:G */
939e470daeaSArnaldo Carvalho de Melo 	evsel = leader = evsel__next(evsel);
9401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
941945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9421fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9481fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
949945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
950c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
9515643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
9522bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
953a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
954945aea22SJiri Olsa 
955945aea22SJiri Olsa 	/* instructions:G */
956e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
9571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
958945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9591fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
9601fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9621fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9631fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9641fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9651fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
966945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
9672bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
968945aea22SJiri Olsa 
969945aea22SJiri Olsa 	/* cycles */
970e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
9711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
972945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9731fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9741fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9771fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
9781fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
9791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
980c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
981945aea22SJiri Olsa 
982945aea22SJiri Olsa 	return 0;
983945aea22SJiri Olsa }
984945aea22SJiri Olsa 
98563503dbaSJiri Olsa static int test__group_gh1(struct evlist *evlist)
9865a30a99fSJiri Olsa {
98732dcd021SJiri Olsa 	struct evsel *evsel, *leader;
9885a30a99fSJiri Olsa 
9896484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
9905a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
9915a30a99fSJiri Olsa 
9925a30a99fSJiri Olsa 	/* cycles + :H group modifier */
993515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
9941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
9955a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9961fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9971fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
10001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
10011fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
10021fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10035a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1004c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
10055643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
10062bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
10075a30a99fSJiri Olsa 
10085a30a99fSJiri Olsa 	/* cache-misses:G + :H group modifier */
1009e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
10101fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10115a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10121fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
10131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
10151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
10161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10171fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
10181fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10195a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
10202bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
10215a30a99fSJiri Olsa 
10225a30a99fSJiri Olsa 	return 0;
10235a30a99fSJiri Olsa }
10245a30a99fSJiri Olsa 
102563503dbaSJiri Olsa static int test__group_gh2(struct evlist *evlist)
10265a30a99fSJiri Olsa {
102732dcd021SJiri Olsa 	struct evsel *evsel, *leader;
10285a30a99fSJiri Olsa 
10296484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
10305a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
10315a30a99fSJiri Olsa 
10325a30a99fSJiri Olsa 	/* cycles + :G group modifier */
1033515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
10341fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10355a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10361fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
10371fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
10391fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
10401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10411fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
10421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10435a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1044c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
10455643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
10462bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
10475a30a99fSJiri Olsa 
10485a30a99fSJiri Olsa 	/* cache-misses:H + :G group modifier */
1049e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
10501fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10515a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10521fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
10531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10541fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
10551fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
10561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
10581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10595a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
10602bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
10615a30a99fSJiri Olsa 
10625a30a99fSJiri Olsa 	return 0;
10635a30a99fSJiri Olsa }
10645a30a99fSJiri Olsa 
106563503dbaSJiri Olsa static int test__group_gh3(struct evlist *evlist)
10665a30a99fSJiri Olsa {
106732dcd021SJiri Olsa 	struct evsel *evsel, *leader;
10685a30a99fSJiri Olsa 
10696484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
10705a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
10715a30a99fSJiri Olsa 
10725a30a99fSJiri Olsa 	/* cycles:G + :u group modifier */
1073515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
10741fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10755a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10761fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
10771fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10781fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
10791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
10801fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10811fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
10821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10835a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1084c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
10855643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
10862bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
10875a30a99fSJiri Olsa 
10885a30a99fSJiri Olsa 	/* cache-misses:H + :u group modifier */
1089e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
10901fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10915a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10921fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
10931fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
10951fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
10961fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
10971fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
10981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10995a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
11002bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
11015a30a99fSJiri Olsa 
11025a30a99fSJiri Olsa 	return 0;
11035a30a99fSJiri Olsa }
11045a30a99fSJiri Olsa 
110563503dbaSJiri Olsa static int test__group_gh4(struct evlist *evlist)
11065a30a99fSJiri Olsa {
110732dcd021SJiri Olsa 	struct evsel *evsel, *leader;
11085a30a99fSJiri Olsa 
11096484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
11105a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
11115a30a99fSJiri Olsa 
11125a30a99fSJiri Olsa 	/* cycles:G + :uG group modifier */
1113515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
11141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
11155a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11161fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
11171fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11181fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
11191fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
11201fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
11211fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
11221fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
11235a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1124c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
11255643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
11262bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
11275a30a99fSJiri Olsa 
11285a30a99fSJiri Olsa 	/* cache-misses:H + :uG group modifier */
1129e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
11301fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
11315a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11321fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
11331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11341fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
11351fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
11361fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
11371fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
11395a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
11402bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
11415a30a99fSJiri Olsa 
11425a30a99fSJiri Olsa 	return 0;
11435a30a99fSJiri Olsa }
11445a30a99fSJiri Olsa 
114563503dbaSJiri Olsa static int test__leader_sample1(struct evlist *evlist)
1146a9f93f97SJiri Olsa {
114732dcd021SJiri Olsa 	struct evsel *evsel, *leader;
1148a9f93f97SJiri Olsa 
11496484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1150a9f93f97SJiri Olsa 
1151a9f93f97SJiri Olsa 	/* cycles - sampling group leader */
1152515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
11531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1154a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11551fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
11561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
11581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
11591fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11601fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1162a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1163a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1164a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1165a9f93f97SJiri Olsa 
1166a9f93f97SJiri Olsa 	/* cache-misses - not sampling */
1167e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
11681fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1169a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11701fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
11711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
11731fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
11741fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1177a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1178a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1179a9f93f97SJiri Olsa 
1180a9f93f97SJiri Olsa 	/* branch-misses - not sampling */
1181e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
11821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1183a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11841fc632ceSJiri Olsa 			PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
11851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
11871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
11881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11891fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11901fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1191a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1192a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1193a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1194a9f93f97SJiri Olsa 
1195a9f93f97SJiri Olsa 	return 0;
1196a9f93f97SJiri Olsa }
1197a9f93f97SJiri Olsa 
119863503dbaSJiri Olsa static int test__leader_sample2(struct evlist *evlist __maybe_unused)
1199a9f93f97SJiri Olsa {
120032dcd021SJiri Olsa 	struct evsel *evsel, *leader;
1201a9f93f97SJiri Olsa 
12026484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1203a9f93f97SJiri Olsa 
1204a9f93f97SJiri Olsa 	/* instructions - sampling group leader */
1205515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
12061fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1207a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
12081fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
12091fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
12101fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
12111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
12121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
12131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
12141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1215a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1216a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1217a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1218a9f93f97SJiri Olsa 
1219a9f93f97SJiri Olsa 	/* branch-misses - not sampling */
1220e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
12211fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1222a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
12231fc632ceSJiri Olsa 			PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
12241fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
12251fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
12261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
12271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
12281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
12291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1230a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1231a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1232a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1233a9f93f97SJiri Olsa 
1234a9f93f97SJiri Olsa 	return 0;
1235a9f93f97SJiri Olsa }
1236a9f93f97SJiri Olsa 
123763503dbaSJiri Olsa static int test__checkevent_pinned_modifier(struct evlist *evlist)
1238c9ee780fSMichael Ellerman {
1239515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1240c9ee780fSMichael Ellerman 
12411fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
12421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
12431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
12441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
12451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
1246c9ee780fSMichael Ellerman 
1247c9ee780fSMichael Ellerman 	return test__checkevent_symbolic_name(evlist);
1248c9ee780fSMichael Ellerman }
1249c9ee780fSMichael Ellerman 
125063503dbaSJiri Olsa static int test__pinned_group(struct evlist *evlist)
1251c9ee780fSMichael Ellerman {
125232dcd021SJiri Olsa 	struct evsel *evsel, *leader;
1253c9ee780fSMichael Ellerman 
12546484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1255c9ee780fSMichael Ellerman 
1256c9ee780fSMichael Ellerman 	/* cycles - group leader */
1257515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
12581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1259c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong config",
12601fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1261c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1262c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
12631fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
1264c9ee780fSMichael Ellerman 
1265c9ee780fSMichael Ellerman 	/* cache-misses - can not be pinned, but will go on with the leader */
1266e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
12671fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1268c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong config",
12691fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
12701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
1271c9ee780fSMichael Ellerman 
1272c9ee780fSMichael Ellerman 	/* branch-misses - ditto */
1273e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
1274c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong config",
12751fc632ceSJiri Olsa 			PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
12761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
1277c9ee780fSMichael Ellerman 
1278c9ee780fSMichael Ellerman 	return 0;
1279c9ee780fSMichael Ellerman }
1280c9ee780fSMichael Ellerman 
12810997a266SAndi Kleen static int test__checkevent_exclusive_modifier(struct evlist *evlist)
12820997a266SAndi Kleen {
12830997a266SAndi Kleen 	struct evsel *evsel = evlist__first(evlist);
12840997a266SAndi Kleen 
12850997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
12860997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
12870997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
12880997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
12890997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive);
12900997a266SAndi Kleen 
12910997a266SAndi Kleen 	return test__checkevent_symbolic_name(evlist);
12920997a266SAndi Kleen }
12930997a266SAndi Kleen 
12940997a266SAndi Kleen static int test__exclusive_group(struct evlist *evlist)
12950997a266SAndi Kleen {
12960997a266SAndi Kleen 	struct evsel *evsel, *leader;
12970997a266SAndi Kleen 
12980997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
12990997a266SAndi Kleen 
13000997a266SAndi Kleen 	/* cycles - group leader */
13010997a266SAndi Kleen 	evsel = leader = evlist__first(evlist);
13020997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
13030997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong config",
13040997a266SAndi Kleen 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
13050997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
13060997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
13070997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive);
13080997a266SAndi Kleen 
13090997a266SAndi Kleen 	/* cache-misses - can not be pinned, but will go on with the leader */
13100997a266SAndi Kleen 	evsel = evsel__next(evsel);
13110997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
13120997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong config",
13130997a266SAndi Kleen 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
13140997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
13150997a266SAndi Kleen 
13160997a266SAndi Kleen 	/* branch-misses - ditto */
13170997a266SAndi Kleen 	evsel = evsel__next(evsel);
13180997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong config",
13190997a266SAndi Kleen 			PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
13200997a266SAndi Kleen 	TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
13210997a266SAndi Kleen 
13220997a266SAndi Kleen 	return 0;
13230997a266SAndi Kleen }
132463503dbaSJiri Olsa static int test__checkevent_breakpoint_len(struct evlist *evlist)
1325ec32398cSJacob Shin {
1326515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1327ec32398cSJacob Shin 
13286484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
13291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
13301fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
1331ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
13321fc632ceSJiri Olsa 					 evsel->core.attr.bp_type);
1333ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
13341fc632ceSJiri Olsa 					evsel->core.attr.bp_len);
1335ec32398cSJacob Shin 
1336ec32398cSJacob Shin 	return 0;
1337ec32398cSJacob Shin }
1338ec32398cSJacob Shin 
133963503dbaSJiri Olsa static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
1340ec32398cSJacob Shin {
1341515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1342ec32398cSJacob Shin 
13436484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
13441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
13451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
1346ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
13471fc632ceSJiri Olsa 					 evsel->core.attr.bp_type);
1348ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
13491fc632ceSJiri Olsa 					evsel->core.attr.bp_len);
1350ec32398cSJacob Shin 
1351ec32398cSJacob Shin 	return 0;
1352ec32398cSJacob Shin }
1353ec32398cSJacob Shin 
1354ec32398cSJacob Shin static int
135563503dbaSJiri Olsa test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
1356ec32398cSJacob Shin {
1357515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1358ec32398cSJacob Shin 
13591fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
13601fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
13611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
13621fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1363ec32398cSJacob Shin 
1364ec32398cSJacob Shin 	return test__checkevent_breakpoint_rw(evlist);
1365ec32398cSJacob Shin }
1366ec32398cSJacob Shin 
136763503dbaSJiri Olsa static int test__checkevent_precise_max_modifier(struct evlist *evlist)
1368ddd83c97SJiri Olsa {
1369515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1370ddd83c97SJiri Olsa 
13716484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
13721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
1373ddd83c97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
13741fc632ceSJiri Olsa 			PERF_COUNT_SW_TASK_CLOCK == evsel->core.attr.config);
1375ddd83c97SJiri Olsa 	return 0;
1376ddd83c97SJiri Olsa }
1377ddd83c97SJiri Olsa 
137863503dbaSJiri Olsa static int test__checkevent_config_symbol(struct evlist *evlist)
137910bf358aSWang Nan {
1380515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
138110bf358aSWang Nan 
138210bf358aSWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
138310bf358aSWang Nan 	return 0;
138410bf358aSWang Nan }
138510bf358aSWang Nan 
138663503dbaSJiri Olsa static int test__checkevent_config_raw(struct evlist *evlist)
138710bf358aSWang Nan {
1388515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
138910bf358aSWang Nan 
139010bf358aSWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
139110bf358aSWang Nan 	return 0;
139210bf358aSWang Nan }
139310bf358aSWang Nan 
139463503dbaSJiri Olsa static int test__checkevent_config_num(struct evlist *evlist)
139510bf358aSWang Nan {
1396515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
139710bf358aSWang Nan 
139810bf358aSWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
139910bf358aSWang Nan 	return 0;
140010bf358aSWang Nan }
140110bf358aSWang Nan 
140263503dbaSJiri Olsa static int test__checkevent_config_cache(struct evlist *evlist)
140343d0b978SWang Nan {
1404515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
140543d0b978SWang Nan 
140643d0b978SWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
140743d0b978SWang Nan 	return 0;
140843d0b978SWang Nan }
140910bf358aSWang Nan 
141016ddcfbfSJiri Olsa static bool test__intel_pt_valid(void)
141116ddcfbfSJiri Olsa {
141216ddcfbfSJiri Olsa 	return !!perf_pmu__find("intel_pt");
141316ddcfbfSJiri Olsa }
141416ddcfbfSJiri Olsa 
141563503dbaSJiri Olsa static int test__intel_pt(struct evlist *evlist)
1416b3f58c8dSArnaldo Carvalho de Melo {
1417515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1418b3f58c8dSArnaldo Carvalho de Melo 
1419b3f58c8dSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0);
1420b3f58c8dSArnaldo Carvalho de Melo 	return 0;
1421b3f58c8dSArnaldo Carvalho de Melo }
1422b3f58c8dSArnaldo Carvalho de Melo 
142363503dbaSJiri Olsa static int test__checkevent_complex_name(struct evlist *evlist)
142406dc5bf2SAlexey Budankov {
1425515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
142606dc5bf2SAlexey Budankov 
142706dc5bf2SAlexey Budankov 	TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0);
142806dc5bf2SAlexey Budankov 	return 0;
142906dc5bf2SAlexey Budankov }
143006dc5bf2SAlexey Budankov 
14313a6c51e4SJiri Olsa static int test__checkevent_raw_pmu(struct evlist *evlist)
14323a6c51e4SJiri Olsa {
14333a6c51e4SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
14343a6c51e4SJiri Olsa 
14353a6c51e4SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
14363a6c51e4SJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
14373a6c51e4SJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
14383a6c51e4SJiri Olsa 	return 0;
14393a6c51e4SJiri Olsa }
14403a6c51e4SJiri Olsa 
144163503dbaSJiri Olsa static int test__sym_event_slash(struct evlist *evlist)
1442714a92d8SJiri Olsa {
1443515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1444714a92d8SJiri Olsa 
14451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
14461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
14471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1448714a92d8SJiri Olsa 	return 0;
1449714a92d8SJiri Olsa }
1450714a92d8SJiri Olsa 
145163503dbaSJiri Olsa static int test__sym_event_dc(struct evlist *evlist)
1452714a92d8SJiri Olsa {
1453515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1454714a92d8SJiri Olsa 
14551fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
14561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
14571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
1458714a92d8SJiri Olsa 	return 0;
1459714a92d8SJiri Olsa }
1460714a92d8SJiri Olsa 
146182ce75d9SJiri Olsa static int count_tracepoints(void)
146282ce75d9SJiri Olsa {
146382ce75d9SJiri Olsa 	struct dirent *events_ent;
146482ce75d9SJiri Olsa 	DIR *events_dir;
146582ce75d9SJiri Olsa 	int cnt = 0;
146682ce75d9SJiri Olsa 
14677014e0e3SArnaldo Carvalho de Melo 	events_dir = tracing_events__opendir();
146882ce75d9SJiri Olsa 
146982ce75d9SJiri Olsa 	TEST_ASSERT_VAL("Can't open events dir", events_dir);
147082ce75d9SJiri Olsa 
147182ce75d9SJiri Olsa 	while ((events_ent = readdir(events_dir))) {
147225a7d914SArnaldo Carvalho de Melo 		char *sys_path;
147382ce75d9SJiri Olsa 		struct dirent *sys_ent;
147482ce75d9SJiri Olsa 		DIR *sys_dir;
147582ce75d9SJiri Olsa 
147682ce75d9SJiri Olsa 		if (!strcmp(events_ent->d_name, ".")
147782ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "..")
147882ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "enable")
147982ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "header_event")
148082ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "header_page"))
148182ce75d9SJiri Olsa 			continue;
148282ce75d9SJiri Olsa 
148325a7d914SArnaldo Carvalho de Melo 		sys_path = get_events_file(events_ent->d_name);
148425a7d914SArnaldo Carvalho de Melo 		TEST_ASSERT_VAL("Can't get sys path", sys_path);
148582ce75d9SJiri Olsa 
148682ce75d9SJiri Olsa 		sys_dir = opendir(sys_path);
148782ce75d9SJiri Olsa 		TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
148882ce75d9SJiri Olsa 
148982ce75d9SJiri Olsa 		while ((sys_ent = readdir(sys_dir))) {
149082ce75d9SJiri Olsa 			if (!strcmp(sys_ent->d_name, ".")
149182ce75d9SJiri Olsa 			    || !strcmp(sys_ent->d_name, "..")
149282ce75d9SJiri Olsa 			    || !strcmp(sys_ent->d_name, "enable")
149382ce75d9SJiri Olsa 			    || !strcmp(sys_ent->d_name, "filter"))
149482ce75d9SJiri Olsa 				continue;
149582ce75d9SJiri Olsa 
149682ce75d9SJiri Olsa 			cnt++;
149782ce75d9SJiri Olsa 		}
149882ce75d9SJiri Olsa 
149982ce75d9SJiri Olsa 		closedir(sys_dir);
150025a7d914SArnaldo Carvalho de Melo 		put_events_file(sys_path);
150182ce75d9SJiri Olsa 	}
150282ce75d9SJiri Olsa 
150382ce75d9SJiri Olsa 	closedir(events_dir);
150482ce75d9SJiri Olsa 	return cnt;
150582ce75d9SJiri Olsa }
150682ce75d9SJiri Olsa 
150763503dbaSJiri Olsa static int test__all_tracepoints(struct evlist *evlist)
150882ce75d9SJiri Olsa {
150982ce75d9SJiri Olsa 	TEST_ASSERT_VAL("wrong events count",
15106484d2f9SJiri Olsa 			count_tracepoints() == evlist->core.nr_entries);
151182ce75d9SJiri Olsa 
151282ce75d9SJiri Olsa 	return test__checkevent_tracepoint_multi(evlist);
151382ce75d9SJiri Olsa }
151482ce75d9SJiri Olsa 
151523b6339bSArnaldo Carvalho de Melo struct evlist_test {
1516945aea22SJiri Olsa 	const char *name;
1517945aea22SJiri Olsa 	__u32 type;
1518615b8f99SAlexander Yarygin 	const int id;
151916ddcfbfSJiri Olsa 	bool (*valid)(void);
152063503dbaSJiri Olsa 	int (*check)(struct evlist *evlist);
1521945aea22SJiri Olsa };
1522945aea22SJiri Olsa 
152323b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events[] = {
1524615b8f99SAlexander Yarygin 	{
152543f322b4SRiku Voipio 		.name  = "syscalls:sys_enter_openat",
1526945aea22SJiri Olsa 		.check = test__checkevent_tracepoint,
1527615b8f99SAlexander Yarygin 		.id    = 0,
1528945aea22SJiri Olsa 	},
1529615b8f99SAlexander Yarygin 	{
1530945aea22SJiri Olsa 		.name  = "syscalls:*",
1531945aea22SJiri Olsa 		.check = test__checkevent_tracepoint_multi,
1532615b8f99SAlexander Yarygin 		.id    = 1,
1533945aea22SJiri Olsa 	},
1534615b8f99SAlexander Yarygin 	{
1535945aea22SJiri Olsa 		.name  = "r1a",
1536945aea22SJiri Olsa 		.check = test__checkevent_raw,
1537615b8f99SAlexander Yarygin 		.id    = 2,
1538945aea22SJiri Olsa 	},
1539615b8f99SAlexander Yarygin 	{
1540945aea22SJiri Olsa 		.name  = "1:1",
1541945aea22SJiri Olsa 		.check = test__checkevent_numeric,
1542615b8f99SAlexander Yarygin 		.id    = 3,
1543945aea22SJiri Olsa 	},
1544615b8f99SAlexander Yarygin 	{
1545945aea22SJiri Olsa 		.name  = "instructions",
1546945aea22SJiri Olsa 		.check = test__checkevent_symbolic_name,
1547615b8f99SAlexander Yarygin 		.id    = 4,
1548945aea22SJiri Olsa 	},
1549615b8f99SAlexander Yarygin 	{
1550945aea22SJiri Olsa 		.name  = "cycles/period=100000,config2/",
1551945aea22SJiri Olsa 		.check = test__checkevent_symbolic_name_config,
1552615b8f99SAlexander Yarygin 		.id    = 5,
1553945aea22SJiri Olsa 	},
1554615b8f99SAlexander Yarygin 	{
1555945aea22SJiri Olsa 		.name  = "faults",
1556945aea22SJiri Olsa 		.check = test__checkevent_symbolic_alias,
1557615b8f99SAlexander Yarygin 		.id    = 6,
1558945aea22SJiri Olsa 	},
1559615b8f99SAlexander Yarygin 	{
1560945aea22SJiri Olsa 		.name  = "L1-dcache-load-miss",
1561945aea22SJiri Olsa 		.check = test__checkevent_genhw,
1562615b8f99SAlexander Yarygin 		.id    = 7,
1563945aea22SJiri Olsa 	},
1564615b8f99SAlexander Yarygin 	{
1565945aea22SJiri Olsa 		.name  = "mem:0",
1566945aea22SJiri Olsa 		.check = test__checkevent_breakpoint,
1567615b8f99SAlexander Yarygin 		.id    = 8,
1568945aea22SJiri Olsa 	},
1569615b8f99SAlexander Yarygin 	{
1570945aea22SJiri Olsa 		.name  = "mem:0:x",
1571945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_x,
1572615b8f99SAlexander Yarygin 		.id    = 9,
1573945aea22SJiri Olsa 	},
1574615b8f99SAlexander Yarygin 	{
1575945aea22SJiri Olsa 		.name  = "mem:0:r",
1576945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_r,
1577615b8f99SAlexander Yarygin 		.id    = 10,
1578945aea22SJiri Olsa 	},
1579615b8f99SAlexander Yarygin 	{
1580945aea22SJiri Olsa 		.name  = "mem:0:w",
1581945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_w,
1582615b8f99SAlexander Yarygin 		.id    = 11,
1583945aea22SJiri Olsa 	},
1584615b8f99SAlexander Yarygin 	{
158543f322b4SRiku Voipio 		.name  = "syscalls:sys_enter_openat:k",
1586945aea22SJiri Olsa 		.check = test__checkevent_tracepoint_modifier,
1587615b8f99SAlexander Yarygin 		.id    = 12,
1588945aea22SJiri Olsa 	},
1589615b8f99SAlexander Yarygin 	{
1590945aea22SJiri Olsa 		.name  = "syscalls:*:u",
1591945aea22SJiri Olsa 		.check = test__checkevent_tracepoint_multi_modifier,
1592615b8f99SAlexander Yarygin 		.id    = 13,
1593945aea22SJiri Olsa 	},
1594615b8f99SAlexander Yarygin 	{
1595945aea22SJiri Olsa 		.name  = "r1a:kp",
1596945aea22SJiri Olsa 		.check = test__checkevent_raw_modifier,
1597615b8f99SAlexander Yarygin 		.id    = 14,
1598945aea22SJiri Olsa 	},
1599615b8f99SAlexander Yarygin 	{
1600945aea22SJiri Olsa 		.name  = "1:1:hp",
1601945aea22SJiri Olsa 		.check = test__checkevent_numeric_modifier,
1602615b8f99SAlexander Yarygin 		.id    = 15,
1603945aea22SJiri Olsa 	},
1604615b8f99SAlexander Yarygin 	{
1605945aea22SJiri Olsa 		.name  = "instructions:h",
1606945aea22SJiri Olsa 		.check = test__checkevent_symbolic_name_modifier,
1607615b8f99SAlexander Yarygin 		.id    = 16,
1608945aea22SJiri Olsa 	},
1609615b8f99SAlexander Yarygin 	{
1610945aea22SJiri Olsa 		.name  = "faults:u",
1611945aea22SJiri Olsa 		.check = test__checkevent_symbolic_alias_modifier,
1612615b8f99SAlexander Yarygin 		.id    = 17,
1613945aea22SJiri Olsa 	},
1614615b8f99SAlexander Yarygin 	{
1615945aea22SJiri Olsa 		.name  = "L1-dcache-load-miss:kp",
1616945aea22SJiri Olsa 		.check = test__checkevent_genhw_modifier,
1617615b8f99SAlexander Yarygin 		.id    = 18,
1618945aea22SJiri Olsa 	},
1619615b8f99SAlexander Yarygin 	{
1620945aea22SJiri Olsa 		.name  = "mem:0:u",
1621945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_modifier,
1622615b8f99SAlexander Yarygin 		.id    = 19,
1623945aea22SJiri Olsa 	},
1624615b8f99SAlexander Yarygin 	{
1625945aea22SJiri Olsa 		.name  = "mem:0:x:k",
1626945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_x_modifier,
1627615b8f99SAlexander Yarygin 		.id    = 20,
1628945aea22SJiri Olsa 	},
1629615b8f99SAlexander Yarygin 	{
1630945aea22SJiri Olsa 		.name  = "mem:0:r:hp",
1631945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_r_modifier,
1632615b8f99SAlexander Yarygin 		.id    = 21,
1633945aea22SJiri Olsa 	},
1634615b8f99SAlexander Yarygin 	{
1635945aea22SJiri Olsa 		.name  = "mem:0:w:up",
1636945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_w_modifier,
1637615b8f99SAlexander Yarygin 		.id    = 22,
1638945aea22SJiri Olsa 	},
1639615b8f99SAlexander Yarygin 	{
164043f322b4SRiku Voipio 		.name  = "r1,syscalls:sys_enter_openat:k,1:1:hp",
1641945aea22SJiri Olsa 		.check = test__checkevent_list,
1642615b8f99SAlexander Yarygin 		.id    = 23,
1643945aea22SJiri Olsa 	},
1644615b8f99SAlexander Yarygin 	{
1645945aea22SJiri Olsa 		.name  = "instructions:G",
1646945aea22SJiri Olsa 		.check = test__checkevent_exclude_host_modifier,
1647615b8f99SAlexander Yarygin 		.id    = 24,
1648945aea22SJiri Olsa 	},
1649615b8f99SAlexander Yarygin 	{
1650945aea22SJiri Olsa 		.name  = "instructions:H",
1651945aea22SJiri Olsa 		.check = test__checkevent_exclude_guest_modifier,
1652615b8f99SAlexander Yarygin 		.id    = 25,
1653945aea22SJiri Olsa 	},
1654615b8f99SAlexander Yarygin 	{
1655945aea22SJiri Olsa 		.name  = "mem:0:rw",
1656945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_rw,
1657615b8f99SAlexander Yarygin 		.id    = 26,
1658945aea22SJiri Olsa 	},
1659615b8f99SAlexander Yarygin 	{
1660945aea22SJiri Olsa 		.name  = "mem:0:rw:kp",
1661945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_rw_modifier,
1662615b8f99SAlexander Yarygin 		.id    = 27,
1663945aea22SJiri Olsa 	},
1664615b8f99SAlexander Yarygin 	{
1665945aea22SJiri Olsa 		.name  = "{instructions:k,cycles:upp}",
1666945aea22SJiri Olsa 		.check = test__group1,
1667615b8f99SAlexander Yarygin 		.id    = 28,
1668945aea22SJiri Olsa 	},
1669615b8f99SAlexander Yarygin 	{
1670945aea22SJiri Olsa 		.name  = "{faults:k,cache-references}:u,cycles:k",
1671945aea22SJiri Olsa 		.check = test__group2,
1672615b8f99SAlexander Yarygin 		.id    = 29,
1673945aea22SJiri Olsa 	},
1674615b8f99SAlexander Yarygin 	{
167543f322b4SRiku Voipio 		.name  = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
1676945aea22SJiri Olsa 		.check = test__group3,
1677615b8f99SAlexander Yarygin 		.id    = 30,
1678945aea22SJiri Olsa 	},
1679615b8f99SAlexander Yarygin 	{
1680945aea22SJiri Olsa 		.name  = "{cycles:u,instructions:kp}:p",
1681945aea22SJiri Olsa 		.check = test__group4,
1682615b8f99SAlexander Yarygin 		.id    = 31,
1683945aea22SJiri Olsa 	},
1684615b8f99SAlexander Yarygin 	{
1685945aea22SJiri Olsa 		.name  = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
1686945aea22SJiri Olsa 		.check = test__group5,
1687615b8f99SAlexander Yarygin 		.id    = 32,
1688945aea22SJiri Olsa 	},
1689615b8f99SAlexander Yarygin 	{
169082ce75d9SJiri Olsa 		.name  = "*:*",
169182ce75d9SJiri Olsa 		.check = test__all_tracepoints,
1692615b8f99SAlexander Yarygin 		.id    = 33,
169382ce75d9SJiri Olsa 	},
1694615b8f99SAlexander Yarygin 	{
16955a30a99fSJiri Olsa 		.name  = "{cycles,cache-misses:G}:H",
16965a30a99fSJiri Olsa 		.check = test__group_gh1,
1697615b8f99SAlexander Yarygin 		.id    = 34,
16985a30a99fSJiri Olsa 	},
1699615b8f99SAlexander Yarygin 	{
17005a30a99fSJiri Olsa 		.name  = "{cycles,cache-misses:H}:G",
17015a30a99fSJiri Olsa 		.check = test__group_gh2,
1702615b8f99SAlexander Yarygin 		.id    = 35,
17035a30a99fSJiri Olsa 	},
1704615b8f99SAlexander Yarygin 	{
17055a30a99fSJiri Olsa 		.name  = "{cycles:G,cache-misses:H}:u",
17065a30a99fSJiri Olsa 		.check = test__group_gh3,
1707615b8f99SAlexander Yarygin 		.id    = 36,
17085a30a99fSJiri Olsa 	},
1709615b8f99SAlexander Yarygin 	{
17105a30a99fSJiri Olsa 		.name  = "{cycles:G,cache-misses:H}:uG",
17115a30a99fSJiri Olsa 		.check = test__group_gh4,
1712615b8f99SAlexander Yarygin 		.id    = 37,
17135a30a99fSJiri Olsa 	},
1714615b8f99SAlexander Yarygin 	{
1715a9f93f97SJiri Olsa 		.name  = "{cycles,cache-misses,branch-misses}:S",
1716a9f93f97SJiri Olsa 		.check = test__leader_sample1,
1717615b8f99SAlexander Yarygin 		.id    = 38,
1718a9f93f97SJiri Olsa 	},
1719615b8f99SAlexander Yarygin 	{
1720a9f93f97SJiri Olsa 		.name  = "{instructions,branch-misses}:Su",
1721a9f93f97SJiri Olsa 		.check = test__leader_sample2,
1722615b8f99SAlexander Yarygin 		.id    = 39,
1723a9f93f97SJiri Olsa 	},
1724615b8f99SAlexander Yarygin 	{
1725c9ee780fSMichael Ellerman 		.name  = "instructions:uDp",
1726c9ee780fSMichael Ellerman 		.check = test__checkevent_pinned_modifier,
1727615b8f99SAlexander Yarygin 		.id    = 40,
1728c9ee780fSMichael Ellerman 	},
1729615b8f99SAlexander Yarygin 	{
1730c9ee780fSMichael Ellerman 		.name  = "{cycles,cache-misses,branch-misses}:D",
1731c9ee780fSMichael Ellerman 		.check = test__pinned_group,
1732615b8f99SAlexander Yarygin 		.id    = 41,
1733c9ee780fSMichael Ellerman 	},
1734ec32398cSJacob Shin 	{
1735ec32398cSJacob Shin 		.name  = "mem:0/1",
1736ec32398cSJacob Shin 		.check = test__checkevent_breakpoint_len,
1737ec32398cSJacob Shin 		.id    = 42,
1738ec32398cSJacob Shin 	},
1739ec32398cSJacob Shin 	{
1740ec32398cSJacob Shin 		.name  = "mem:0/2:w",
1741ec32398cSJacob Shin 		.check = test__checkevent_breakpoint_len_w,
1742ec32398cSJacob Shin 		.id    = 43,
1743ec32398cSJacob Shin 	},
1744ec32398cSJacob Shin 	{
1745ec32398cSJacob Shin 		.name  = "mem:0/4:rw:u",
1746ec32398cSJacob Shin 		.check = test__checkevent_breakpoint_len_rw_modifier,
1747ec32398cSJacob Shin 		.id    = 44
1748ec32398cSJacob Shin 	},
1749c0bc8c6dSAlexander Yarygin #if defined(__s390x__)
1750c0bc8c6dSAlexander Yarygin 	{
1751c0bc8c6dSAlexander Yarygin 		.name  = "kvm-s390:kvm_s390_create_vm",
1752c0bc8c6dSAlexander Yarygin 		.check = test__checkevent_tracepoint,
175353fe307dSThomas Richter 		.valid = kvm_s390_create_vm_valid,
1754c0bc8c6dSAlexander Yarygin 		.id    = 100,
1755c0bc8c6dSAlexander Yarygin 	},
1756c0bc8c6dSAlexander Yarygin #endif
1757a1e12da4SJiri Olsa 	{
1758a1e12da4SJiri Olsa 		.name  = "instructions:I",
1759a1e12da4SJiri Olsa 		.check = test__checkevent_exclude_idle_modifier,
1760a1e12da4SJiri Olsa 		.id    = 45,
1761a1e12da4SJiri Olsa 	},
1762a1e12da4SJiri Olsa 	{
1763a1e12da4SJiri Olsa 		.name  = "instructions:kIG",
1764a1e12da4SJiri Olsa 		.check = test__checkevent_exclude_idle_modifier_1,
1765a1e12da4SJiri Olsa 		.id    = 46,
1766a1e12da4SJiri Olsa 	},
1767ddd83c97SJiri Olsa 	{
1768ddd83c97SJiri Olsa 		.name  = "task-clock:P,cycles",
1769ddd83c97SJiri Olsa 		.check = test__checkevent_precise_max_modifier,
1770ddd83c97SJiri Olsa 		.id    = 47,
1771ddd83c97SJiri Olsa 	},
177210bf358aSWang Nan 	{
177310bf358aSWang Nan 		.name  = "instructions/name=insn/",
177410bf358aSWang Nan 		.check = test__checkevent_config_symbol,
177510bf358aSWang Nan 		.id    = 48,
177610bf358aSWang Nan 	},
177710bf358aSWang Nan 	{
177810bf358aSWang Nan 		.name  = "r1234/name=rawpmu/",
177910bf358aSWang Nan 		.check = test__checkevent_config_raw,
178010bf358aSWang Nan 		.id    = 49,
178110bf358aSWang Nan 	},
178210bf358aSWang Nan 	{
178310bf358aSWang Nan 		.name  = "4:0x6530160/name=numpmu/",
178410bf358aSWang Nan 		.check = test__checkevent_config_num,
178510bf358aSWang Nan 		.id    = 50,
178610bf358aSWang Nan 	},
178743d0b978SWang Nan 	{
178843d0b978SWang Nan 		.name  = "L1-dcache-misses/name=cachepmu/",
178943d0b978SWang Nan 		.check = test__checkevent_config_cache,
179043d0b978SWang Nan 		.id    = 51,
179143d0b978SWang Nan 	},
1792b3f58c8dSArnaldo Carvalho de Melo 	{
1793b3f58c8dSArnaldo Carvalho de Melo 		.name  = "intel_pt//u",
179416ddcfbfSJiri Olsa 		.valid = test__intel_pt_valid,
1795b3f58c8dSArnaldo Carvalho de Melo 		.check = test__intel_pt,
1796b3f58c8dSArnaldo Carvalho de Melo 		.id    = 52,
1797b3f58c8dSArnaldo Carvalho de Melo 	},
179806dc5bf2SAlexey Budankov 	{
179906dc5bf2SAlexey Budankov 		.name  = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk",
180006dc5bf2SAlexey Budankov 		.check = test__checkevent_complex_name,
180106dc5bf2SAlexey Budankov 		.id    = 53
1802714a92d8SJiri Olsa 	},
1803714a92d8SJiri Olsa 	{
1804714a92d8SJiri Olsa 		.name  = "cycles//u",
1805714a92d8SJiri Olsa 		.check = test__sym_event_slash,
1806714a92d8SJiri Olsa 		.id    = 54,
1807714a92d8SJiri Olsa 	},
1808714a92d8SJiri Olsa 	{
1809714a92d8SJiri Olsa 		.name  = "cycles:k",
1810714a92d8SJiri Olsa 		.check = test__sym_event_dc,
1811714a92d8SJiri Olsa 		.id    = 55,
18120997a266SAndi Kleen 	},
18130997a266SAndi Kleen 	{
18140997a266SAndi Kleen 		.name  = "instructions:uep",
18150997a266SAndi Kleen 		.check = test__checkevent_exclusive_modifier,
18160997a266SAndi Kleen 		.id    = 56,
18170997a266SAndi Kleen 	},
18180997a266SAndi Kleen 	{
18190997a266SAndi Kleen 		.name  = "{cycles,cache-misses,branch-misses}:e",
18200997a266SAndi Kleen 		.check = test__exclusive_group,
18210997a266SAndi Kleen 		.id    = 57,
18220997a266SAndi Kleen 	},
1823945aea22SJiri Olsa };
1824945aea22SJiri Olsa 
182523b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events_pmu[] = {
1826615b8f99SAlexander Yarygin 	{
1827945aea22SJiri Olsa 		.name  = "cpu/config=10,config1,config2=3,period=1000/u",
1828945aea22SJiri Olsa 		.check = test__checkevent_pmu,
1829615b8f99SAlexander Yarygin 		.id    = 0,
1830945aea22SJiri Olsa 	},
1831615b8f99SAlexander Yarygin 	{
1832945aea22SJiri Olsa 		.name  = "cpu/config=1,name=krava/u,cpu/config=2/u",
1833945aea22SJiri Olsa 		.check = test__checkevent_pmu_name,
1834615b8f99SAlexander Yarygin 		.id    = 1,
1835945aea22SJiri Olsa 	},
183671ef150eSKan Liang 	{
183771ef150eSKan Liang 		.name  = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
183871ef150eSKan Liang 		.check = test__checkevent_pmu_partial_time_callgraph,
183971ef150eSKan Liang 		.id    = 2,
184071ef150eSKan Liang 	},
184106dc5bf2SAlexey Budankov 	{
1842a6f39cecSSandipan Das 		.name  = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
184306dc5bf2SAlexey Budankov 		.check = test__checkevent_complex_name,
184406dc5bf2SAlexey Budankov 		.id    = 3,
18453a6c51e4SJiri Olsa 	},
18463a6c51e4SJiri Olsa 	{
18473a6c51e4SJiri Olsa 		.name  = "software/r1a/",
18483a6c51e4SJiri Olsa 		.check = test__checkevent_raw_pmu,
18493a6c51e4SJiri Olsa 		.id    = 4,
18503a6c51e4SJiri Olsa 	},
1851c33cdf54SJiri Olsa 	{
1852c33cdf54SJiri Olsa 		.name  = "software/r0x1a/",
1853c33cdf54SJiri Olsa 		.check = test__checkevent_raw_pmu,
1854c33cdf54SJiri Olsa 		.id    = 4,
1855c33cdf54SJiri Olsa 	},
1856945aea22SJiri Olsa };
1857945aea22SJiri Olsa 
185823b6339bSArnaldo Carvalho de Melo struct terms_test {
1859945aea22SJiri Olsa 	const char *str;
1860945aea22SJiri Olsa 	__u32 type;
1861945aea22SJiri Olsa 	int (*check)(struct list_head *terms);
1862945aea22SJiri Olsa };
1863945aea22SJiri Olsa 
186423b6339bSArnaldo Carvalho de Melo static struct terms_test test__terms[] = {
1865945aea22SJiri Olsa 	[0] = {
18664929e95aSJiri Olsa 		.str   = "config=10,config1,config2=3,umask=1,read,r0xead",
1867945aea22SJiri Olsa 		.check = test__checkterms_simple,
1868945aea22SJiri Olsa 	},
1869945aea22SJiri Olsa };
1870945aea22SJiri Olsa 
187123b6339bSArnaldo Carvalho de Melo static int test_event(struct evlist_test *e)
1872945aea22SJiri Olsa {
1873a910e466SIan Rogers 	struct parse_events_error err;
187463503dbaSJiri Olsa 	struct evlist *evlist;
1875945aea22SJiri Olsa 	int ret;
1876945aea22SJiri Olsa 
1877a910e466SIan Rogers 	bzero(&err, sizeof(err));
187816ddcfbfSJiri Olsa 	if (e->valid && !e->valid()) {
187916ddcfbfSJiri Olsa 		pr_debug("... SKIP");
188016ddcfbfSJiri Olsa 		return 0;
188116ddcfbfSJiri Olsa 	}
188216ddcfbfSJiri Olsa 
18830f98b11cSJiri Olsa 	evlist = evlist__new();
1884945aea22SJiri Olsa 	if (evlist == NULL)
1885945aea22SJiri Olsa 		return -ENOMEM;
1886945aea22SJiri Olsa 
1887933ccf20SJiri Olsa 	ret = parse_events(evlist, e->name, &err);
1888945aea22SJiri Olsa 	if (ret) {
1889933ccf20SJiri Olsa 		pr_debug("failed to parse event '%s', err %d, str '%s'\n",
1890933ccf20SJiri Olsa 			 e->name, ret, err.str);
1891933ccf20SJiri Olsa 		parse_events_print_error(&err, e->name);
18922d4352c0SArnaldo Carvalho de Melo 	} else {
18932d4352c0SArnaldo Carvalho de Melo 		ret = e->check(evlist);
1894945aea22SJiri Olsa 	}
1895945aea22SJiri Olsa 
1896c12995a5SJiri Olsa 	evlist__delete(evlist);
1897945aea22SJiri Olsa 
1898945aea22SJiri Olsa 	return ret;
1899945aea22SJiri Olsa }
1900945aea22SJiri Olsa 
190123b6339bSArnaldo Carvalho de Melo static int test_events(struct evlist_test *events, unsigned cnt)
1902945aea22SJiri Olsa {
1903945aea22SJiri Olsa 	int ret1, ret2 = 0;
1904945aea22SJiri Olsa 	unsigned i;
1905945aea22SJiri Olsa 
1906945aea22SJiri Olsa 	for (i = 0; i < cnt; i++) {
190723b6339bSArnaldo Carvalho de Melo 		struct evlist_test *e = &events[i];
1908945aea22SJiri Olsa 
190916ddcfbfSJiri Olsa 		pr_debug("running test %d '%s'", e->id, e->name);
1910945aea22SJiri Olsa 		ret1 = test_event(e);
1911945aea22SJiri Olsa 		if (ret1)
1912945aea22SJiri Olsa 			ret2 = ret1;
191316ddcfbfSJiri Olsa 		pr_debug("\n");
1914945aea22SJiri Olsa 	}
1915945aea22SJiri Olsa 
1916945aea22SJiri Olsa 	return ret2;
1917945aea22SJiri Olsa }
1918945aea22SJiri Olsa 
191923b6339bSArnaldo Carvalho de Melo static int test_term(struct terms_test *t)
1920945aea22SJiri Olsa {
1921c549aca5SDavid Ahern 	struct list_head terms;
1922945aea22SJiri Olsa 	int ret;
1923945aea22SJiri Olsa 
1924c549aca5SDavid Ahern 	INIT_LIST_HEAD(&terms);
1925945aea22SJiri Olsa 
19264929e95aSJiri Olsa 	/*
19274929e95aSJiri Olsa 	 * The perf_pmu__test_parse_init prepares perf_pmu_events_list
19284929e95aSJiri Olsa 	 * which gets freed in parse_events_terms.
19294929e95aSJiri Olsa 	 */
19304929e95aSJiri Olsa 	if (perf_pmu__test_parse_init())
19314929e95aSJiri Olsa 		return -1;
19324929e95aSJiri Olsa 
1933c549aca5SDavid Ahern 	ret = parse_events_terms(&terms, t->str);
1934945aea22SJiri Olsa 	if (ret) {
1935945aea22SJiri Olsa 		pr_debug("failed to parse terms '%s', err %d\n",
1936945aea22SJiri Olsa 			 t->str , ret);
1937945aea22SJiri Olsa 		return ret;
1938945aea22SJiri Olsa 	}
1939945aea22SJiri Olsa 
1940c549aca5SDavid Ahern 	ret = t->check(&terms);
1941682dc24cSArnaldo Carvalho de Melo 	parse_events_terms__purge(&terms);
1942945aea22SJiri Olsa 
1943945aea22SJiri Olsa 	return ret;
1944945aea22SJiri Olsa }
1945945aea22SJiri Olsa 
194623b6339bSArnaldo Carvalho de Melo static int test_terms(struct terms_test *terms, unsigned cnt)
1947945aea22SJiri Olsa {
1948945aea22SJiri Olsa 	int ret = 0;
1949945aea22SJiri Olsa 	unsigned i;
1950945aea22SJiri Olsa 
1951945aea22SJiri Olsa 	for (i = 0; i < cnt; i++) {
195223b6339bSArnaldo Carvalho de Melo 		struct terms_test *t = &terms[i];
1953945aea22SJiri Olsa 
1954945aea22SJiri Olsa 		pr_debug("running test %d '%s'\n", i, t->str);
1955945aea22SJiri Olsa 		ret = test_term(t);
1956945aea22SJiri Olsa 		if (ret)
1957945aea22SJiri Olsa 			break;
1958945aea22SJiri Olsa 	}
1959945aea22SJiri Olsa 
1960945aea22SJiri Olsa 	return ret;
1961945aea22SJiri Olsa }
1962945aea22SJiri Olsa 
1963945aea22SJiri Olsa static int test_pmu(void)
1964945aea22SJiri Olsa {
1965945aea22SJiri Olsa 	struct stat st;
1966945aea22SJiri Olsa 	char path[PATH_MAX];
1967945aea22SJiri Olsa 	int ret;
1968945aea22SJiri Olsa 
1969945aea22SJiri Olsa 	snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
1970cf38fadaSArnaldo Carvalho de Melo 		 sysfs__mountpoint());
1971945aea22SJiri Olsa 
1972945aea22SJiri Olsa 	ret = stat(path, &st);
1973945aea22SJiri Olsa 	if (ret)
1974945aea22SJiri Olsa 		pr_debug("omitting PMU cpu tests\n");
1975945aea22SJiri Olsa 	return !ret;
1976945aea22SJiri Olsa }
1977945aea22SJiri Olsa 
1978945aea22SJiri Olsa static int test_pmu_events(void)
1979945aea22SJiri Olsa {
1980945aea22SJiri Olsa 	struct stat st;
1981945aea22SJiri Olsa 	char path[PATH_MAX];
1982945aea22SJiri Olsa 	struct dirent *ent;
1983945aea22SJiri Olsa 	DIR *dir;
1984945aea22SJiri Olsa 	int ret;
1985945aea22SJiri Olsa 
1986945aea22SJiri Olsa 	snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
1987cf38fadaSArnaldo Carvalho de Melo 		 sysfs__mountpoint());
1988945aea22SJiri Olsa 
1989945aea22SJiri Olsa 	ret = stat(path, &st);
1990945aea22SJiri Olsa 	if (ret) {
1991a895d57dSMasanari Iida 		pr_debug("omitting PMU cpu events tests\n");
1992945aea22SJiri Olsa 		return 0;
1993945aea22SJiri Olsa 	}
1994945aea22SJiri Olsa 
1995945aea22SJiri Olsa 	dir = opendir(path);
1996945aea22SJiri Olsa 	if (!dir) {
1997945aea22SJiri Olsa 		pr_debug("can't open pmu event dir");
1998945aea22SJiri Olsa 		return -1;
1999945aea22SJiri Olsa 	}
2000945aea22SJiri Olsa 
2001945aea22SJiri Olsa 	while (!ret && (ent = readdir(dir))) {
200216ddcfbfSJiri Olsa 		struct evlist_test e = { .id = 0, };
20032e2bbc03SArnaldo Carvalho de Melo 		char name[2 * NAME_MAX + 1 + 12 + 3];
2004945aea22SJiri Olsa 
200517a2634bSAndi Kleen 		/* Names containing . are special and cannot be used directly */
200617a2634bSAndi Kleen 		if (strchr(ent->d_name, '.'))
2007945aea22SJiri Olsa 			continue;
2008945aea22SJiri Olsa 
20092e2bbc03SArnaldo Carvalho de Melo 		snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
2010945aea22SJiri Olsa 
2011945aea22SJiri Olsa 		e.name  = name;
2012945aea22SJiri Olsa 		e.check = test__checkevent_pmu_events;
2013945aea22SJiri Olsa 
2014945aea22SJiri Olsa 		ret = test_event(&e);
2015ffe59788SKan Liang 		if (ret)
2016ffe59788SKan Liang 			break;
20172e2bbc03SArnaldo Carvalho de Melo 		snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
2018ffe59788SKan Liang 		e.name  = name;
2019ffe59788SKan Liang 		e.check = test__checkevent_pmu_events_mix;
2020ffe59788SKan Liang 		ret = test_event(&e);
2021945aea22SJiri Olsa 	}
2022945aea22SJiri Olsa 
2023945aea22SJiri Olsa 	closedir(dir);
2024945aea22SJiri Olsa 	return ret;
2025945aea22SJiri Olsa }
2026945aea22SJiri Olsa 
202781f17c90SArnaldo Carvalho de Melo int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
2028945aea22SJiri Olsa {
2029945aea22SJiri Olsa 	int ret1, ret2 = 0;
2030945aea22SJiri Olsa 
2031945aea22SJiri Olsa #define TEST_EVENTS(tests)				\
2032945aea22SJiri Olsa do {							\
2033945aea22SJiri Olsa 	ret1 = test_events(tests, ARRAY_SIZE(tests));	\
2034945aea22SJiri Olsa 	if (!ret2)					\
2035945aea22SJiri Olsa 		ret2 = ret1;				\
2036945aea22SJiri Olsa } while (0)
2037945aea22SJiri Olsa 
2038945aea22SJiri Olsa 	TEST_EVENTS(test__events);
2039945aea22SJiri Olsa 
2040945aea22SJiri Olsa 	if (test_pmu())
2041945aea22SJiri Olsa 		TEST_EVENTS(test__events_pmu);
2042945aea22SJiri Olsa 
2043945aea22SJiri Olsa 	if (test_pmu()) {
2044945aea22SJiri Olsa 		int ret = test_pmu_events();
2045945aea22SJiri Olsa 		if (ret)
2046945aea22SJiri Olsa 			return ret;
2047945aea22SJiri Olsa 	}
2048945aea22SJiri Olsa 
2049945aea22SJiri Olsa 	ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));
2050945aea22SJiri Olsa 	if (!ret2)
2051945aea22SJiri Olsa 		ret2 = ret1;
2052945aea22SJiri Olsa 
2053945aea22SJiri Olsa 	return ret2;
2054945aea22SJiri Olsa }
2055