xref: /openbmc/linux/tools/perf/tests/parse-events.c (revision 2bb72dbb826c40e2503949ea5d104c3af976d02c)
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
2353fe307dSThomas Richter  * and retun 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 	/*
118ee4c7588SJiri Olsa 	 * The period value gets configured within perf_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 	/*
446ee4c7588SJiri Olsa 	 * The period value gets configured within perf_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 	/*
52371ef150eSKan Liang 	 * The period, time and callgraph value gets configured
52471ef150eSKan Liang 	 * within perf_evlist__config,
52571ef150eSKan Liang 	 * while this test executes only parse events method.
52671ef150eSKan Liang 	 */
5271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong period",     0 == evsel->core.attr.sample_period);
52827de9b2bSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong callgraph",  !evsel__has_callchain(evsel));
5291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong time",  !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
53071ef150eSKan Liang 
53171ef150eSKan Liang 	/* cpu/config=2,call-graph=no,time=0,period=2000/ */
532e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
5331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
5341fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config",  2 == evsel->core.attr.config);
53571ef150eSKan Liang 	/*
53671ef150eSKan Liang 	 * The period, time and callgraph value gets configured
53771ef150eSKan Liang 	 * within perf_evlist__config,
53871ef150eSKan Liang 	 * while this test executes only parse events method.
53971ef150eSKan Liang 	 */
5401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong period",     0 == evsel->core.attr.sample_period);
54127de9b2bSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong callgraph",  !evsel__has_callchain(evsel));
5421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong time",  !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
54371ef150eSKan Liang 
54471ef150eSKan Liang 	return 0;
54571ef150eSKan Liang }
54671ef150eSKan Liang 
54763503dbaSJiri Olsa static int test__checkevent_pmu_events(struct evlist *evlist)
548945aea22SJiri Olsa {
549515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
550945aea22SJiri Olsa 
5516484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
5521fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
553945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user",
5541fc632ceSJiri Olsa 			!evsel->core.attr.exclude_user);
555945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel",
5561fc632ceSJiri Olsa 			evsel->core.attr.exclude_kernel);
5571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
5581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
5591fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
560945aea22SJiri Olsa 
561945aea22SJiri Olsa 	return 0;
562945aea22SJiri Olsa }
563945aea22SJiri Olsa 
564ffe59788SKan Liang 
56563503dbaSJiri Olsa static int test__checkevent_pmu_events_mix(struct evlist *evlist)
566ffe59788SKan Liang {
567515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
568ffe59788SKan Liang 
569ffe59788SKan Liang 	/* pmu-event:u */
5706484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
571ffe59788SKan Liang 	TEST_ASSERT_VAL("wrong exclude_user",
5721fc632ceSJiri Olsa 			!evsel->core.attr.exclude_user);
573ffe59788SKan Liang 	TEST_ASSERT_VAL("wrong exclude_kernel",
5741fc632ceSJiri Olsa 			evsel->core.attr.exclude_kernel);
5751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
5761fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
5771fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
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);
590ffe59788SKan Liang 
591ffe59788SKan Liang 	return 0;
592ffe59788SKan Liang }
593ffe59788SKan Liang 
594945aea22SJiri Olsa static int test__checkterms_simple(struct list_head *terms)
595945aea22SJiri Olsa {
5966cee6cd3SArnaldo Carvalho de Melo 	struct parse_events_term *term;
597945aea22SJiri Olsa 
598945aea22SJiri Olsa 	/* config=10 */
5996cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(terms->next, struct parse_events_term, list);
600945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
601945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
602945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
603945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
604945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 10);
605945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
606945aea22SJiri Olsa 
607945aea22SJiri Olsa 	/* config1 */
6086cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(term->list.next, struct parse_events_term, list);
609945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
610945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
611945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
612945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
613945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 1);
614945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
615945aea22SJiri Olsa 
616945aea22SJiri Olsa 	/* config2=3 */
6176cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(term->list.next, struct parse_events_term, list);
618945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
619945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
620945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
621945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
622945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 3);
623945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !term->config);
624945aea22SJiri Olsa 
625945aea22SJiri Olsa 	/* umask=1*/
6266cee6cd3SArnaldo Carvalho de Melo 	term = list_entry(term->list.next, struct parse_events_term, list);
627945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type term",
628945aea22SJiri Olsa 			term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
629945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong type val",
630945aea22SJiri Olsa 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
631945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong val", term->val.num == 1);
632945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
633945aea22SJiri Olsa 
634945aea22SJiri Olsa 	return 0;
635945aea22SJiri Olsa }
636945aea22SJiri Olsa 
63763503dbaSJiri Olsa static int test__group1(struct evlist *evlist)
638945aea22SJiri Olsa {
63932dcd021SJiri Olsa 	struct evsel *evsel, *leader;
640945aea22SJiri Olsa 
6416484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
6428d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
643945aea22SJiri Olsa 
644945aea22SJiri Olsa 	/* instructions:k */
645515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
6461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
647945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
6481fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
6491fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
6501fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
6511fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
6521fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
6531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
6541fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
655c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
6565643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
657*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
658a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
659945aea22SJiri Olsa 
660945aea22SJiri Olsa 	/* cycles:upp */
661e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
6621fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
663945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
6641fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
6651fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
6661fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
6671fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
668945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
6691fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
6701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
6711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
672945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
673*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
674a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
675945aea22SJiri Olsa 
676945aea22SJiri Olsa 	return 0;
677945aea22SJiri Olsa }
678945aea22SJiri Olsa 
67963503dbaSJiri Olsa static int test__group2(struct evlist *evlist)
680945aea22SJiri Olsa {
68132dcd021SJiri Olsa 	struct evsel *evsel, *leader;
682945aea22SJiri Olsa 
6836484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
6848d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
685945aea22SJiri Olsa 
686945aea22SJiri Olsa 	/* faults + :ku modifier */
687515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
6881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
689945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
6901fc632ceSJiri Olsa 			PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
6911fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
6921fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
6931fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
6941fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
6951fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
6961fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
697c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
6985643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
699*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
700a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
701945aea22SJiri Olsa 
702945aea22SJiri Olsa 	/* cache-references + :u modifier */
703e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7041fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
705945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7061fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_REFERENCES == evsel->core.attr.config);
7071fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
7081fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
7091fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
7101fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
713945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
714*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
715a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
716945aea22SJiri Olsa 
717945aea22SJiri Olsa 	/* cycles:k */
718e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7191fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
720945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7211fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
7221fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
7231fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7241fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
7251fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
7261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
728c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
729a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
730945aea22SJiri Olsa 
731945aea22SJiri Olsa 	return 0;
732945aea22SJiri Olsa }
733945aea22SJiri Olsa 
73463503dbaSJiri Olsa static int test__group3(struct evlist *evlist __maybe_unused)
735945aea22SJiri Olsa {
73632dcd021SJiri Olsa 	struct evsel *evsel, *leader;
737945aea22SJiri Olsa 
7386484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
7398d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
740945aea22SJiri Olsa 
74143f322b4SRiku Voipio 	/* group1 syscalls:sys_enter_openat:H */
742515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
7431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
744945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_type",
7451fc632ceSJiri Olsa 		PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
7461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
7471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
7481fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7491fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
7501fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7511fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7521fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
753c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
754945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name",
755945aea22SJiri Olsa 		!strcmp(leader->group_name, "group1"));
7565643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
757*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
758a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
759945aea22SJiri Olsa 
760945aea22SJiri Olsa 	/* group1 cycles:kppp */
761e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7621fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
763945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7641fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
7651fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
7661fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7671fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
768945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
7691fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
7701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
7711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 3);
772945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
773945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
774*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
775a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
776945aea22SJiri Olsa 
777945aea22SJiri Olsa 	/* group2 cycles + G modifier */
778e470daeaSArnaldo Carvalho de Melo 	evsel = leader = evsel__next(evsel);
7791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
780945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
7811fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
7821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
7831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
7841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
7851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
7861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
7871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
788c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
789945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name",
790945aea22SJiri Olsa 		!strcmp(leader->group_name, "group2"));
7915643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
792*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
793a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
794945aea22SJiri Olsa 
795945aea22SJiri Olsa 	/* group2 1:3 + G modifier */
796e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
7971fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
7981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 3 == evsel->core.attr.config);
7991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
8011fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
8021fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
8031fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
8041fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
805945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
806*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
807a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
808945aea22SJiri Olsa 
809945aea22SJiri Olsa 	/* instructions:u */
810e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
8111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
812945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8131fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
8141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
8161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
8171fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
8181fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8191fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
820c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
821a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
822945aea22SJiri Olsa 
823945aea22SJiri Olsa 	return 0;
824945aea22SJiri Olsa }
825945aea22SJiri Olsa 
82663503dbaSJiri Olsa static int test__group4(struct evlist *evlist __maybe_unused)
827945aea22SJiri Olsa {
82832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
829945aea22SJiri Olsa 
8306484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
8318d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
832945aea22SJiri Olsa 
833945aea22SJiri Olsa 	/* cycles:u + p */
834515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
8351fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
836945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8371fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
8381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8391fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
8401fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
841945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
8421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
8431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 1);
845945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
846c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
8475643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
848*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
849a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
850945aea22SJiri Olsa 
851945aea22SJiri Olsa 	/* instructions:kp + p */
852e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
8531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
854945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8551fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
8561fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
8571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
8581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
859945aea22SJiri Olsa 	/* use of precise requires exclude_guest */
8601fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
8611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
8621fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
863945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
864*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
865a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
866945aea22SJiri Olsa 
867945aea22SJiri Olsa 	return 0;
868945aea22SJiri Olsa }
869945aea22SJiri Olsa 
87063503dbaSJiri Olsa static int test__group5(struct evlist *evlist __maybe_unused)
871945aea22SJiri Olsa {
87232dcd021SJiri Olsa 	struct evsel *evsel, *leader;
873945aea22SJiri Olsa 
8746484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
8758d7d8474SNamhyung Kim 	TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
876945aea22SJiri Olsa 
877945aea22SJiri Olsa 	/* cycles + G */
878515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
8791fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
880945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8811fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
8821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
8831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
8841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
8851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
8861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
8871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
888945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
889c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
8905643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
891*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
892a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
893945aea22SJiri Olsa 
894945aea22SJiri Olsa 	/* instructions + G */
895e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
8961fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
897945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
8981fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
8991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9011fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9021fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9031fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9041fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
905945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
906*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
907a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
908945aea22SJiri Olsa 
909945aea22SJiri Olsa 	/* cycles:G */
910e470daeaSArnaldo Carvalho de Melo 	evsel = leader = evsel__next(evsel);
9111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
912945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9131fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9171fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9181fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9191fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
920945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
921c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
9225643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
923*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
924a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
925945aea22SJiri Olsa 
926945aea22SJiri Olsa 	/* instructions:G */
927e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
9281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
929945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9301fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
9311fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9321fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9331fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9341fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9351fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
9361fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
937945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
938*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
939945aea22SJiri Olsa 
940945aea22SJiri Olsa 	/* cycles */
941e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
9421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
943945aea22SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9441fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9481fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
9491fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
9501fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
951c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
952945aea22SJiri Olsa 
953945aea22SJiri Olsa 	return 0;
954945aea22SJiri Olsa }
955945aea22SJiri Olsa 
95663503dbaSJiri Olsa static int test__group_gh1(struct evlist *evlist)
9575a30a99fSJiri Olsa {
95832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
9595a30a99fSJiri Olsa 
9606484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
9615a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
9625a30a99fSJiri Olsa 
9635a30a99fSJiri Olsa 	/* cycles + :H group modifier */
964515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
9651fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
9665a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9671fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
9681fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9691fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9701fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9711fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
9721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
9731fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
9745a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
975c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
9765643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
977*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
9785a30a99fSJiri Olsa 
9795a30a99fSJiri Olsa 	/* cache-misses:G + :H group modifier */
980e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
9811fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
9825a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
9831fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
9841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
9851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
9861fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
9871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
9881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
9891fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
9905a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
991*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
9925a30a99fSJiri Olsa 
9935a30a99fSJiri Olsa 	return 0;
9945a30a99fSJiri Olsa }
9955a30a99fSJiri Olsa 
99663503dbaSJiri Olsa static int test__group_gh2(struct evlist *evlist)
9975a30a99fSJiri Olsa {
99832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
9995a30a99fSJiri Olsa 
10006484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
10015a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
10025a30a99fSJiri Olsa 
10035a30a99fSJiri Olsa 	/* cycles + :G group modifier */
1004515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
10051fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10065a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10071fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
10081fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10091fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
10101fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
10111fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
10131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10145a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1015c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
10165643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1017*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
10185a30a99fSJiri Olsa 
10195a30a99fSJiri Olsa 	/* cache-misses:H + :G group modifier */
1020e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
10211fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10225a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10231fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
10241fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10251fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
10261fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
10271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
10291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10305a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1031*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
10325a30a99fSJiri Olsa 
10335a30a99fSJiri Olsa 	return 0;
10345a30a99fSJiri Olsa }
10355a30a99fSJiri Olsa 
103663503dbaSJiri Olsa static int test__group_gh3(struct evlist *evlist)
10375a30a99fSJiri Olsa {
103832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
10395a30a99fSJiri Olsa 
10406484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
10415a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
10425a30a99fSJiri Olsa 
10435a30a99fSJiri Olsa 	/* cycles:G + :u group modifier */
1044515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
10451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10465a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10471fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
10481fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10491fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
10501fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
10511fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10521fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
10531fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10545a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1055c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
10565643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1057*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
10585a30a99fSJiri Olsa 
10595a30a99fSJiri Olsa 	/* cache-misses:H + :u group modifier */
1060e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
10611fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10625a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10631fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
10641fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10651fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
10661fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
10671fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
10681fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
10691fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10705a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1071*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
10725a30a99fSJiri Olsa 
10735a30a99fSJiri Olsa 	return 0;
10745a30a99fSJiri Olsa }
10755a30a99fSJiri Olsa 
107663503dbaSJiri Olsa static int test__group_gh4(struct evlist *evlist)
10775a30a99fSJiri Olsa {
107832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
10795a30a99fSJiri Olsa 
10806484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
10815a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
10825a30a99fSJiri Olsa 
10835a30a99fSJiri Olsa 	/* cycles:G + :uG group modifier */
1084515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
10851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
10865a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
10871fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
10881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
10891fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
10901fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
10911fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
10921fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
10931fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
10945a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1095c754c382SArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
10965643b1a5SJiri Olsa 	TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1097*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
10985a30a99fSJiri Olsa 
10995a30a99fSJiri Olsa 	/* cache-misses:H + :uG group modifier */
1100e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
11011fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
11025a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11031fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
11041fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11051fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
11061fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
11071fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
11081fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11091fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
11105a30a99fSJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1111*2bb72dbbSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
11125a30a99fSJiri Olsa 
11135a30a99fSJiri Olsa 	return 0;
11145a30a99fSJiri Olsa }
11155a30a99fSJiri Olsa 
111663503dbaSJiri Olsa static int test__leader_sample1(struct evlist *evlist)
1117a9f93f97SJiri Olsa {
111832dcd021SJiri Olsa 	struct evsel *evsel, *leader;
1119a9f93f97SJiri Olsa 
11206484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1121a9f93f97SJiri Olsa 
1122a9f93f97SJiri Olsa 	/* cycles - sampling group leader */
1123515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
11241fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1125a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11261fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
11271fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11281fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
11291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
11301fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11311fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11321fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1133a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1134a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1135a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1136a9f93f97SJiri Olsa 
1137a9f93f97SJiri Olsa 	/* cache-misses - not sampling */
1138e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
11391fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1140a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11411fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
11421fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11431fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
11441fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
11451fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11461fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1148a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1149a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1150a9f93f97SJiri Olsa 
1151a9f93f97SJiri Olsa 	/* branch-misses - not sampling */
1152e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
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_BRANCH_MISSES == 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 	return 0;
1167a9f93f97SJiri Olsa }
1168a9f93f97SJiri Olsa 
116963503dbaSJiri Olsa static int test__leader_sample2(struct evlist *evlist __maybe_unused)
1170a9f93f97SJiri Olsa {
117132dcd021SJiri Olsa 	struct evsel *evsel, *leader;
1172a9f93f97SJiri Olsa 
11736484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
1174a9f93f97SJiri Olsa 
1175a9f93f97SJiri Olsa 	/* instructions - sampling group leader */
1176515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
11771fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1178a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11791fc632ceSJiri Olsa 			PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
11801fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11811fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
11821fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
11831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
11851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1186a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1187a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1188a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1189a9f93f97SJiri Olsa 
1190a9f93f97SJiri Olsa 	/* branch-misses - not sampling */
1191e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
11921fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1193a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
11941fc632ceSJiri Olsa 			PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
11951fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
11961fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
11971fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
11981fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
11991fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
12001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1201a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1202a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1203a9f93f97SJiri Olsa 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1204a9f93f97SJiri Olsa 
1205a9f93f97SJiri Olsa 	return 0;
1206a9f93f97SJiri Olsa }
1207a9f93f97SJiri Olsa 
120863503dbaSJiri Olsa static int test__checkevent_pinned_modifier(struct evlist *evlist)
1209c9ee780fSMichael Ellerman {
1210515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1211c9ee780fSMichael Ellerman 
12121fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
12131fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
12141fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
12151fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
12161fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
1217c9ee780fSMichael Ellerman 
1218c9ee780fSMichael Ellerman 	return test__checkevent_symbolic_name(evlist);
1219c9ee780fSMichael Ellerman }
1220c9ee780fSMichael Ellerman 
122163503dbaSJiri Olsa static int test__pinned_group(struct evlist *evlist)
1222c9ee780fSMichael Ellerman {
122332dcd021SJiri Olsa 	struct evsel *evsel, *leader;
1224c9ee780fSMichael Ellerman 
12256484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
1226c9ee780fSMichael Ellerman 
1227c9ee780fSMichael Ellerman 	/* cycles - group leader */
1228515dbe48SJiri Olsa 	evsel = leader = evlist__first(evlist);
12291fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1230c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong config",
12311fc632ceSJiri Olsa 			PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1232c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1233c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
12341fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
1235c9ee780fSMichael Ellerman 
1236c9ee780fSMichael Ellerman 	/* cache-misses - can not be pinned, but will go on with the leader */
1237e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
12381fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
1239c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong config",
12401fc632ceSJiri Olsa 			PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
12411fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
1242c9ee780fSMichael Ellerman 
1243c9ee780fSMichael Ellerman 	/* branch-misses - ditto */
1244e470daeaSArnaldo Carvalho de Melo 	evsel = evsel__next(evsel);
1245c9ee780fSMichael Ellerman 	TEST_ASSERT_VAL("wrong config",
12461fc632ceSJiri Olsa 			PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
12471fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
1248c9ee780fSMichael Ellerman 
1249c9ee780fSMichael Ellerman 	return 0;
1250c9ee780fSMichael Ellerman }
1251c9ee780fSMichael Ellerman 
125263503dbaSJiri Olsa static int test__checkevent_breakpoint_len(struct evlist *evlist)
1253ec32398cSJacob Shin {
1254515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1255ec32398cSJacob Shin 
12566484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
12571fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
12581fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
1259ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
12601fc632ceSJiri Olsa 					 evsel->core.attr.bp_type);
1261ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
12621fc632ceSJiri Olsa 					evsel->core.attr.bp_len);
1263ec32398cSJacob Shin 
1264ec32398cSJacob Shin 	return 0;
1265ec32398cSJacob Shin }
1266ec32398cSJacob Shin 
126763503dbaSJiri Olsa static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
1268ec32398cSJacob Shin {
1269515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1270ec32398cSJacob Shin 
12716484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
12721fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
12731fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
1274ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
12751fc632ceSJiri Olsa 					 evsel->core.attr.bp_type);
1276ec32398cSJacob Shin 	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
12771fc632ceSJiri Olsa 					evsel->core.attr.bp_len);
1278ec32398cSJacob Shin 
1279ec32398cSJacob Shin 	return 0;
1280ec32398cSJacob Shin }
1281ec32398cSJacob Shin 
1282ec32398cSJacob Shin static int
128363503dbaSJiri Olsa test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
1284ec32398cSJacob Shin {
1285515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1286ec32398cSJacob Shin 
12871fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
12881fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
12891fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
12901fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
1291ec32398cSJacob Shin 
1292ec32398cSJacob Shin 	return test__checkevent_breakpoint_rw(evlist);
1293ec32398cSJacob Shin }
1294ec32398cSJacob Shin 
129563503dbaSJiri Olsa static int test__checkevent_precise_max_modifier(struct evlist *evlist)
1296ddd83c97SJiri Olsa {
1297515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1298ddd83c97SJiri Olsa 
12996484d2f9SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
13001fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
1301ddd83c97SJiri Olsa 	TEST_ASSERT_VAL("wrong config",
13021fc632ceSJiri Olsa 			PERF_COUNT_SW_TASK_CLOCK == evsel->core.attr.config);
1303ddd83c97SJiri Olsa 	return 0;
1304ddd83c97SJiri Olsa }
1305ddd83c97SJiri Olsa 
130663503dbaSJiri Olsa static int test__checkevent_config_symbol(struct evlist *evlist)
130710bf358aSWang Nan {
1308515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
130910bf358aSWang Nan 
131010bf358aSWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
131110bf358aSWang Nan 	return 0;
131210bf358aSWang Nan }
131310bf358aSWang Nan 
131463503dbaSJiri Olsa static int test__checkevent_config_raw(struct evlist *evlist)
131510bf358aSWang Nan {
1316515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
131710bf358aSWang Nan 
131810bf358aSWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
131910bf358aSWang Nan 	return 0;
132010bf358aSWang Nan }
132110bf358aSWang Nan 
132263503dbaSJiri Olsa static int test__checkevent_config_num(struct evlist *evlist)
132310bf358aSWang Nan {
1324515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
132510bf358aSWang Nan 
132610bf358aSWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
132710bf358aSWang Nan 	return 0;
132810bf358aSWang Nan }
132910bf358aSWang Nan 
133063503dbaSJiri Olsa static int test__checkevent_config_cache(struct evlist *evlist)
133143d0b978SWang Nan {
1332515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
133343d0b978SWang Nan 
133443d0b978SWang Nan 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
133543d0b978SWang Nan 	return 0;
133643d0b978SWang Nan }
133710bf358aSWang Nan 
133816ddcfbfSJiri Olsa static bool test__intel_pt_valid(void)
133916ddcfbfSJiri Olsa {
134016ddcfbfSJiri Olsa 	return !!perf_pmu__find("intel_pt");
134116ddcfbfSJiri Olsa }
134216ddcfbfSJiri Olsa 
134363503dbaSJiri Olsa static int test__intel_pt(struct evlist *evlist)
1344b3f58c8dSArnaldo Carvalho de Melo {
1345515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1346b3f58c8dSArnaldo Carvalho de Melo 
1347b3f58c8dSArnaldo Carvalho de Melo 	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0);
1348b3f58c8dSArnaldo Carvalho de Melo 	return 0;
1349b3f58c8dSArnaldo Carvalho de Melo }
1350b3f58c8dSArnaldo Carvalho de Melo 
135163503dbaSJiri Olsa static int test__checkevent_complex_name(struct evlist *evlist)
135206dc5bf2SAlexey Budankov {
1353515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
135406dc5bf2SAlexey Budankov 
135506dc5bf2SAlexey Budankov 	TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0);
135606dc5bf2SAlexey Budankov 	return 0;
135706dc5bf2SAlexey Budankov }
135806dc5bf2SAlexey Budankov 
13593a6c51e4SJiri Olsa static int test__checkevent_raw_pmu(struct evlist *evlist)
13603a6c51e4SJiri Olsa {
13613a6c51e4SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
13623a6c51e4SJiri Olsa 
13633a6c51e4SJiri Olsa 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
13643a6c51e4SJiri Olsa 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
13653a6c51e4SJiri Olsa 	TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
13663a6c51e4SJiri Olsa 	return 0;
13673a6c51e4SJiri Olsa }
13683a6c51e4SJiri Olsa 
136963503dbaSJiri Olsa static int test__sym_event_slash(struct evlist *evlist)
1370714a92d8SJiri Olsa {
1371515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1372714a92d8SJiri Olsa 
13731fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
13741fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
13751fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1376714a92d8SJiri Olsa 	return 0;
1377714a92d8SJiri Olsa }
1378714a92d8SJiri Olsa 
137963503dbaSJiri Olsa static int test__sym_event_dc(struct evlist *evlist)
1380714a92d8SJiri Olsa {
1381515dbe48SJiri Olsa 	struct evsel *evsel = evlist__first(evlist);
1382714a92d8SJiri Olsa 
13831fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
13841fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
13851fc632ceSJiri Olsa 	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
1386714a92d8SJiri Olsa 	return 0;
1387714a92d8SJiri Olsa }
1388714a92d8SJiri Olsa 
138982ce75d9SJiri Olsa static int count_tracepoints(void)
139082ce75d9SJiri Olsa {
139182ce75d9SJiri Olsa 	struct dirent *events_ent;
139282ce75d9SJiri Olsa 	DIR *events_dir;
139382ce75d9SJiri Olsa 	int cnt = 0;
139482ce75d9SJiri Olsa 
13957014e0e3SArnaldo Carvalho de Melo 	events_dir = tracing_events__opendir();
139682ce75d9SJiri Olsa 
139782ce75d9SJiri Olsa 	TEST_ASSERT_VAL("Can't open events dir", events_dir);
139882ce75d9SJiri Olsa 
139982ce75d9SJiri Olsa 	while ((events_ent = readdir(events_dir))) {
140025a7d914SArnaldo Carvalho de Melo 		char *sys_path;
140182ce75d9SJiri Olsa 		struct dirent *sys_ent;
140282ce75d9SJiri Olsa 		DIR *sys_dir;
140382ce75d9SJiri Olsa 
140482ce75d9SJiri Olsa 		if (!strcmp(events_ent->d_name, ".")
140582ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "..")
140682ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "enable")
140782ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "header_event")
140882ce75d9SJiri Olsa 		    || !strcmp(events_ent->d_name, "header_page"))
140982ce75d9SJiri Olsa 			continue;
141082ce75d9SJiri Olsa 
141125a7d914SArnaldo Carvalho de Melo 		sys_path = get_events_file(events_ent->d_name);
141225a7d914SArnaldo Carvalho de Melo 		TEST_ASSERT_VAL("Can't get sys path", sys_path);
141382ce75d9SJiri Olsa 
141482ce75d9SJiri Olsa 		sys_dir = opendir(sys_path);
141582ce75d9SJiri Olsa 		TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
141682ce75d9SJiri Olsa 
141782ce75d9SJiri Olsa 		while ((sys_ent = readdir(sys_dir))) {
141882ce75d9SJiri Olsa 			if (!strcmp(sys_ent->d_name, ".")
141982ce75d9SJiri Olsa 			    || !strcmp(sys_ent->d_name, "..")
142082ce75d9SJiri Olsa 			    || !strcmp(sys_ent->d_name, "enable")
142182ce75d9SJiri Olsa 			    || !strcmp(sys_ent->d_name, "filter"))
142282ce75d9SJiri Olsa 				continue;
142382ce75d9SJiri Olsa 
142482ce75d9SJiri Olsa 			cnt++;
142582ce75d9SJiri Olsa 		}
142682ce75d9SJiri Olsa 
142782ce75d9SJiri Olsa 		closedir(sys_dir);
142825a7d914SArnaldo Carvalho de Melo 		put_events_file(sys_path);
142982ce75d9SJiri Olsa 	}
143082ce75d9SJiri Olsa 
143182ce75d9SJiri Olsa 	closedir(events_dir);
143282ce75d9SJiri Olsa 	return cnt;
143382ce75d9SJiri Olsa }
143482ce75d9SJiri Olsa 
143563503dbaSJiri Olsa static int test__all_tracepoints(struct evlist *evlist)
143682ce75d9SJiri Olsa {
143782ce75d9SJiri Olsa 	TEST_ASSERT_VAL("wrong events count",
14386484d2f9SJiri Olsa 			count_tracepoints() == evlist->core.nr_entries);
143982ce75d9SJiri Olsa 
144082ce75d9SJiri Olsa 	return test__checkevent_tracepoint_multi(evlist);
144182ce75d9SJiri Olsa }
144282ce75d9SJiri Olsa 
144323b6339bSArnaldo Carvalho de Melo struct evlist_test {
1444945aea22SJiri Olsa 	const char *name;
1445945aea22SJiri Olsa 	__u32 type;
1446615b8f99SAlexander Yarygin 	const int id;
144716ddcfbfSJiri Olsa 	bool (*valid)(void);
144863503dbaSJiri Olsa 	int (*check)(struct evlist *evlist);
1449945aea22SJiri Olsa };
1450945aea22SJiri Olsa 
145123b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events[] = {
1452615b8f99SAlexander Yarygin 	{
145343f322b4SRiku Voipio 		.name  = "syscalls:sys_enter_openat",
1454945aea22SJiri Olsa 		.check = test__checkevent_tracepoint,
1455615b8f99SAlexander Yarygin 		.id    = 0,
1456945aea22SJiri Olsa 	},
1457615b8f99SAlexander Yarygin 	{
1458945aea22SJiri Olsa 		.name  = "syscalls:*",
1459945aea22SJiri Olsa 		.check = test__checkevent_tracepoint_multi,
1460615b8f99SAlexander Yarygin 		.id    = 1,
1461945aea22SJiri Olsa 	},
1462615b8f99SAlexander Yarygin 	{
1463945aea22SJiri Olsa 		.name  = "r1a",
1464945aea22SJiri Olsa 		.check = test__checkevent_raw,
1465615b8f99SAlexander Yarygin 		.id    = 2,
1466945aea22SJiri Olsa 	},
1467615b8f99SAlexander Yarygin 	{
1468945aea22SJiri Olsa 		.name  = "1:1",
1469945aea22SJiri Olsa 		.check = test__checkevent_numeric,
1470615b8f99SAlexander Yarygin 		.id    = 3,
1471945aea22SJiri Olsa 	},
1472615b8f99SAlexander Yarygin 	{
1473945aea22SJiri Olsa 		.name  = "instructions",
1474945aea22SJiri Olsa 		.check = test__checkevent_symbolic_name,
1475615b8f99SAlexander Yarygin 		.id    = 4,
1476945aea22SJiri Olsa 	},
1477615b8f99SAlexander Yarygin 	{
1478945aea22SJiri Olsa 		.name  = "cycles/period=100000,config2/",
1479945aea22SJiri Olsa 		.check = test__checkevent_symbolic_name_config,
1480615b8f99SAlexander Yarygin 		.id    = 5,
1481945aea22SJiri Olsa 	},
1482615b8f99SAlexander Yarygin 	{
1483945aea22SJiri Olsa 		.name  = "faults",
1484945aea22SJiri Olsa 		.check = test__checkevent_symbolic_alias,
1485615b8f99SAlexander Yarygin 		.id    = 6,
1486945aea22SJiri Olsa 	},
1487615b8f99SAlexander Yarygin 	{
1488945aea22SJiri Olsa 		.name  = "L1-dcache-load-miss",
1489945aea22SJiri Olsa 		.check = test__checkevent_genhw,
1490615b8f99SAlexander Yarygin 		.id    = 7,
1491945aea22SJiri Olsa 	},
1492615b8f99SAlexander Yarygin 	{
1493945aea22SJiri Olsa 		.name  = "mem:0",
1494945aea22SJiri Olsa 		.check = test__checkevent_breakpoint,
1495615b8f99SAlexander Yarygin 		.id    = 8,
1496945aea22SJiri Olsa 	},
1497615b8f99SAlexander Yarygin 	{
1498945aea22SJiri Olsa 		.name  = "mem:0:x",
1499945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_x,
1500615b8f99SAlexander Yarygin 		.id    = 9,
1501945aea22SJiri Olsa 	},
1502615b8f99SAlexander Yarygin 	{
1503945aea22SJiri Olsa 		.name  = "mem:0:r",
1504945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_r,
1505615b8f99SAlexander Yarygin 		.id    = 10,
1506945aea22SJiri Olsa 	},
1507615b8f99SAlexander Yarygin 	{
1508945aea22SJiri Olsa 		.name  = "mem:0:w",
1509945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_w,
1510615b8f99SAlexander Yarygin 		.id    = 11,
1511945aea22SJiri Olsa 	},
1512615b8f99SAlexander Yarygin 	{
151343f322b4SRiku Voipio 		.name  = "syscalls:sys_enter_openat:k",
1514945aea22SJiri Olsa 		.check = test__checkevent_tracepoint_modifier,
1515615b8f99SAlexander Yarygin 		.id    = 12,
1516945aea22SJiri Olsa 	},
1517615b8f99SAlexander Yarygin 	{
1518945aea22SJiri Olsa 		.name  = "syscalls:*:u",
1519945aea22SJiri Olsa 		.check = test__checkevent_tracepoint_multi_modifier,
1520615b8f99SAlexander Yarygin 		.id    = 13,
1521945aea22SJiri Olsa 	},
1522615b8f99SAlexander Yarygin 	{
1523945aea22SJiri Olsa 		.name  = "r1a:kp",
1524945aea22SJiri Olsa 		.check = test__checkevent_raw_modifier,
1525615b8f99SAlexander Yarygin 		.id    = 14,
1526945aea22SJiri Olsa 	},
1527615b8f99SAlexander Yarygin 	{
1528945aea22SJiri Olsa 		.name  = "1:1:hp",
1529945aea22SJiri Olsa 		.check = test__checkevent_numeric_modifier,
1530615b8f99SAlexander Yarygin 		.id    = 15,
1531945aea22SJiri Olsa 	},
1532615b8f99SAlexander Yarygin 	{
1533945aea22SJiri Olsa 		.name  = "instructions:h",
1534945aea22SJiri Olsa 		.check = test__checkevent_symbolic_name_modifier,
1535615b8f99SAlexander Yarygin 		.id    = 16,
1536945aea22SJiri Olsa 	},
1537615b8f99SAlexander Yarygin 	{
1538945aea22SJiri Olsa 		.name  = "faults:u",
1539945aea22SJiri Olsa 		.check = test__checkevent_symbolic_alias_modifier,
1540615b8f99SAlexander Yarygin 		.id    = 17,
1541945aea22SJiri Olsa 	},
1542615b8f99SAlexander Yarygin 	{
1543945aea22SJiri Olsa 		.name  = "L1-dcache-load-miss:kp",
1544945aea22SJiri Olsa 		.check = test__checkevent_genhw_modifier,
1545615b8f99SAlexander Yarygin 		.id    = 18,
1546945aea22SJiri Olsa 	},
1547615b8f99SAlexander Yarygin 	{
1548945aea22SJiri Olsa 		.name  = "mem:0:u",
1549945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_modifier,
1550615b8f99SAlexander Yarygin 		.id    = 19,
1551945aea22SJiri Olsa 	},
1552615b8f99SAlexander Yarygin 	{
1553945aea22SJiri Olsa 		.name  = "mem:0:x:k",
1554945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_x_modifier,
1555615b8f99SAlexander Yarygin 		.id    = 20,
1556945aea22SJiri Olsa 	},
1557615b8f99SAlexander Yarygin 	{
1558945aea22SJiri Olsa 		.name  = "mem:0:r:hp",
1559945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_r_modifier,
1560615b8f99SAlexander Yarygin 		.id    = 21,
1561945aea22SJiri Olsa 	},
1562615b8f99SAlexander Yarygin 	{
1563945aea22SJiri Olsa 		.name  = "mem:0:w:up",
1564945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_w_modifier,
1565615b8f99SAlexander Yarygin 		.id    = 22,
1566945aea22SJiri Olsa 	},
1567615b8f99SAlexander Yarygin 	{
156843f322b4SRiku Voipio 		.name  = "r1,syscalls:sys_enter_openat:k,1:1:hp",
1569945aea22SJiri Olsa 		.check = test__checkevent_list,
1570615b8f99SAlexander Yarygin 		.id    = 23,
1571945aea22SJiri Olsa 	},
1572615b8f99SAlexander Yarygin 	{
1573945aea22SJiri Olsa 		.name  = "instructions:G",
1574945aea22SJiri Olsa 		.check = test__checkevent_exclude_host_modifier,
1575615b8f99SAlexander Yarygin 		.id    = 24,
1576945aea22SJiri Olsa 	},
1577615b8f99SAlexander Yarygin 	{
1578945aea22SJiri Olsa 		.name  = "instructions:H",
1579945aea22SJiri Olsa 		.check = test__checkevent_exclude_guest_modifier,
1580615b8f99SAlexander Yarygin 		.id    = 25,
1581945aea22SJiri Olsa 	},
1582615b8f99SAlexander Yarygin 	{
1583945aea22SJiri Olsa 		.name  = "mem:0:rw",
1584945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_rw,
1585615b8f99SAlexander Yarygin 		.id    = 26,
1586945aea22SJiri Olsa 	},
1587615b8f99SAlexander Yarygin 	{
1588945aea22SJiri Olsa 		.name  = "mem:0:rw:kp",
1589945aea22SJiri Olsa 		.check = test__checkevent_breakpoint_rw_modifier,
1590615b8f99SAlexander Yarygin 		.id    = 27,
1591945aea22SJiri Olsa 	},
1592615b8f99SAlexander Yarygin 	{
1593945aea22SJiri Olsa 		.name  = "{instructions:k,cycles:upp}",
1594945aea22SJiri Olsa 		.check = test__group1,
1595615b8f99SAlexander Yarygin 		.id    = 28,
1596945aea22SJiri Olsa 	},
1597615b8f99SAlexander Yarygin 	{
1598945aea22SJiri Olsa 		.name  = "{faults:k,cache-references}:u,cycles:k",
1599945aea22SJiri Olsa 		.check = test__group2,
1600615b8f99SAlexander Yarygin 		.id    = 29,
1601945aea22SJiri Olsa 	},
1602615b8f99SAlexander Yarygin 	{
160343f322b4SRiku Voipio 		.name  = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
1604945aea22SJiri Olsa 		.check = test__group3,
1605615b8f99SAlexander Yarygin 		.id    = 30,
1606945aea22SJiri Olsa 	},
1607615b8f99SAlexander Yarygin 	{
1608945aea22SJiri Olsa 		.name  = "{cycles:u,instructions:kp}:p",
1609945aea22SJiri Olsa 		.check = test__group4,
1610615b8f99SAlexander Yarygin 		.id    = 31,
1611945aea22SJiri Olsa 	},
1612615b8f99SAlexander Yarygin 	{
1613945aea22SJiri Olsa 		.name  = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
1614945aea22SJiri Olsa 		.check = test__group5,
1615615b8f99SAlexander Yarygin 		.id    = 32,
1616945aea22SJiri Olsa 	},
1617615b8f99SAlexander Yarygin 	{
161882ce75d9SJiri Olsa 		.name  = "*:*",
161982ce75d9SJiri Olsa 		.check = test__all_tracepoints,
1620615b8f99SAlexander Yarygin 		.id    = 33,
162182ce75d9SJiri Olsa 	},
1622615b8f99SAlexander Yarygin 	{
16235a30a99fSJiri Olsa 		.name  = "{cycles,cache-misses:G}:H",
16245a30a99fSJiri Olsa 		.check = test__group_gh1,
1625615b8f99SAlexander Yarygin 		.id    = 34,
16265a30a99fSJiri Olsa 	},
1627615b8f99SAlexander Yarygin 	{
16285a30a99fSJiri Olsa 		.name  = "{cycles,cache-misses:H}:G",
16295a30a99fSJiri Olsa 		.check = test__group_gh2,
1630615b8f99SAlexander Yarygin 		.id    = 35,
16315a30a99fSJiri Olsa 	},
1632615b8f99SAlexander Yarygin 	{
16335a30a99fSJiri Olsa 		.name  = "{cycles:G,cache-misses:H}:u",
16345a30a99fSJiri Olsa 		.check = test__group_gh3,
1635615b8f99SAlexander Yarygin 		.id    = 36,
16365a30a99fSJiri Olsa 	},
1637615b8f99SAlexander Yarygin 	{
16385a30a99fSJiri Olsa 		.name  = "{cycles:G,cache-misses:H}:uG",
16395a30a99fSJiri Olsa 		.check = test__group_gh4,
1640615b8f99SAlexander Yarygin 		.id    = 37,
16415a30a99fSJiri Olsa 	},
1642615b8f99SAlexander Yarygin 	{
1643a9f93f97SJiri Olsa 		.name  = "{cycles,cache-misses,branch-misses}:S",
1644a9f93f97SJiri Olsa 		.check = test__leader_sample1,
1645615b8f99SAlexander Yarygin 		.id    = 38,
1646a9f93f97SJiri Olsa 	},
1647615b8f99SAlexander Yarygin 	{
1648a9f93f97SJiri Olsa 		.name  = "{instructions,branch-misses}:Su",
1649a9f93f97SJiri Olsa 		.check = test__leader_sample2,
1650615b8f99SAlexander Yarygin 		.id    = 39,
1651a9f93f97SJiri Olsa 	},
1652615b8f99SAlexander Yarygin 	{
1653c9ee780fSMichael Ellerman 		.name  = "instructions:uDp",
1654c9ee780fSMichael Ellerman 		.check = test__checkevent_pinned_modifier,
1655615b8f99SAlexander Yarygin 		.id    = 40,
1656c9ee780fSMichael Ellerman 	},
1657615b8f99SAlexander Yarygin 	{
1658c9ee780fSMichael Ellerman 		.name  = "{cycles,cache-misses,branch-misses}:D",
1659c9ee780fSMichael Ellerman 		.check = test__pinned_group,
1660615b8f99SAlexander Yarygin 		.id    = 41,
1661c9ee780fSMichael Ellerman 	},
1662ec32398cSJacob Shin 	{
1663ec32398cSJacob Shin 		.name  = "mem:0/1",
1664ec32398cSJacob Shin 		.check = test__checkevent_breakpoint_len,
1665ec32398cSJacob Shin 		.id    = 42,
1666ec32398cSJacob Shin 	},
1667ec32398cSJacob Shin 	{
1668ec32398cSJacob Shin 		.name  = "mem:0/2:w",
1669ec32398cSJacob Shin 		.check = test__checkevent_breakpoint_len_w,
1670ec32398cSJacob Shin 		.id    = 43,
1671ec32398cSJacob Shin 	},
1672ec32398cSJacob Shin 	{
1673ec32398cSJacob Shin 		.name  = "mem:0/4:rw:u",
1674ec32398cSJacob Shin 		.check = test__checkevent_breakpoint_len_rw_modifier,
1675ec32398cSJacob Shin 		.id    = 44
1676ec32398cSJacob Shin 	},
1677c0bc8c6dSAlexander Yarygin #if defined(__s390x__)
1678c0bc8c6dSAlexander Yarygin 	{
1679c0bc8c6dSAlexander Yarygin 		.name  = "kvm-s390:kvm_s390_create_vm",
1680c0bc8c6dSAlexander Yarygin 		.check = test__checkevent_tracepoint,
168153fe307dSThomas Richter 		.valid = kvm_s390_create_vm_valid,
1682c0bc8c6dSAlexander Yarygin 		.id    = 100,
1683c0bc8c6dSAlexander Yarygin 	},
1684c0bc8c6dSAlexander Yarygin #endif
1685a1e12da4SJiri Olsa 	{
1686a1e12da4SJiri Olsa 		.name  = "instructions:I",
1687a1e12da4SJiri Olsa 		.check = test__checkevent_exclude_idle_modifier,
1688a1e12da4SJiri Olsa 		.id    = 45,
1689a1e12da4SJiri Olsa 	},
1690a1e12da4SJiri Olsa 	{
1691a1e12da4SJiri Olsa 		.name  = "instructions:kIG",
1692a1e12da4SJiri Olsa 		.check = test__checkevent_exclude_idle_modifier_1,
1693a1e12da4SJiri Olsa 		.id    = 46,
1694a1e12da4SJiri Olsa 	},
1695ddd83c97SJiri Olsa 	{
1696ddd83c97SJiri Olsa 		.name  = "task-clock:P,cycles",
1697ddd83c97SJiri Olsa 		.check = test__checkevent_precise_max_modifier,
1698ddd83c97SJiri Olsa 		.id    = 47,
1699ddd83c97SJiri Olsa 	},
170010bf358aSWang Nan 	{
170110bf358aSWang Nan 		.name  = "instructions/name=insn/",
170210bf358aSWang Nan 		.check = test__checkevent_config_symbol,
170310bf358aSWang Nan 		.id    = 48,
170410bf358aSWang Nan 	},
170510bf358aSWang Nan 	{
170610bf358aSWang Nan 		.name  = "r1234/name=rawpmu/",
170710bf358aSWang Nan 		.check = test__checkevent_config_raw,
170810bf358aSWang Nan 		.id    = 49,
170910bf358aSWang Nan 	},
171010bf358aSWang Nan 	{
171110bf358aSWang Nan 		.name  = "4:0x6530160/name=numpmu/",
171210bf358aSWang Nan 		.check = test__checkevent_config_num,
171310bf358aSWang Nan 		.id    = 50,
171410bf358aSWang Nan 	},
171543d0b978SWang Nan 	{
171643d0b978SWang Nan 		.name  = "L1-dcache-misses/name=cachepmu/",
171743d0b978SWang Nan 		.check = test__checkevent_config_cache,
171843d0b978SWang Nan 		.id    = 51,
171943d0b978SWang Nan 	},
1720b3f58c8dSArnaldo Carvalho de Melo 	{
1721b3f58c8dSArnaldo Carvalho de Melo 		.name  = "intel_pt//u",
172216ddcfbfSJiri Olsa 		.valid = test__intel_pt_valid,
1723b3f58c8dSArnaldo Carvalho de Melo 		.check = test__intel_pt,
1724b3f58c8dSArnaldo Carvalho de Melo 		.id    = 52,
1725b3f58c8dSArnaldo Carvalho de Melo 	},
172606dc5bf2SAlexey Budankov 	{
172706dc5bf2SAlexey Budankov 		.name  = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk",
172806dc5bf2SAlexey Budankov 		.check = test__checkevent_complex_name,
172906dc5bf2SAlexey Budankov 		.id    = 53
1730714a92d8SJiri Olsa 	},
1731714a92d8SJiri Olsa 	{
1732714a92d8SJiri Olsa 		.name  = "cycles//u",
1733714a92d8SJiri Olsa 		.check = test__sym_event_slash,
1734714a92d8SJiri Olsa 		.id    = 54,
1735714a92d8SJiri Olsa 	},
1736714a92d8SJiri Olsa 	{
1737714a92d8SJiri Olsa 		.name  = "cycles:k",
1738714a92d8SJiri Olsa 		.check = test__sym_event_dc,
1739714a92d8SJiri Olsa 		.id    = 55,
174006dc5bf2SAlexey Budankov 	}
1741945aea22SJiri Olsa };
1742945aea22SJiri Olsa 
174323b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events_pmu[] = {
1744615b8f99SAlexander Yarygin 	{
1745945aea22SJiri Olsa 		.name  = "cpu/config=10,config1,config2=3,period=1000/u",
1746945aea22SJiri Olsa 		.check = test__checkevent_pmu,
1747615b8f99SAlexander Yarygin 		.id    = 0,
1748945aea22SJiri Olsa 	},
1749615b8f99SAlexander Yarygin 	{
1750945aea22SJiri Olsa 		.name  = "cpu/config=1,name=krava/u,cpu/config=2/u",
1751945aea22SJiri Olsa 		.check = test__checkevent_pmu_name,
1752615b8f99SAlexander Yarygin 		.id    = 1,
1753945aea22SJiri Olsa 	},
175471ef150eSKan Liang 	{
175571ef150eSKan Liang 		.name  = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
175671ef150eSKan Liang 		.check = test__checkevent_pmu_partial_time_callgraph,
175771ef150eSKan Liang 		.id    = 2,
175871ef150eSKan Liang 	},
175906dc5bf2SAlexey Budankov 	{
1760a6f39cecSSandipan Das 		.name  = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
176106dc5bf2SAlexey Budankov 		.check = test__checkevent_complex_name,
176206dc5bf2SAlexey Budankov 		.id    = 3,
17633a6c51e4SJiri Olsa 	},
17643a6c51e4SJiri Olsa 	{
17653a6c51e4SJiri Olsa 		.name  = "software/r1a/",
17663a6c51e4SJiri Olsa 		.check = test__checkevent_raw_pmu,
17673a6c51e4SJiri Olsa 		.id    = 4,
17683a6c51e4SJiri Olsa 	},
1769945aea22SJiri Olsa };
1770945aea22SJiri Olsa 
177123b6339bSArnaldo Carvalho de Melo struct terms_test {
1772945aea22SJiri Olsa 	const char *str;
1773945aea22SJiri Olsa 	__u32 type;
1774945aea22SJiri Olsa 	int (*check)(struct list_head *terms);
1775945aea22SJiri Olsa };
1776945aea22SJiri Olsa 
177723b6339bSArnaldo Carvalho de Melo static struct terms_test test__terms[] = {
1778945aea22SJiri Olsa 	[0] = {
1779945aea22SJiri Olsa 		.str   = "config=10,config1,config2=3,umask=1",
1780945aea22SJiri Olsa 		.check = test__checkterms_simple,
1781945aea22SJiri Olsa 	},
1782945aea22SJiri Olsa };
1783945aea22SJiri Olsa 
178423b6339bSArnaldo Carvalho de Melo static int test_event(struct evlist_test *e)
1785945aea22SJiri Olsa {
1786a910e466SIan Rogers 	struct parse_events_error err;
178763503dbaSJiri Olsa 	struct evlist *evlist;
1788945aea22SJiri Olsa 	int ret;
1789945aea22SJiri Olsa 
1790a910e466SIan Rogers 	bzero(&err, sizeof(err));
179116ddcfbfSJiri Olsa 	if (e->valid && !e->valid()) {
179216ddcfbfSJiri Olsa 		pr_debug("... SKIP");
179316ddcfbfSJiri Olsa 		return 0;
179416ddcfbfSJiri Olsa 	}
179516ddcfbfSJiri Olsa 
17960f98b11cSJiri Olsa 	evlist = evlist__new();
1797945aea22SJiri Olsa 	if (evlist == NULL)
1798945aea22SJiri Olsa 		return -ENOMEM;
1799945aea22SJiri Olsa 
1800933ccf20SJiri Olsa 	ret = parse_events(evlist, e->name, &err);
1801945aea22SJiri Olsa 	if (ret) {
1802933ccf20SJiri Olsa 		pr_debug("failed to parse event '%s', err %d, str '%s'\n",
1803933ccf20SJiri Olsa 			 e->name, ret, err.str);
1804933ccf20SJiri Olsa 		parse_events_print_error(&err, e->name);
18052d4352c0SArnaldo Carvalho de Melo 	} else {
18062d4352c0SArnaldo Carvalho de Melo 		ret = e->check(evlist);
1807945aea22SJiri Olsa 	}
1808945aea22SJiri Olsa 
1809c12995a5SJiri Olsa 	evlist__delete(evlist);
1810945aea22SJiri Olsa 
1811945aea22SJiri Olsa 	return ret;
1812945aea22SJiri Olsa }
1813945aea22SJiri Olsa 
181423b6339bSArnaldo Carvalho de Melo static int test_events(struct evlist_test *events, unsigned cnt)
1815945aea22SJiri Olsa {
1816945aea22SJiri Olsa 	int ret1, ret2 = 0;
1817945aea22SJiri Olsa 	unsigned i;
1818945aea22SJiri Olsa 
1819945aea22SJiri Olsa 	for (i = 0; i < cnt; i++) {
182023b6339bSArnaldo Carvalho de Melo 		struct evlist_test *e = &events[i];
1821945aea22SJiri Olsa 
182216ddcfbfSJiri Olsa 		pr_debug("running test %d '%s'", e->id, e->name);
1823945aea22SJiri Olsa 		ret1 = test_event(e);
1824945aea22SJiri Olsa 		if (ret1)
1825945aea22SJiri Olsa 			ret2 = ret1;
182616ddcfbfSJiri Olsa 		pr_debug("\n");
1827945aea22SJiri Olsa 	}
1828945aea22SJiri Olsa 
1829945aea22SJiri Olsa 	return ret2;
1830945aea22SJiri Olsa }
1831945aea22SJiri Olsa 
183223b6339bSArnaldo Carvalho de Melo static int test_term(struct terms_test *t)
1833945aea22SJiri Olsa {
1834c549aca5SDavid Ahern 	struct list_head terms;
1835945aea22SJiri Olsa 	int ret;
1836945aea22SJiri Olsa 
1837c549aca5SDavid Ahern 	INIT_LIST_HEAD(&terms);
1838945aea22SJiri Olsa 
1839c549aca5SDavid Ahern 	ret = parse_events_terms(&terms, t->str);
1840945aea22SJiri Olsa 	if (ret) {
1841945aea22SJiri Olsa 		pr_debug("failed to parse terms '%s', err %d\n",
1842945aea22SJiri Olsa 			 t->str , ret);
1843945aea22SJiri Olsa 		return ret;
1844945aea22SJiri Olsa 	}
1845945aea22SJiri Olsa 
1846c549aca5SDavid Ahern 	ret = t->check(&terms);
1847682dc24cSArnaldo Carvalho de Melo 	parse_events_terms__purge(&terms);
1848945aea22SJiri Olsa 
1849945aea22SJiri Olsa 	return ret;
1850945aea22SJiri Olsa }
1851945aea22SJiri Olsa 
185223b6339bSArnaldo Carvalho de Melo static int test_terms(struct terms_test *terms, unsigned cnt)
1853945aea22SJiri Olsa {
1854945aea22SJiri Olsa 	int ret = 0;
1855945aea22SJiri Olsa 	unsigned i;
1856945aea22SJiri Olsa 
1857945aea22SJiri Olsa 	for (i = 0; i < cnt; i++) {
185823b6339bSArnaldo Carvalho de Melo 		struct terms_test *t = &terms[i];
1859945aea22SJiri Olsa 
1860945aea22SJiri Olsa 		pr_debug("running test %d '%s'\n", i, t->str);
1861945aea22SJiri Olsa 		ret = test_term(t);
1862945aea22SJiri Olsa 		if (ret)
1863945aea22SJiri Olsa 			break;
1864945aea22SJiri Olsa 	}
1865945aea22SJiri Olsa 
1866945aea22SJiri Olsa 	return ret;
1867945aea22SJiri Olsa }
1868945aea22SJiri Olsa 
1869945aea22SJiri Olsa static int test_pmu(void)
1870945aea22SJiri Olsa {
1871945aea22SJiri Olsa 	struct stat st;
1872945aea22SJiri Olsa 	char path[PATH_MAX];
1873945aea22SJiri Olsa 	int ret;
1874945aea22SJiri Olsa 
1875945aea22SJiri Olsa 	snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
1876cf38fadaSArnaldo Carvalho de Melo 		 sysfs__mountpoint());
1877945aea22SJiri Olsa 
1878945aea22SJiri Olsa 	ret = stat(path, &st);
1879945aea22SJiri Olsa 	if (ret)
1880945aea22SJiri Olsa 		pr_debug("omitting PMU cpu tests\n");
1881945aea22SJiri Olsa 	return !ret;
1882945aea22SJiri Olsa }
1883945aea22SJiri Olsa 
1884945aea22SJiri Olsa static int test_pmu_events(void)
1885945aea22SJiri Olsa {
1886945aea22SJiri Olsa 	struct stat st;
1887945aea22SJiri Olsa 	char path[PATH_MAX];
1888945aea22SJiri Olsa 	struct dirent *ent;
1889945aea22SJiri Olsa 	DIR *dir;
1890945aea22SJiri Olsa 	int ret;
1891945aea22SJiri Olsa 
1892945aea22SJiri Olsa 	snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
1893cf38fadaSArnaldo Carvalho de Melo 		 sysfs__mountpoint());
1894945aea22SJiri Olsa 
1895945aea22SJiri Olsa 	ret = stat(path, &st);
1896945aea22SJiri Olsa 	if (ret) {
1897a895d57dSMasanari Iida 		pr_debug("omitting PMU cpu events tests\n");
1898945aea22SJiri Olsa 		return 0;
1899945aea22SJiri Olsa 	}
1900945aea22SJiri Olsa 
1901945aea22SJiri Olsa 	dir = opendir(path);
1902945aea22SJiri Olsa 	if (!dir) {
1903945aea22SJiri Olsa 		pr_debug("can't open pmu event dir");
1904945aea22SJiri Olsa 		return -1;
1905945aea22SJiri Olsa 	}
1906945aea22SJiri Olsa 
1907945aea22SJiri Olsa 	while (!ret && (ent = readdir(dir))) {
190816ddcfbfSJiri Olsa 		struct evlist_test e = { .id = 0, };
19092e2bbc03SArnaldo Carvalho de Melo 		char name[2 * NAME_MAX + 1 + 12 + 3];
1910945aea22SJiri Olsa 
191117a2634bSAndi Kleen 		/* Names containing . are special and cannot be used directly */
191217a2634bSAndi Kleen 		if (strchr(ent->d_name, '.'))
1913945aea22SJiri Olsa 			continue;
1914945aea22SJiri Olsa 
19152e2bbc03SArnaldo Carvalho de Melo 		snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
1916945aea22SJiri Olsa 
1917945aea22SJiri Olsa 		e.name  = name;
1918945aea22SJiri Olsa 		e.check = test__checkevent_pmu_events;
1919945aea22SJiri Olsa 
1920945aea22SJiri Olsa 		ret = test_event(&e);
1921ffe59788SKan Liang 		if (ret)
1922ffe59788SKan Liang 			break;
19232e2bbc03SArnaldo Carvalho de Melo 		snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
1924ffe59788SKan Liang 		e.name  = name;
1925ffe59788SKan Liang 		e.check = test__checkevent_pmu_events_mix;
1926ffe59788SKan Liang 		ret = test_event(&e);
1927945aea22SJiri Olsa 	}
1928945aea22SJiri Olsa 
1929945aea22SJiri Olsa 	closedir(dir);
1930945aea22SJiri Olsa 	return ret;
1931945aea22SJiri Olsa }
1932945aea22SJiri Olsa 
193381f17c90SArnaldo Carvalho de Melo int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
1934945aea22SJiri Olsa {
1935945aea22SJiri Olsa 	int ret1, ret2 = 0;
1936945aea22SJiri Olsa 
1937945aea22SJiri Olsa #define TEST_EVENTS(tests)				\
1938945aea22SJiri Olsa do {							\
1939945aea22SJiri Olsa 	ret1 = test_events(tests, ARRAY_SIZE(tests));	\
1940945aea22SJiri Olsa 	if (!ret2)					\
1941945aea22SJiri Olsa 		ret2 = ret1;				\
1942945aea22SJiri Olsa } while (0)
1943945aea22SJiri Olsa 
1944945aea22SJiri Olsa 	TEST_EVENTS(test__events);
1945945aea22SJiri Olsa 
1946945aea22SJiri Olsa 	if (test_pmu())
1947945aea22SJiri Olsa 		TEST_EVENTS(test__events_pmu);
1948945aea22SJiri Olsa 
1949945aea22SJiri Olsa 	if (test_pmu()) {
1950945aea22SJiri Olsa 		int ret = test_pmu_events();
1951945aea22SJiri Olsa 		if (ret)
1952945aea22SJiri Olsa 			return ret;
1953945aea22SJiri Olsa 	}
1954945aea22SJiri Olsa 
1955945aea22SJiri Olsa 	ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));
1956945aea22SJiri Olsa 	if (!ret2)
1957945aea22SJiri Olsa 		ret2 = ret1;
1958945aea22SJiri Olsa 
1959945aea22SJiri Olsa 	return ret2;
1960945aea22SJiri Olsa }
1961