blob: 895188b63f9635b2c32ac2f241a9e14aa6aa3c92 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Jiri Olsaf50246e2012-05-21 09:12:49 +02002#include "parse-events.h"
3#include "evsel.h"
4#include "evlist.h"
Borislav Petkovcd0cfad2013-12-09 17:14:24 +01005#include <api/fs/fs.h>
Jiri Olsac81251e2012-11-10 01:46:51 +01006#include "tests.h"
Jiri Olsa84f5d362014-07-14 23:46:48 +02007#include "debug.h"
Arnaldo Carvalho de Melof2a39fe2019-08-30 14:45:20 -03008#include "pmu.h"
Arnaldo Carvalho de Melo76b31a22017-04-18 12:26:44 -03009#include <dirent.h>
Arnaldo Carvalho de Meloa43783a2017-04-18 10:46:11 -030010#include <errno.h>
Arnaldo Carvalho de Melo7a8ef4c2017-04-19 20:57:47 -030011#include <sys/types.h>
12#include <sys/stat.h>
13#include <unistd.h>
Arnaldo Carvalho de Melo877a7a12017-04-17 11:39:06 -030014#include <linux/kernel.h>
David Howellsd2709c72012-11-19 22:21:03 +000015#include <linux/hw_breakpoint.h>
Arnaldo Carvalho de Melo20a9ed22017-04-18 11:44:58 -030016#include <api/fs/tracing_path.h>
Jiri Olsaf50246e2012-05-21 09:12:49 +020017
Jiri Olsa30f31c02012-08-01 14:48:58 +020018#define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
19 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
20
Thomas Richter53fe3072019-06-04 07:35:04 +020021#if defined(__s390x__)
22/* Return true if kvm module is available and loaded. Test this
23 * and retun success when trace point kvm_s390_create_vm
24 * exists. Otherwise this test always fails.
25 */
26static bool kvm_s390_create_vm_valid(void)
27{
28 char *eventfile;
29 bool rc = false;
30
31 eventfile = get_events_file("kvm-s390");
32
33 if (eventfile) {
34 DIR *mydir = opendir(eventfile);
35
36 if (mydir) {
37 rc = true;
38 closedir(mydir);
39 }
40 put_events_file(eventfile);
41 }
42
43 return rc;
44}
45#endif
46
Jiri Olsa63503db2019-07-21 13:23:52 +020047static int test__checkevent_tracepoint(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +020048{
Jiri Olsa515dbe42019-09-03 10:39:52 +020049 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +020050
Jiri Olsa6484d2f2019-07-21 13:24:28 +020051 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Namhyung Kim8d7d8472013-01-22 18:09:30 +090052 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
Jiri Olsa1fc632c2019-07-21 13:24:29 +020053 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
Jiri Olsaf50246e2012-05-21 09:12:49 +020054 TEST_ASSERT_VAL("wrong sample_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +020055 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
56 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
Jiri Olsaf50246e2012-05-21 09:12:49 +020057 return 0;
58}
59
Jiri Olsa63503db2019-07-21 13:23:52 +020060static int test__checkevent_tracepoint_multi(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +020061{
Jiri Olsa32dcd022019-07-21 13:23:51 +020062 struct evsel *evsel;
Jiri Olsaf50246e2012-05-21 09:12:49 +020063
Jiri Olsa6484d2f2019-07-21 13:24:28 +020064 TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
Namhyung Kim8d7d8472013-01-22 18:09:30 +090065 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
Jiri Olsaf50246e2012-05-21 09:12:49 +020066
Arnaldo Carvalho de Meloe5cadb92016-06-23 11:26:15 -030067 evlist__for_each_entry(evlist, evsel) {
Jiri Olsaf50246e2012-05-21 09:12:49 +020068 TEST_ASSERT_VAL("wrong type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +020069 PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
Jiri Olsaf50246e2012-05-21 09:12:49 +020070 TEST_ASSERT_VAL("wrong sample_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +020071 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
Jiri Olsaf50246e2012-05-21 09:12:49 +020072 TEST_ASSERT_VAL("wrong sample_period",
Jiri Olsa1fc632c2019-07-21 13:24:29 +020073 1 == evsel->core.attr.sample_period);
Jiri Olsaf50246e2012-05-21 09:12:49 +020074 }
75 return 0;
76}
77
Jiri Olsa63503db2019-07-21 13:23:52 +020078static int test__checkevent_raw(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +020079{
Jiri Olsa515dbe42019-09-03 10:39:52 +020080 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +020081
Jiri Olsa6484d2f2019-07-21 13:24:28 +020082 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +020083 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
84 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +020085 return 0;
86}
87
Jiri Olsa63503db2019-07-21 13:23:52 +020088static int test__checkevent_numeric(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +020089{
Jiri Olsa515dbe42019-09-03 10:39:52 +020090 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +020091
Jiri Olsa6484d2f2019-07-21 13:24:28 +020092 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +020093 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
94 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +020095 return 0;
96}
97
Jiri Olsa63503db2019-07-21 13:23:52 +020098static int test__checkevent_symbolic_name(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +020099{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200100 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200101
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200102 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200103 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200104 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200105 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200106 return 0;
107}
108
Jiri Olsa63503db2019-07-21 13:23:52 +0200109static int test__checkevent_symbolic_name_config(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200110{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200111 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200112
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200113 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200114 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200115 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200116 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
Jiri Olsaee4c7582015-07-29 05:42:11 -0400117 /*
118 * The period value gets configured within perf_evlist__config,
119 * while this test executes only parse events method.
120 */
Jiri Olsaf50246e2012-05-21 09:12:49 +0200121 TEST_ASSERT_VAL("wrong period",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200122 0 == evsel->core.attr.sample_period);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200123 TEST_ASSERT_VAL("wrong config1",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200124 0 == evsel->core.attr.config1);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200125 TEST_ASSERT_VAL("wrong config2",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200126 1 == evsel->core.attr.config2);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200127 return 0;
128}
129
Jiri Olsa63503db2019-07-21 13:23:52 +0200130static int test__checkevent_symbolic_alias(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200131{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200132 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200133
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200134 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200135 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200136 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200137 PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200138 return 0;
139}
140
Jiri Olsa63503db2019-07-21 13:23:52 +0200141static int test__checkevent_genhw(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200142{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200143 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200144
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200145 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200146 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
147 TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200148 return 0;
149}
150
Jiri Olsa63503db2019-07-21 13:23:52 +0200151static int test__checkevent_breakpoint(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200152{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200153 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200154
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200155 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200156 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
157 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200158 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200159 evsel->core.attr.bp_type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200160 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200161 evsel->core.attr.bp_len);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200162 return 0;
163}
164
Jiri Olsa63503db2019-07-21 13:23:52 +0200165static int test__checkevent_breakpoint_x(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200166{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200167 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200168
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200169 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200170 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
171 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200172 TEST_ASSERT_VAL("wrong bp_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200173 HW_BREAKPOINT_X == evsel->core.attr.bp_type);
174 TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->core.attr.bp_len);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200175 return 0;
176}
177
Jiri Olsa63503db2019-07-21 13:23:52 +0200178static int test__checkevent_breakpoint_r(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200179{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200180 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200181
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200182 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200183 TEST_ASSERT_VAL("wrong type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200184 PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
185 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200186 TEST_ASSERT_VAL("wrong bp_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200187 HW_BREAKPOINT_R == evsel->core.attr.bp_type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200188 TEST_ASSERT_VAL("wrong bp_len",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200189 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200190 return 0;
191}
192
Jiri Olsa63503db2019-07-21 13:23:52 +0200193static int test__checkevent_breakpoint_w(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200194{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200195 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200196
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200197 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200198 TEST_ASSERT_VAL("wrong type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200199 PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
200 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200201 TEST_ASSERT_VAL("wrong bp_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200202 HW_BREAKPOINT_W == evsel->core.attr.bp_type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200203 TEST_ASSERT_VAL("wrong bp_len",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200204 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200205 return 0;
206}
207
Jiri Olsa63503db2019-07-21 13:23:52 +0200208static int test__checkevent_breakpoint_rw(struct evlist *evlist)
Jiri Olsa75827322012-06-29 09:22:54 +0200209{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200210 struct evsel *evsel = evlist__first(evlist);
Jiri Olsa75827322012-06-29 09:22:54 +0200211
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200212 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa75827322012-06-29 09:22:54 +0200213 TEST_ASSERT_VAL("wrong type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200214 PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
215 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jiri Olsa75827322012-06-29 09:22:54 +0200216 TEST_ASSERT_VAL("wrong bp_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200217 (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->core.attr.bp_type);
Jiri Olsa75827322012-06-29 09:22:54 +0200218 TEST_ASSERT_VAL("wrong bp_len",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200219 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
Jiri Olsa75827322012-06-29 09:22:54 +0200220 return 0;
221}
222
Jiri Olsa63503db2019-07-21 13:23:52 +0200223static int test__checkevent_tracepoint_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200224{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200225 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200226
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200227 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
228 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
229 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
230 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200231
232 return test__checkevent_tracepoint(evlist);
233}
234
235static int
Jiri Olsa63503db2019-07-21 13:23:52 +0200236test__checkevent_tracepoint_multi_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200237{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200238 struct evsel *evsel;
Jiri Olsaf50246e2012-05-21 09:12:49 +0200239
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200240 TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200241
Arnaldo Carvalho de Meloe5cadb92016-06-23 11:26:15 -0300242 evlist__for_each_entry(evlist, evsel) {
Jiri Olsaf50246e2012-05-21 09:12:49 +0200243 TEST_ASSERT_VAL("wrong exclude_user",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200244 !evsel->core.attr.exclude_user);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200245 TEST_ASSERT_VAL("wrong exclude_kernel",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200246 evsel->core.attr.exclude_kernel);
247 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
248 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200249 }
250
251 return test__checkevent_tracepoint_multi(evlist);
252}
253
Jiri Olsa63503db2019-07-21 13:23:52 +0200254static int test__checkevent_raw_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200255{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200256 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200257
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200258 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
259 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
260 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
261 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200262
263 return test__checkevent_raw(evlist);
264}
265
Jiri Olsa63503db2019-07-21 13:23:52 +0200266static int test__checkevent_numeric_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200267{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200268 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200269
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200270 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
271 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
272 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
273 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200274
275 return test__checkevent_numeric(evlist);
276}
277
Jiri Olsa63503db2019-07-21 13:23:52 +0200278static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200279{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200280 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200281
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200282 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
283 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
284 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
285 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200286
287 return test__checkevent_symbolic_name(evlist);
288}
289
Jiri Olsa63503db2019-07-21 13:23:52 +0200290static int test__checkevent_exclude_host_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200291{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200292 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200293
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200294 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
295 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200296
297 return test__checkevent_symbolic_name(evlist);
298}
299
Jiri Olsa63503db2019-07-21 13:23:52 +0200300static int test__checkevent_exclude_guest_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200301{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200302 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200303
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200304 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
305 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200306
307 return test__checkevent_symbolic_name(evlist);
308}
309
Jiri Olsa63503db2019-07-21 13:23:52 +0200310static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200311{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200312 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200313
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200314 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
315 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
316 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
317 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200318
319 return test__checkevent_symbolic_alias(evlist);
320}
321
Jiri Olsa63503db2019-07-21 13:23:52 +0200322static int test__checkevent_genhw_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200323{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200324 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200325
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200326 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
327 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
328 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
329 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200330
331 return test__checkevent_genhw(evlist);
332}
333
Jiri Olsa63503db2019-07-21 13:23:52 +0200334static int test__checkevent_exclude_idle_modifier(struct evlist *evlist)
Jiri Olsaa1e12da2015-04-07 23:25:14 +0200335{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200336 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaa1e12da2015-04-07 23:25:14 +0200337
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200338 TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
339 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
340 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
341 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
342 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
343 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
344 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa1e12da2015-04-07 23:25:14 +0200345
346 return test__checkevent_symbolic_name(evlist);
347}
348
Jiri Olsa63503db2019-07-21 13:23:52 +0200349static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist)
Jiri Olsaa1e12da2015-04-07 23:25:14 +0200350{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200351 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaa1e12da2015-04-07 23:25:14 +0200352
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200353 TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
354 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
355 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
356 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
357 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
358 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
359 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa1e12da2015-04-07 23:25:14 +0200360
361 return test__checkevent_symbolic_name(evlist);
362}
363
Jiri Olsa63503db2019-07-21 13:23:52 +0200364static int test__checkevent_breakpoint_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200365{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200366 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200367
Jiri Olsaf50246e2012-05-21 09:12:49 +0200368
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200369 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
370 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
371 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
372 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa287e74a2012-06-28 23:18:49 +0200373 TEST_ASSERT_VAL("wrong name",
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300374 !strcmp(evsel__name(evsel), "mem:0:u"));
Jiri Olsaf50246e2012-05-21 09:12:49 +0200375
376 return test__checkevent_breakpoint(evlist);
377}
378
Jiri Olsa63503db2019-07-21 13:23:52 +0200379static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200380{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200381 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200382
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200383 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
384 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
385 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
386 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa287e74a2012-06-28 23:18:49 +0200387 TEST_ASSERT_VAL("wrong name",
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300388 !strcmp(evsel__name(evsel), "mem:0:x:k"));
Jiri Olsaf50246e2012-05-21 09:12:49 +0200389
390 return test__checkevent_breakpoint_x(evlist);
391}
392
Jiri Olsa63503db2019-07-21 13:23:52 +0200393static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200394{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200395 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200396
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200397 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
398 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
399 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
400 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsa287e74a2012-06-28 23:18:49 +0200401 TEST_ASSERT_VAL("wrong name",
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300402 !strcmp(evsel__name(evsel), "mem:0:r:hp"));
Jiri Olsaf50246e2012-05-21 09:12:49 +0200403
404 return test__checkevent_breakpoint_r(evlist);
405}
406
Jiri Olsa63503db2019-07-21 13:23:52 +0200407static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200408{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200409 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200410
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200411 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
412 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
413 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
414 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsa287e74a2012-06-28 23:18:49 +0200415 TEST_ASSERT_VAL("wrong name",
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300416 !strcmp(evsel__name(evsel), "mem:0:w:up"));
Jiri Olsaf50246e2012-05-21 09:12:49 +0200417
418 return test__checkevent_breakpoint_w(evlist);
419}
420
Jiri Olsa63503db2019-07-21 13:23:52 +0200421static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist)
Jiri Olsa75827322012-06-29 09:22:54 +0200422{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200423 struct evsel *evsel = evlist__first(evlist);
Jiri Olsa75827322012-06-29 09:22:54 +0200424
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200425 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
426 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
427 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
428 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsa287e74a2012-06-28 23:18:49 +0200429 TEST_ASSERT_VAL("wrong name",
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300430 !strcmp(evsel__name(evsel), "mem:0:rw:kp"));
Jiri Olsa75827322012-06-29 09:22:54 +0200431
432 return test__checkevent_breakpoint_rw(evlist);
433}
434
Jiri Olsa63503db2019-07-21 13:23:52 +0200435static int test__checkevent_pmu(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200436{
437
Jiri Olsa515dbe42019-09-03 10:39:52 +0200438 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200439
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200440 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200441 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
442 TEST_ASSERT_VAL("wrong config", 10 == evsel->core.attr.config);
443 TEST_ASSERT_VAL("wrong config1", 1 == evsel->core.attr.config1);
444 TEST_ASSERT_VAL("wrong config2", 3 == evsel->core.attr.config2);
Jiri Olsaee4c7582015-07-29 05:42:11 -0400445 /*
446 * The period value gets configured within perf_evlist__config,
447 * while this test executes only parse events method.
448 */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200449 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200450
451 return 0;
452}
453
Jiri Olsa63503db2019-07-21 13:23:52 +0200454static int test__checkevent_list(struct evlist *evlist)
Jiri Olsaf50246e2012-05-21 09:12:49 +0200455{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200456 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200457
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200458 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200459
460 /* r1 */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200461 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
462 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
463 TEST_ASSERT_VAL("wrong config1", 0 == evsel->core.attr.config1);
464 TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
465 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
466 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
467 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
468 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200469
Riku Voipio43f322b2015-04-16 16:52:53 +0300470 /* syscalls:sys_enter_openat:k */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300471 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200472 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200473 TEST_ASSERT_VAL("wrong sample_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200474 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
475 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
476 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
477 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
478 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
479 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200480
481 /* 1:1:hp */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300482 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200483 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
484 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
485 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
486 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
487 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
488 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
Jiri Olsaf50246e2012-05-21 09:12:49 +0200489
490 return 0;
491}
492
Jiri Olsa63503db2019-07-21 13:23:52 +0200493static int test__checkevent_pmu_name(struct evlist *evlist)
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200494{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200495 struct evsel *evsel = evlist__first(evlist);
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200496
Jiri Olsa7a25b2d2012-06-21 12:25:16 +0200497 /* cpu/config=1,name=krava/u */
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200498 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200499 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
500 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300501 TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "krava"));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200502
Jiri Olsa7a25b2d2012-06-21 12:25:16 +0200503 /* cpu/config=2/u" */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300504 evsel = evsel__next(evsel);
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200505 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200506 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
507 TEST_ASSERT_VAL("wrong config", 2 == evsel->core.attr.config);
Jiri Olsa7a25b2d2012-06-21 12:25:16 +0200508 TEST_ASSERT_VAL("wrong name",
Arnaldo Carvalho de Melo8ab2e962020-04-29 16:07:09 -0300509 !strcmp(evsel__name(evsel), "cpu/config=2/u"));
Jiri Olsa6b5fc392012-05-21 09:12:53 +0200510
511 return 0;
512}
513
Jiri Olsa63503db2019-07-21 13:23:52 +0200514static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
Kan Liang71ef1502015-08-11 06:30:50 -0400515{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200516 struct evsel *evsel = evlist__first(evlist);
Kan Liang71ef1502015-08-11 06:30:50 -0400517
518 /* cpu/config=1,call-graph=fp,time,period=100000/ */
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200519 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200520 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
521 TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
Kan Liang71ef1502015-08-11 06:30:50 -0400522 /*
523 * The period, time and callgraph value gets configured
524 * within perf_evlist__config,
525 * while this test executes only parse events method.
526 */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200527 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
Arnaldo Carvalho de Melo27de9b22018-05-28 16:00:29 -0300528 TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200529 TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
Kan Liang71ef1502015-08-11 06:30:50 -0400530
531 /* cpu/config=2,call-graph=no,time=0,period=2000/ */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300532 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200533 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
534 TEST_ASSERT_VAL("wrong config", 2 == evsel->core.attr.config);
Kan Liang71ef1502015-08-11 06:30:50 -0400535 /*
536 * The period, time and callgraph value gets configured
537 * within perf_evlist__config,
538 * while this test executes only parse events method.
539 */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200540 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
Arnaldo Carvalho de Melo27de9b22018-05-28 16:00:29 -0300541 TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200542 TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
Kan Liang71ef1502015-08-11 06:30:50 -0400543
544 return 0;
545}
546
Jiri Olsa63503db2019-07-21 13:23:52 +0200547static int test__checkevent_pmu_events(struct evlist *evlist)
Jiri Olsa3f3a2062012-10-10 14:53:18 +0200548{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200549 struct evsel *evsel = evlist__first(evlist);
Jiri Olsa3f3a2062012-10-10 14:53:18 +0200550
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200551 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200552 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
Jiri Olsa3f3a2062012-10-10 14:53:18 +0200553 TEST_ASSERT_VAL("wrong exclude_user",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200554 !evsel->core.attr.exclude_user);
Jiri Olsa3f3a2062012-10-10 14:53:18 +0200555 TEST_ASSERT_VAL("wrong exclude_kernel",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200556 evsel->core.attr.exclude_kernel);
557 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
558 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
559 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
Jiri Olsa3f3a2062012-10-10 14:53:18 +0200560
561 return 0;
562}
563
Kan Liangffe59782014-10-07 11:08:52 -0400564
Jiri Olsa63503db2019-07-21 13:23:52 +0200565static int test__checkevent_pmu_events_mix(struct evlist *evlist)
Kan Liangffe59782014-10-07 11:08:52 -0400566{
Jiri Olsa515dbe42019-09-03 10:39:52 +0200567 struct evsel *evsel = evlist__first(evlist);
Kan Liangffe59782014-10-07 11:08:52 -0400568
569 /* pmu-event:u */
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200570 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Kan Liangffe59782014-10-07 11:08:52 -0400571 TEST_ASSERT_VAL("wrong exclude_user",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200572 !evsel->core.attr.exclude_user);
Kan Liangffe59782014-10-07 11:08:52 -0400573 TEST_ASSERT_VAL("wrong exclude_kernel",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200574 evsel->core.attr.exclude_kernel);
575 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
576 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
577 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
Kan Liangffe59782014-10-07 11:08:52 -0400578
579 /* cpu/pmu-event/u*/
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300580 evsel = evsel__next(evsel);
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200581 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200582 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
Kan Liangffe59782014-10-07 11:08:52 -0400583 TEST_ASSERT_VAL("wrong exclude_user",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200584 !evsel->core.attr.exclude_user);
Kan Liangffe59782014-10-07 11:08:52 -0400585 TEST_ASSERT_VAL("wrong exclude_kernel",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200586 evsel->core.attr.exclude_kernel);
587 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
588 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
589 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
Kan Liangffe59782014-10-07 11:08:52 -0400590
591 return 0;
592}
593
Jiri Olsa44293922012-06-15 14:31:42 +0800594static int test__checkterms_simple(struct list_head *terms)
595{
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300596 struct parse_events_term *term;
Jiri Olsa44293922012-06-15 14:31:42 +0800597
598 /* config=10 */
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300599 term = list_entry(terms->next, struct parse_events_term, list);
Jiri Olsa44293922012-06-15 14:31:42 +0800600 TEST_ASSERT_VAL("wrong type term",
601 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
602 TEST_ASSERT_VAL("wrong type val",
603 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
604 TEST_ASSERT_VAL("wrong val", term->val.num == 10);
605 TEST_ASSERT_VAL("wrong config", !term->config);
606
607 /* config1 */
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300608 term = list_entry(term->list.next, struct parse_events_term, list);
Jiri Olsa44293922012-06-15 14:31:42 +0800609 TEST_ASSERT_VAL("wrong type term",
610 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
611 TEST_ASSERT_VAL("wrong type val",
612 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
613 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
614 TEST_ASSERT_VAL("wrong config", !term->config);
615
616 /* config2=3 */
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300617 term = list_entry(term->list.next, struct parse_events_term, list);
Jiri Olsa44293922012-06-15 14:31:42 +0800618 TEST_ASSERT_VAL("wrong type term",
619 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
620 TEST_ASSERT_VAL("wrong type val",
621 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
622 TEST_ASSERT_VAL("wrong val", term->val.num == 3);
623 TEST_ASSERT_VAL("wrong config", !term->config);
624
625 /* umask=1*/
Arnaldo Carvalho de Melo6cee6cd2013-01-18 16:29:49 -0300626 term = list_entry(term->list.next, struct parse_events_term, list);
Jiri Olsa44293922012-06-15 14:31:42 +0800627 TEST_ASSERT_VAL("wrong type term",
628 term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
629 TEST_ASSERT_VAL("wrong type val",
630 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
631 TEST_ASSERT_VAL("wrong val", term->val.num == 1);
632 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
633
634 return 0;
635}
636
Jiri Olsa63503db2019-07-21 13:23:52 +0200637static int test__group1(struct evlist *evlist)
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200638{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200639 struct evsel *evsel, *leader;
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200640
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200641 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Namhyung Kim8d7d8472013-01-22 18:09:30 +0900642 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200643
644 /* instructions:k */
Jiri Olsa515dbe42019-09-03 10:39:52 +0200645 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200646 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200647 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200648 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
649 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
650 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
651 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
652 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
653 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
654 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300655 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200656 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300657 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100658 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200659
660 /* cycles:upp */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300661 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200662 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200663 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200664 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
665 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
666 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
667 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
Jiri Olsa42be7392012-10-20 18:29:34 +0200668 /* use of precise requires exclude_guest */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200669 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
670 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
671 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200672 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300673 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100674 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200675
676 return 0;
677}
678
Jiri Olsa63503db2019-07-21 13:23:52 +0200679static int test__group2(struct evlist *evlist)
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200680{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200681 struct evsel *evsel, *leader;
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200682
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200683 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
Namhyung Kim8d7d8472013-01-22 18:09:30 +0900684 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200685
686 /* faults + :ku modifier */
Jiri Olsa515dbe42019-09-03 10:39:52 +0200687 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200688 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200689 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200690 PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
691 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
692 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
693 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
694 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
695 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
696 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300697 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200698 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300699 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100700 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200701
702 /* cache-references + :u modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300703 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200704 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200705 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200706 PERF_COUNT_HW_CACHE_REFERENCES == evsel->core.attr.config);
707 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
708 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
709 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
710 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
711 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
712 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200713 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300714 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100715 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200716
717 /* cycles:k */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300718 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200719 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200720 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200721 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
722 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
723 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
724 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
725 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
726 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
727 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300728 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100729 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200730
731 return 0;
732}
733
Jiri Olsa63503db2019-07-21 13:23:52 +0200734static int test__group3(struct evlist *evlist __maybe_unused)
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200735{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200736 struct evsel *evsel, *leader;
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200737
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200738 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
Namhyung Kim8d7d8472013-01-22 18:09:30 +0900739 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200740
Riku Voipio43f322b2015-04-16 16:52:53 +0300741 /* group1 syscalls:sys_enter_openat:H */
Jiri Olsa515dbe42019-09-03 10:39:52 +0200742 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200743 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200744 TEST_ASSERT_VAL("wrong sample_type",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200745 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
746 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
747 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
748 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
749 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
750 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
751 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
752 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300753 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200754 TEST_ASSERT_VAL("wrong group name",
755 !strcmp(leader->group_name, "group1"));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200756 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300757 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100758 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200759
760 /* group1 cycles:kppp */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300761 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200762 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200763 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200764 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
765 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
766 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
767 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
Jiri Olsa42be7392012-10-20 18:29:34 +0200768 /* use of precise requires exclude_guest */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200769 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
770 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
771 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 3);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200772 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
773 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300774 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100775 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200776
777 /* group2 cycles + G modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300778 evsel = leader = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200779 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200780 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200781 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
782 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
783 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
784 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
785 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
786 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
787 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300788 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200789 TEST_ASSERT_VAL("wrong group name",
790 !strcmp(leader->group_name, "group2"));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200791 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300792 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100793 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200794
795 /* group2 1:3 + G modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300796 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200797 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
798 TEST_ASSERT_VAL("wrong config", 3 == evsel->core.attr.config);
799 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
800 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
801 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
802 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
803 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
804 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200805 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300806 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100807 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200808
809 /* instructions:u */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300810 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200811 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200812 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200813 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
814 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
815 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
816 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
817 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
818 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
819 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300820 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100821 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200822
823 return 0;
824}
825
Jiri Olsa63503db2019-07-21 13:23:52 +0200826static int test__group4(struct evlist *evlist __maybe_unused)
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200827{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200828 struct evsel *evsel, *leader;
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200829
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200830 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Namhyung Kim8d7d8472013-01-22 18:09:30 +0900831 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200832
833 /* cycles:u + p */
Jiri Olsa515dbe42019-09-03 10:39:52 +0200834 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200835 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200836 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200837 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
838 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
839 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
840 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
Jiri Olsa42be7392012-10-20 18:29:34 +0200841 /* use of precise requires exclude_guest */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200842 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
843 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
844 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 1);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200845 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300846 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200847 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300848 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100849 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200850
851 /* instructions:kp + p */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300852 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200853 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200854 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200855 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
856 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
857 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
858 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
Jiri Olsa42be7392012-10-20 18:29:34 +0200859 /* use of precise requires exclude_guest */
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200860 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
861 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
862 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200863 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300864 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100865 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200866
867 return 0;
868}
869
Jiri Olsa63503db2019-07-21 13:23:52 +0200870static int test__group5(struct evlist *evlist __maybe_unused)
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200871{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200872 struct evsel *evsel, *leader;
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200873
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200874 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries);
Namhyung Kim8d7d8472013-01-22 18:09:30 +0900875 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200876
877 /* cycles + G */
Jiri Olsa515dbe42019-09-03 10:39:52 +0200878 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200879 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200880 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200881 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
882 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
883 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
884 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
885 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
886 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
887 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200888 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300889 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200890 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300891 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100892 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200893
894 /* instructions + G */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300895 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200896 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200897 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200898 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
899 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
900 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
901 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
902 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
903 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
904 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200905 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300906 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100907 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200908
909 /* cycles:G */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300910 evsel = leader = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200911 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200912 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200913 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
914 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
915 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
916 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
917 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
918 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
919 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200920 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300921 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200922 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300923 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsaa9f93f92013-02-01 20:37:11 +0100924 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200925
926 /* instructions:G */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300927 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200928 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200929 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200930 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
931 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
932 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
933 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
934 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
935 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
936 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200937 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300938 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200939
940 /* cycles */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300941 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200942 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200943 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200944 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
945 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
946 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
947 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
948 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
949 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
950 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300951 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa905f5ee2012-08-08 12:23:52 +0200952
953 return 0;
954}
955
Jiri Olsa63503db2019-07-21 13:23:52 +0200956static int test__group_gh1(struct evlist *evlist)
Jiri Olsa5a30a992013-02-04 10:56:43 +0100957{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200958 struct evsel *evsel, *leader;
Jiri Olsa5a30a992013-02-04 10:56:43 +0100959
Jiri Olsa6484d2f2019-07-21 13:24:28 +0200960 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100961 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
962
963 /* cycles + :H group modifier */
Jiri Olsa515dbe42019-09-03 10:39:52 +0200964 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200965 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100966 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200967 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
968 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
969 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
970 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
971 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
972 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
973 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100974 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -0300975 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +0200976 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300977 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100978
979 /* cache-misses:G + :H group modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -0300980 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200981 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100982 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +0200983 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
984 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
985 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
986 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
987 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
988 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
989 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100990 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -0300991 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsa5a30a992013-02-04 10:56:43 +0100992
993 return 0;
994}
995
Jiri Olsa63503db2019-07-21 13:23:52 +0200996static int test__group_gh2(struct evlist *evlist)
Jiri Olsa5a30a992013-02-04 10:56:43 +0100997{
Jiri Olsa32dcd022019-07-21 13:23:51 +0200998 struct evsel *evsel, *leader;
Jiri Olsa5a30a992013-02-04 10:56:43 +0100999
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001000 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001001 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
1002
1003 /* cycles + :G group modifier */
Jiri Olsa515dbe42019-09-03 10:39:52 +02001004 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001005 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001006 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001007 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1008 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1009 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1010 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1011 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1012 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
1013 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001014 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -03001015 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +02001016 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -03001017 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001018
1019 /* cache-misses:H + :G group modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001020 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001021 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001022 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001023 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1024 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1025 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1026 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1027 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1028 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1029 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001030 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -03001031 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001032
1033 return 0;
1034}
1035
Jiri Olsa63503db2019-07-21 13:23:52 +02001036static int test__group_gh3(struct evlist *evlist)
Jiri Olsa5a30a992013-02-04 10:56:43 +01001037{
Jiri Olsa32dcd022019-07-21 13:23:51 +02001038 struct evsel *evsel, *leader;
Jiri Olsa5a30a992013-02-04 10:56:43 +01001039
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001040 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001041 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
1042
1043 /* cycles:G + :u group modifier */
Jiri Olsa515dbe42019-09-03 10:39:52 +02001044 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001045 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001046 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001047 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1048 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1049 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1050 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1051 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1052 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
1053 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001054 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -03001055 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +02001056 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -03001057 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001058
1059 /* cache-misses:H + :u group modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001060 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001061 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001062 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001063 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1064 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1065 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1066 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1067 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1068 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1069 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001070 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -03001071 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001072
1073 return 0;
1074}
1075
Jiri Olsa63503db2019-07-21 13:23:52 +02001076static int test__group_gh4(struct evlist *evlist)
Jiri Olsa5a30a992013-02-04 10:56:43 +01001077{
Jiri Olsa32dcd022019-07-21 13:23:51 +02001078 struct evsel *evsel, *leader;
Jiri Olsa5a30a992013-02-04 10:56:43 +01001079
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001080 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001081 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
1082
1083 /* cycles:G + :uG group modifier */
Jiri Olsa515dbe42019-09-03 10:39:52 +02001084 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001085 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001086 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001087 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1088 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1089 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1090 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1091 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1092 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
1093 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001094 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
Arnaldo Carvalho de Meloc754c382020-04-30 10:51:16 -03001095 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
Jiri Olsa5643b1a2019-07-21 13:24:46 +02001096 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -03001097 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001098
1099 /* cache-misses:H + :uG group modifier */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001100 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001101 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001102 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001103 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1104 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1105 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1106 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1107 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
1108 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1109 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001110 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Arnaldo Carvalho de Melo2bb72db2020-05-04 13:43:03 -03001111 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
Jiri Olsa5a30a992013-02-04 10:56:43 +01001112
1113 return 0;
1114}
1115
Jiri Olsa63503db2019-07-21 13:23:52 +02001116static int test__leader_sample1(struct evlist *evlist)
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001117{
Jiri Olsa32dcd022019-07-21 13:23:51 +02001118 struct evsel *evsel, *leader;
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001119
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001120 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001121
1122 /* cycles - sampling group leader */
Jiri Olsa515dbe42019-09-03 10:39:52 +02001123 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001124 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001125 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001126 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
1127 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1128 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1129 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1130 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1131 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1132 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001133 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1134 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1135 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1136
1137 /* cache-misses - not sampling */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001138 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001139 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001140 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001141 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1142 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1143 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1144 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1145 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1146 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1147 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001148 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1149 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1150
1151 /* branch-misses - not sampling */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001152 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001153 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001154 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001155 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1156 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1157 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
1158 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
1159 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1160 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1161 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001162 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1163 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1164 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1165
1166 return 0;
1167}
1168
Jiri Olsa63503db2019-07-21 13:23:52 +02001169static int test__leader_sample2(struct evlist *evlist __maybe_unused)
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001170{
Jiri Olsa32dcd022019-07-21 13:23:51 +02001171 struct evsel *evsel, *leader;
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001172
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001173 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001174
1175 /* instructions - sampling group leader */
Jiri Olsa515dbe42019-09-03 10:39:52 +02001176 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001177 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001178 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001179 PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
1180 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1181 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1182 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1183 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1184 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1185 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001186 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1187 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1188 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1189
1190 /* branch-misses - not sampling */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001191 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001192 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001193 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001194 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1195 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1196 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1197 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1198 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
1199 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
1200 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001201 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1202 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
1203 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
1204
1205 return 0;
1206}
1207
Jiri Olsa63503db2019-07-21 13:23:52 +02001208static int test__checkevent_pinned_modifier(struct evlist *evlist)
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001209{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001210 struct evsel *evsel = evlist__first(evlist);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001211
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001212 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1213 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1214 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1215 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
1216 TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001217
1218 return test__checkevent_symbolic_name(evlist);
1219}
1220
Jiri Olsa63503db2019-07-21 13:23:52 +02001221static int test__pinned_group(struct evlist *evlist)
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001222{
Jiri Olsa32dcd022019-07-21 13:23:51 +02001223 struct evsel *evsel, *leader;
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001224
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001225 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001226
1227 /* cycles - group leader */
Jiri Olsa515dbe42019-09-03 10:39:52 +02001228 evsel = leader = evlist__first(evlist);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001229 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001230 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001231 PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001232 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
1233 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001234 TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001235
1236 /* cache-misses - can not be pinned, but will go on with the leader */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001237 evsel = evsel__next(evsel);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001238 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001239 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001240 PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config);
1241 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001242
1243 /* branch-misses - ditto */
Arnaldo Carvalho de Meloe470dae2020-04-30 11:06:45 -03001244 evsel = evsel__next(evsel);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001245 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001246 PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config);
1247 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001248
1249 return 0;
1250}
1251
Jiri Olsa63503db2019-07-21 13:23:52 +02001252static int test__checkevent_breakpoint_len(struct evlist *evlist)
Jacob Shinec323982014-05-29 17:26:52 +02001253{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001254 struct evsel *evsel = evlist__first(evlist);
Jacob Shinec323982014-05-29 17:26:52 +02001255
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001256 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001257 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1258 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jacob Shinec323982014-05-29 17:26:52 +02001259 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001260 evsel->core.attr.bp_type);
Jacob Shinec323982014-05-29 17:26:52 +02001261 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001262 evsel->core.attr.bp_len);
Jacob Shinec323982014-05-29 17:26:52 +02001263
1264 return 0;
1265}
1266
Jiri Olsa63503db2019-07-21 13:23:52 +02001267static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
Jacob Shinec323982014-05-29 17:26:52 +02001268{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001269 struct evsel *evsel = evlist__first(evlist);
Jacob Shinec323982014-05-29 17:26:52 +02001270
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001271 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001272 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
1273 TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
Jacob Shinec323982014-05-29 17:26:52 +02001274 TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001275 evsel->core.attr.bp_type);
Jacob Shinec323982014-05-29 17:26:52 +02001276 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001277 evsel->core.attr.bp_len);
Jacob Shinec323982014-05-29 17:26:52 +02001278
1279 return 0;
1280}
1281
1282static int
Jiri Olsa63503db2019-07-21 13:23:52 +02001283test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
Jacob Shinec323982014-05-29 17:26:52 +02001284{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001285 struct evsel *evsel = evlist__first(evlist);
Jacob Shinec323982014-05-29 17:26:52 +02001286
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001287 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
1288 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
1289 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
1290 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
Jacob Shinec323982014-05-29 17:26:52 +02001291
1292 return test__checkevent_breakpoint_rw(evlist);
1293}
1294
Jiri Olsa63503db2019-07-21 13:23:52 +02001295static int test__checkevent_precise_max_modifier(struct evlist *evlist)
Jiri Olsaddd83c92015-10-05 20:06:06 +02001296{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001297 struct evsel *evsel = evlist__first(evlist);
Jiri Olsaddd83c92015-10-05 20:06:06 +02001298
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001299 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001300 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
Jiri Olsaddd83c92015-10-05 20:06:06 +02001301 TEST_ASSERT_VAL("wrong config",
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001302 PERF_COUNT_SW_TASK_CLOCK == evsel->core.attr.config);
Jiri Olsaddd83c92015-10-05 20:06:06 +02001303 return 0;
1304}
1305
Jiri Olsa63503db2019-07-21 13:23:52 +02001306static int test__checkevent_config_symbol(struct evlist *evlist)
Wang Nan10bf3582016-02-19 11:44:00 +00001307{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001308 struct evsel *evsel = evlist__first(evlist);
Wang Nan10bf3582016-02-19 11:44:00 +00001309
1310 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
1311 return 0;
1312}
1313
Jiri Olsa63503db2019-07-21 13:23:52 +02001314static int test__checkevent_config_raw(struct evlist *evlist)
Wang Nan10bf3582016-02-19 11:44:00 +00001315{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001316 struct evsel *evsel = evlist__first(evlist);
Wang Nan10bf3582016-02-19 11:44:00 +00001317
1318 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
1319 return 0;
1320}
1321
Jiri Olsa63503db2019-07-21 13:23:52 +02001322static int test__checkevent_config_num(struct evlist *evlist)
Wang Nan10bf3582016-02-19 11:44:00 +00001323{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001324 struct evsel *evsel = evlist__first(evlist);
Wang Nan10bf3582016-02-19 11:44:00 +00001325
1326 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
1327 return 0;
1328}
1329
Jiri Olsa63503db2019-07-21 13:23:52 +02001330static int test__checkevent_config_cache(struct evlist *evlist)
Wang Nan43d0b972016-02-19 11:44:01 +00001331{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001332 struct evsel *evsel = evlist__first(evlist);
Wang Nan43d0b972016-02-19 11:44:01 +00001333
1334 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
1335 return 0;
1336}
Wang Nan10bf3582016-02-19 11:44:00 +00001337
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001338static bool test__intel_pt_valid(void)
1339{
1340 return !!perf_pmu__find("intel_pt");
1341}
1342
Jiri Olsa63503db2019-07-21 13:23:52 +02001343static int test__intel_pt(struct evlist *evlist)
Arnaldo Carvalho de Melob3f58c82018-05-11 11:48:54 -03001344{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001345 struct evsel *evsel = evlist__first(evlist);
Arnaldo Carvalho de Melob3f58c82018-05-11 11:48:54 -03001346
1347 TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0);
1348 return 0;
1349}
1350
Jiri Olsa63503db2019-07-21 13:23:52 +02001351static int test__checkevent_complex_name(struct evlist *evlist)
Alexey Budankov06dc5bf2018-06-19 11:45:40 +03001352{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001353 struct evsel *evsel = evlist__first(evlist);
Alexey Budankov06dc5bf2018-06-19 11:45:40 +03001354
1355 TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0);
1356 return 0;
1357}
1358
Jiri Olsa3a6c51e2020-04-17 00:14:05 +02001359static int test__checkevent_raw_pmu(struct evlist *evlist)
1360{
1361 struct evsel *evsel = evlist__first(evlist);
1362
1363 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
1364 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
1365 TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
1366 return 0;
1367}
1368
Jiri Olsa63503db2019-07-21 13:23:52 +02001369static int test__sym_event_slash(struct evlist *evlist)
Jiri Olsa714a92d2019-02-13 13:32:40 +01001370{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001371 struct evsel *evsel = evlist__first(evlist);
Jiri Olsa714a92d2019-02-13 13:32:40 +01001372
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001373 TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
1374 TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
1375 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
Jiri Olsa714a92d2019-02-13 13:32:40 +01001376 return 0;
1377}
1378
Jiri Olsa63503db2019-07-21 13:23:52 +02001379static int test__sym_event_dc(struct evlist *evlist)
Jiri Olsa714a92d2019-02-13 13:32:40 +01001380{
Jiri Olsa515dbe42019-09-03 10:39:52 +02001381 struct evsel *evsel = evlist__first(evlist);
Jiri Olsa714a92d2019-02-13 13:32:40 +01001382
Jiri Olsa1fc632c2019-07-21 13:24:29 +02001383 TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
1384 TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
1385 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
Jiri Olsa714a92d2019-02-13 13:32:40 +01001386 return 0;
1387}
1388
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001389static int count_tracepoints(void)
1390{
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001391 struct dirent *events_ent;
1392 DIR *events_dir;
1393 int cnt = 0;
1394
Arnaldo Carvalho de Melo7014e0e2018-05-17 14:42:39 -03001395 events_dir = tracing_events__opendir();
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001396
1397 TEST_ASSERT_VAL("Can't open events dir", events_dir);
1398
1399 while ((events_ent = readdir(events_dir))) {
Arnaldo Carvalho de Melo25a7d9142018-05-17 14:27:29 -03001400 char *sys_path;
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001401 struct dirent *sys_ent;
1402 DIR *sys_dir;
1403
1404 if (!strcmp(events_ent->d_name, ".")
1405 || !strcmp(events_ent->d_name, "..")
1406 || !strcmp(events_ent->d_name, "enable")
1407 || !strcmp(events_ent->d_name, "header_event")
1408 || !strcmp(events_ent->d_name, "header_page"))
1409 continue;
1410
Arnaldo Carvalho de Melo25a7d9142018-05-17 14:27:29 -03001411 sys_path = get_events_file(events_ent->d_name);
1412 TEST_ASSERT_VAL("Can't get sys path", sys_path);
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001413
1414 sys_dir = opendir(sys_path);
1415 TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
1416
1417 while ((sys_ent = readdir(sys_dir))) {
1418 if (!strcmp(sys_ent->d_name, ".")
1419 || !strcmp(sys_ent->d_name, "..")
1420 || !strcmp(sys_ent->d_name, "enable")
1421 || !strcmp(sys_ent->d_name, "filter"))
1422 continue;
1423
1424 cnt++;
1425 }
1426
1427 closedir(sys_dir);
Arnaldo Carvalho de Melo25a7d9142018-05-17 14:27:29 -03001428 put_events_file(sys_path);
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001429 }
1430
1431 closedir(events_dir);
1432 return cnt;
1433}
1434
Jiri Olsa63503db2019-07-21 13:23:52 +02001435static int test__all_tracepoints(struct evlist *evlist)
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001436{
1437 TEST_ASSERT_VAL("wrong events count",
Jiri Olsa6484d2f2019-07-21 13:24:28 +02001438 count_tracepoints() == evlist->core.nr_entries);
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001439
1440 return test__checkevent_tracepoint_multi(evlist);
1441}
1442
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001443struct evlist_test {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001444 const char *name;
1445 __u32 type;
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001446 const int id;
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001447 bool (*valid)(void);
Jiri Olsa63503db2019-07-21 13:23:52 +02001448 int (*check)(struct evlist *evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +02001449};
1450
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001451static struct evlist_test test__events[] = {
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001452 {
Riku Voipio43f322b2015-04-16 16:52:53 +03001453 .name = "syscalls:sys_enter_openat",
Jiri Olsaf50246e2012-05-21 09:12:49 +02001454 .check = test__checkevent_tracepoint,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001455 .id = 0,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001456 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001457 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001458 .name = "syscalls:*",
1459 .check = test__checkevent_tracepoint_multi,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001460 .id = 1,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001461 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001462 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001463 .name = "r1a",
1464 .check = test__checkevent_raw,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001465 .id = 2,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001466 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001467 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001468 .name = "1:1",
1469 .check = test__checkevent_numeric,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001470 .id = 3,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001471 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001472 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001473 .name = "instructions",
1474 .check = test__checkevent_symbolic_name,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001475 .id = 4,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001476 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001477 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001478 .name = "cycles/period=100000,config2/",
1479 .check = test__checkevent_symbolic_name_config,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001480 .id = 5,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001481 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001482 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001483 .name = "faults",
1484 .check = test__checkevent_symbolic_alias,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001485 .id = 6,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001486 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001487 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001488 .name = "L1-dcache-load-miss",
1489 .check = test__checkevent_genhw,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001490 .id = 7,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001491 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001492 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001493 .name = "mem:0",
1494 .check = test__checkevent_breakpoint,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001495 .id = 8,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001496 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001497 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001498 .name = "mem:0:x",
1499 .check = test__checkevent_breakpoint_x,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001500 .id = 9,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001501 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001502 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001503 .name = "mem:0:r",
1504 .check = test__checkevent_breakpoint_r,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001505 .id = 10,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001506 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001507 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001508 .name = "mem:0:w",
1509 .check = test__checkevent_breakpoint_w,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001510 .id = 11,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001511 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001512 {
Riku Voipio43f322b2015-04-16 16:52:53 +03001513 .name = "syscalls:sys_enter_openat:k",
Jiri Olsaf50246e2012-05-21 09:12:49 +02001514 .check = test__checkevent_tracepoint_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001515 .id = 12,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001516 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001517 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001518 .name = "syscalls:*:u",
1519 .check = test__checkevent_tracepoint_multi_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001520 .id = 13,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001521 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001522 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001523 .name = "r1a:kp",
1524 .check = test__checkevent_raw_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001525 .id = 14,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001526 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001527 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001528 .name = "1:1:hp",
1529 .check = test__checkevent_numeric_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001530 .id = 15,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001531 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001532 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001533 .name = "instructions:h",
1534 .check = test__checkevent_symbolic_name_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001535 .id = 16,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001536 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001537 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001538 .name = "faults:u",
1539 .check = test__checkevent_symbolic_alias_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001540 .id = 17,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001541 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001542 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001543 .name = "L1-dcache-load-miss:kp",
1544 .check = test__checkevent_genhw_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001545 .id = 18,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001546 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001547 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001548 .name = "mem:0:u",
1549 .check = test__checkevent_breakpoint_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001550 .id = 19,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001551 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001552 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001553 .name = "mem:0:x:k",
1554 .check = test__checkevent_breakpoint_x_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001555 .id = 20,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001556 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001557 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001558 .name = "mem:0:r:hp",
1559 .check = test__checkevent_breakpoint_r_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001560 .id = 21,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001561 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001562 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001563 .name = "mem:0:w:up",
1564 .check = test__checkevent_breakpoint_w_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001565 .id = 22,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001566 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001567 {
Riku Voipio43f322b2015-04-16 16:52:53 +03001568 .name = "r1,syscalls:sys_enter_openat:k,1:1:hp",
Jiri Olsaf50246e2012-05-21 09:12:49 +02001569 .check = test__checkevent_list,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001570 .id = 23,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001571 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001572 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001573 .name = "instructions:G",
1574 .check = test__checkevent_exclude_host_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001575 .id = 24,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001576 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001577 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001578 .name = "instructions:H",
1579 .check = test__checkevent_exclude_guest_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001580 .id = 25,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001581 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001582 {
Jiri Olsa75827322012-06-29 09:22:54 +02001583 .name = "mem:0:rw",
1584 .check = test__checkevent_breakpoint_rw,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001585 .id = 26,
Jiri Olsa75827322012-06-29 09:22:54 +02001586 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001587 {
Jiri Olsa75827322012-06-29 09:22:54 +02001588 .name = "mem:0:rw:kp",
1589 .check = test__checkevent_breakpoint_rw_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001590 .id = 27,
Jiri Olsa75827322012-06-29 09:22:54 +02001591 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001592 {
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001593 .name = "{instructions:k,cycles:upp}",
1594 .check = test__group1,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001595 .id = 28,
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001596 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001597 {
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001598 .name = "{faults:k,cache-references}:u,cycles:k",
1599 .check = test__group2,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001600 .id = 29,
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001601 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001602 {
Riku Voipio43f322b2015-04-16 16:52:53 +03001603 .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001604 .check = test__group3,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001605 .id = 30,
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001606 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001607 {
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001608 .name = "{cycles:u,instructions:kp}:p",
1609 .check = test__group4,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001610 .id = 31,
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001611 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001612 {
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001613 .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
1614 .check = test__group5,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001615 .id = 32,
Jiri Olsa905f5ee2012-08-08 12:23:52 +02001616 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001617 {
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001618 .name = "*:*",
1619 .check = test__all_tracepoints,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001620 .id = 33,
Jiri Olsa82ce75d2012-12-17 14:08:38 +01001621 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001622 {
Jiri Olsa5a30a992013-02-04 10:56:43 +01001623 .name = "{cycles,cache-misses:G}:H",
1624 .check = test__group_gh1,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001625 .id = 34,
Jiri Olsa5a30a992013-02-04 10:56:43 +01001626 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001627 {
Jiri Olsa5a30a992013-02-04 10:56:43 +01001628 .name = "{cycles,cache-misses:H}:G",
1629 .check = test__group_gh2,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001630 .id = 35,
Jiri Olsa5a30a992013-02-04 10:56:43 +01001631 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001632 {
Jiri Olsa5a30a992013-02-04 10:56:43 +01001633 .name = "{cycles:G,cache-misses:H}:u",
1634 .check = test__group_gh3,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001635 .id = 36,
Jiri Olsa5a30a992013-02-04 10:56:43 +01001636 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001637 {
Jiri Olsa5a30a992013-02-04 10:56:43 +01001638 .name = "{cycles:G,cache-misses:H}:uG",
1639 .check = test__group_gh4,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001640 .id = 37,
Jiri Olsa5a30a992013-02-04 10:56:43 +01001641 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001642 {
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001643 .name = "{cycles,cache-misses,branch-misses}:S",
1644 .check = test__leader_sample1,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001645 .id = 38,
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001646 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001647 {
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001648 .name = "{instructions,branch-misses}:Su",
1649 .check = test__leader_sample2,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001650 .id = 39,
Jiri Olsaa9f93f92013-02-01 20:37:11 +01001651 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001652 {
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001653 .name = "instructions:uDp",
1654 .check = test__checkevent_pinned_modifier,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001655 .id = 40,
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001656 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001657 {
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001658 .name = "{cycles,cache-misses,branch-misses}:D",
1659 .check = test__pinned_group,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001660 .id = 41,
Michael Ellermanc9ee7802013-08-06 23:28:06 +10001661 },
Jacob Shinec323982014-05-29 17:26:52 +02001662 {
1663 .name = "mem:0/1",
1664 .check = test__checkevent_breakpoint_len,
1665 .id = 42,
1666 },
1667 {
1668 .name = "mem:0/2:w",
1669 .check = test__checkevent_breakpoint_len_w,
1670 .id = 43,
1671 },
1672 {
1673 .name = "mem:0/4:rw:u",
1674 .check = test__checkevent_breakpoint_len_rw_modifier,
1675 .id = 44
1676 },
Alexander Yaryginc0bc8c62014-04-25 17:34:07 +02001677#if defined(__s390x__)
1678 {
1679 .name = "kvm-s390:kvm_s390_create_vm",
1680 .check = test__checkevent_tracepoint,
Thomas Richter53fe3072019-06-04 07:35:04 +02001681 .valid = kvm_s390_create_vm_valid,
Alexander Yaryginc0bc8c62014-04-25 17:34:07 +02001682 .id = 100,
1683 },
1684#endif
Jiri Olsaa1e12da2015-04-07 23:25:14 +02001685 {
1686 .name = "instructions:I",
1687 .check = test__checkevent_exclude_idle_modifier,
1688 .id = 45,
1689 },
1690 {
1691 .name = "instructions:kIG",
1692 .check = test__checkevent_exclude_idle_modifier_1,
1693 .id = 46,
1694 },
Jiri Olsaddd83c92015-10-05 20:06:06 +02001695 {
1696 .name = "task-clock:P,cycles",
1697 .check = test__checkevent_precise_max_modifier,
1698 .id = 47,
1699 },
Wang Nan10bf3582016-02-19 11:44:00 +00001700 {
1701 .name = "instructions/name=insn/",
1702 .check = test__checkevent_config_symbol,
1703 .id = 48,
1704 },
1705 {
1706 .name = "r1234/name=rawpmu/",
1707 .check = test__checkevent_config_raw,
1708 .id = 49,
1709 },
1710 {
1711 .name = "4:0x6530160/name=numpmu/",
1712 .check = test__checkevent_config_num,
1713 .id = 50,
1714 },
Wang Nan43d0b972016-02-19 11:44:01 +00001715 {
1716 .name = "L1-dcache-misses/name=cachepmu/",
1717 .check = test__checkevent_config_cache,
1718 .id = 51,
1719 },
Arnaldo Carvalho de Melob3f58c82018-05-11 11:48:54 -03001720 {
1721 .name = "intel_pt//u",
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001722 .valid = test__intel_pt_valid,
Arnaldo Carvalho de Melob3f58c82018-05-11 11:48:54 -03001723 .check = test__intel_pt,
1724 .id = 52,
1725 },
Alexey Budankov06dc5bf2018-06-19 11:45:40 +03001726 {
1727 .name = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk",
1728 .check = test__checkevent_complex_name,
1729 .id = 53
Jiri Olsa714a92d2019-02-13 13:32:40 +01001730 },
1731 {
1732 .name = "cycles//u",
1733 .check = test__sym_event_slash,
1734 .id = 54,
1735 },
1736 {
1737 .name = "cycles:k",
1738 .check = test__sym_event_dc,
1739 .id = 55,
Alexey Budankov06dc5bf2018-06-19 11:45:40 +03001740 }
Jiri Olsaf50246e2012-05-21 09:12:49 +02001741};
1742
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001743static struct evlist_test test__events_pmu[] = {
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001744 {
Jiri Olsaf50246e2012-05-21 09:12:49 +02001745 .name = "cpu/config=10,config1,config2=3,period=1000/u",
1746 .check = test__checkevent_pmu,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001747 .id = 0,
Jiri Olsaf50246e2012-05-21 09:12:49 +02001748 },
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001749 {
Jiri Olsa6b5fc392012-05-21 09:12:53 +02001750 .name = "cpu/config=1,name=krava/u,cpu/config=2/u",
1751 .check = test__checkevent_pmu_name,
Alexander Yarygin615b8f92014-04-25 17:34:06 +02001752 .id = 1,
Jiri Olsa6b5fc392012-05-21 09:12:53 +02001753 },
Kan Liang71ef1502015-08-11 06:30:50 -04001754 {
1755 .name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
1756 .check = test__checkevent_pmu_partial_time_callgraph,
1757 .id = 2,
1758 },
Alexey Budankov06dc5bf2018-06-19 11:45:40 +03001759 {
Sandipan Dasa6f39ce2018-07-26 16:25:02 +05301760 .name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
Alexey Budankov06dc5bf2018-06-19 11:45:40 +03001761 .check = test__checkevent_complex_name,
1762 .id = 3,
Jiri Olsa3a6c51e2020-04-17 00:14:05 +02001763 },
1764 {
1765 .name = "software/r1a/",
1766 .check = test__checkevent_raw_pmu,
1767 .id = 4,
1768 },
Jiri Olsaf50246e2012-05-21 09:12:49 +02001769};
1770
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001771struct terms_test {
Jiri Olsa44293922012-06-15 14:31:42 +08001772 const char *str;
1773 __u32 type;
1774 int (*check)(struct list_head *terms);
1775};
1776
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001777static struct terms_test test__terms[] = {
Jiri Olsa44293922012-06-15 14:31:42 +08001778 [0] = {
1779 .str = "config=10,config1,config2=3,umask=1",
1780 .check = test__checkterms_simple,
1781 },
1782};
1783
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001784static int test_event(struct evlist_test *e)
Jiri Olsaf50246e2012-05-21 09:12:49 +02001785{
Ian Rogersa910e462019-11-15 23:46:52 -08001786 struct parse_events_error err;
Jiri Olsa63503db2019-07-21 13:23:52 +02001787 struct evlist *evlist;
Jiri Olsaf50246e2012-05-21 09:12:49 +02001788 int ret;
1789
Ian Rogersa910e462019-11-15 23:46:52 -08001790 bzero(&err, sizeof(err));
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001791 if (e->valid && !e->valid()) {
1792 pr_debug("... SKIP");
1793 return 0;
1794 }
1795
Jiri Olsa0f98b112019-07-21 13:23:55 +02001796 evlist = evlist__new();
Jiri Olsaf50246e2012-05-21 09:12:49 +02001797 if (evlist == NULL)
1798 return -ENOMEM;
1799
Jiri Olsa933ccf22018-06-11 11:34:21 +02001800 ret = parse_events(evlist, e->name, &err);
Jiri Olsaf50246e2012-05-21 09:12:49 +02001801 if (ret) {
Jiri Olsa933ccf22018-06-11 11:34:21 +02001802 pr_debug("failed to parse event '%s', err %d, str '%s'\n",
1803 e->name, ret, err.str);
1804 parse_events_print_error(&err, e->name);
Arnaldo Carvalho de Melo2d4352c2014-01-03 17:30:04 -03001805 } else {
1806 ret = e->check(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +02001807 }
Arnaldo Carvalho de Melo48000a12014-12-17 17:24:45 -03001808
Jiri Olsac12995a2019-07-21 13:23:56 +02001809 evlist__delete(evlist);
Jiri Olsaf50246e2012-05-21 09:12:49 +02001810
1811 return ret;
1812}
1813
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001814static int test_events(struct evlist_test *events, unsigned cnt)
Jiri Olsaf50246e2012-05-21 09:12:49 +02001815{
Robert Richter9bfbbc62012-08-21 20:03:15 +02001816 int ret1, ret2 = 0;
Jiri Olsaf50246e2012-05-21 09:12:49 +02001817 unsigned i;
1818
1819 for (i = 0; i < cnt; i++) {
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001820 struct evlist_test *e = &events[i];
Jiri Olsaf50246e2012-05-21 09:12:49 +02001821
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001822 pr_debug("running test %d '%s'", e->id, e->name);
Robert Richter9bfbbc62012-08-21 20:03:15 +02001823 ret1 = test_event(e);
1824 if (ret1)
1825 ret2 = ret1;
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001826 pr_debug("\n");
Jiri Olsa44293922012-06-15 14:31:42 +08001827 }
1828
Robert Richter9bfbbc62012-08-21 20:03:15 +02001829 return ret2;
Jiri Olsa44293922012-06-15 14:31:42 +08001830}
1831
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001832static int test_term(struct terms_test *t)
Jiri Olsa44293922012-06-15 14:31:42 +08001833{
David Ahernc549aca2013-07-02 13:27:24 -06001834 struct list_head terms;
Jiri Olsa44293922012-06-15 14:31:42 +08001835 int ret;
1836
David Ahernc549aca2013-07-02 13:27:24 -06001837 INIT_LIST_HEAD(&terms);
Jiri Olsa44293922012-06-15 14:31:42 +08001838
David Ahernc549aca2013-07-02 13:27:24 -06001839 ret = parse_events_terms(&terms, t->str);
Jiri Olsa44293922012-06-15 14:31:42 +08001840 if (ret) {
1841 pr_debug("failed to parse terms '%s', err %d\n",
1842 t->str , ret);
1843 return ret;
1844 }
1845
David Ahernc549aca2013-07-02 13:27:24 -06001846 ret = t->check(&terms);
Arnaldo Carvalho de Melo682dc242016-02-12 16:48:00 -03001847 parse_events_terms__purge(&terms);
Jiri Olsa44293922012-06-15 14:31:42 +08001848
1849 return ret;
1850}
1851
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001852static int test_terms(struct terms_test *terms, unsigned cnt)
Jiri Olsa44293922012-06-15 14:31:42 +08001853{
1854 int ret = 0;
1855 unsigned i;
1856
1857 for (i = 0; i < cnt; i++) {
Arnaldo Carvalho de Melo23b63392013-01-18 16:56:57 -03001858 struct terms_test *t = &terms[i];
Jiri Olsa44293922012-06-15 14:31:42 +08001859
1860 pr_debug("running test %d '%s'\n", i, t->str);
1861 ret = test_term(t);
Jiri Olsaf50246e2012-05-21 09:12:49 +02001862 if (ret)
1863 break;
1864 }
1865
1866 return ret;
1867}
1868
1869static int test_pmu(void)
1870{
1871 struct stat st;
1872 char path[PATH_MAX];
1873 int ret;
1874
1875 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
Arnaldo Carvalho de Melocf38fad2013-11-05 14:48:50 -03001876 sysfs__mountpoint());
Jiri Olsaf50246e2012-05-21 09:12:49 +02001877
1878 ret = stat(path, &st);
1879 if (ret)
Masanari Iida3fd44cd2012-07-18 01:20:59 +09001880 pr_debug("omitting PMU cpu tests\n");
Jiri Olsaf50246e2012-05-21 09:12:49 +02001881 return !ret;
1882}
1883
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001884static int test_pmu_events(void)
1885{
1886 struct stat st;
1887 char path[PATH_MAX];
1888 struct dirent *ent;
1889 DIR *dir;
1890 int ret;
1891
1892 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
Arnaldo Carvalho de Melocf38fad2013-11-05 14:48:50 -03001893 sysfs__mountpoint());
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001894
1895 ret = stat(path, &st);
1896 if (ret) {
Masanari Iidaa895d572013-04-09 02:06:50 +09001897 pr_debug("omitting PMU cpu events tests\n");
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001898 return 0;
1899 }
1900
1901 dir = opendir(path);
1902 if (!dir) {
1903 pr_debug("can't open pmu event dir");
1904 return -1;
1905 }
1906
1907 while (!ret && (ent = readdir(dir))) {
Jiri Olsa16ddcfb2018-06-11 11:34:22 +02001908 struct evlist_test e = { .id = 0, };
Arnaldo Carvalho de Melo2e2bbc032017-02-09 14:48:46 -03001909 char name[2 * NAME_MAX + 1 + 12 + 3];
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001910
Andi Kleen17a26342016-06-06 07:36:06 -07001911 /* Names containing . are special and cannot be used directly */
1912 if (strchr(ent->d_name, '.'))
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001913 continue;
1914
Arnaldo Carvalho de Melo2e2bbc032017-02-09 14:48:46 -03001915 snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001916
1917 e.name = name;
1918 e.check = test__checkevent_pmu_events;
1919
1920 ret = test_event(&e);
Kan Liangffe59782014-10-07 11:08:52 -04001921 if (ret)
1922 break;
Arnaldo Carvalho de Melo2e2bbc032017-02-09 14:48:46 -03001923 snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
Kan Liangffe59782014-10-07 11:08:52 -04001924 e.name = name;
1925 e.check = test__checkevent_pmu_events_mix;
1926 ret = test_event(&e);
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001927 }
1928
1929 closedir(dir);
1930 return ret;
1931}
1932
Arnaldo Carvalho de Melo81f17c92017-08-03 15:16:31 -03001933int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
Jiri Olsaf50246e2012-05-21 09:12:49 +02001934{
Robert Richter9bfbbc62012-08-21 20:03:15 +02001935 int ret1, ret2 = 0;
Jiri Olsaf50246e2012-05-21 09:12:49 +02001936
Jiri Olsaebf124f2012-07-04 00:00:47 +02001937#define TEST_EVENTS(tests) \
1938do { \
Robert Richter9bfbbc62012-08-21 20:03:15 +02001939 ret1 = test_events(tests, ARRAY_SIZE(tests)); \
1940 if (!ret2) \
1941 ret2 = ret1; \
Jiri Olsaebf124f2012-07-04 00:00:47 +02001942} while (0)
Jiri Olsa44293922012-06-15 14:31:42 +08001943
Jiri Olsaebf124f2012-07-04 00:00:47 +02001944 TEST_EVENTS(test__events);
Jiri Olsa44293922012-06-15 14:31:42 +08001945
Jiri Olsaebf124f2012-07-04 00:00:47 +02001946 if (test_pmu())
1947 TEST_EVENTS(test__events_pmu);
Jiri Olsa44293922012-06-15 14:31:42 +08001948
Jiri Olsa3f3a2062012-10-10 14:53:18 +02001949 if (test_pmu()) {
1950 int ret = test_pmu_events();
1951 if (ret)
1952 return ret;
1953 }
1954
Robert Richter9bfbbc62012-08-21 20:03:15 +02001955 ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));
1956 if (!ret2)
1957 ret2 = ret1;
1958
1959 return ret2;
Jiri Olsaf50246e2012-05-21 09:12:49 +02001960}