Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1 | |
| 2 | #include "parse-events.h" |
| 3 | #include "evsel.h" |
| 4 | #include "evlist.h" |
Borislav Petkov | cd0cfad | 2013-12-09 17:14:24 +0100 | [diff] [blame] | 5 | #include <api/fs/fs.h> |
Steven Rostedt (Red Hat) | 23773ca | 2015-02-02 14:35:07 -0500 | [diff] [blame^] | 6 | #include <api/fs/tracefs.h> |
Borislav Petkov | 553873e | 2013-12-09 17:14:23 +0100 | [diff] [blame] | 7 | #include <api/fs/debugfs.h> |
Jiri Olsa | c81251e | 2012-11-10 01:46:51 +0100 | [diff] [blame] | 8 | #include "tests.h" |
Jiri Olsa | 84f5d36 | 2014-07-14 23:46:48 +0200 | [diff] [blame] | 9 | #include "debug.h" |
David Howells | d2709c7 | 2012-11-19 22:21:03 +0000 | [diff] [blame] | 10 | #include <linux/hw_breakpoint.h> |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 11 | |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 12 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ |
| 13 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) |
| 14 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 15 | static int test__checkevent_tracepoint(struct perf_evlist *evlist) |
| 16 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 17 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 18 | |
| 19 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 20 | TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 21 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 22 | TEST_ASSERT_VAL("wrong sample_type", |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 23 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 24 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) |
| 29 | { |
| 30 | struct perf_evsel *evsel; |
| 31 | |
| 32 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 33 | TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 34 | |
Arnaldo Carvalho de Melo | 0050f7a | 2014-01-10 10:37:27 -0300 | [diff] [blame] | 35 | evlist__for_each(evlist, evsel) { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 36 | TEST_ASSERT_VAL("wrong type", |
| 37 | PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 38 | TEST_ASSERT_VAL("wrong sample_type", |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 39 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 40 | TEST_ASSERT_VAL("wrong sample_period", |
| 41 | 1 == evsel->attr.sample_period); |
| 42 | } |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | static int test__checkevent_raw(struct perf_evlist *evlist) |
| 47 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 48 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 49 | |
| 50 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 51 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 52 | TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config); |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | static int test__checkevent_numeric(struct perf_evlist *evlist) |
| 57 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 58 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 59 | |
| 60 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 61 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 62 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static int test__checkevent_symbolic_name(struct perf_evlist *evlist) |
| 67 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 68 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 69 | |
| 70 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 71 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 72 | TEST_ASSERT_VAL("wrong config", |
| 73 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) |
| 78 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 79 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 80 | |
| 81 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 82 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 83 | TEST_ASSERT_VAL("wrong config", |
| 84 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 85 | TEST_ASSERT_VAL("wrong period", |
| 86 | 100000 == evsel->attr.sample_period); |
| 87 | TEST_ASSERT_VAL("wrong config1", |
| 88 | 0 == evsel->attr.config1); |
| 89 | TEST_ASSERT_VAL("wrong config2", |
| 90 | 1 == evsel->attr.config2); |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) |
| 95 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 96 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 97 | |
| 98 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 99 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
| 100 | TEST_ASSERT_VAL("wrong config", |
| 101 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | static int test__checkevent_genhw(struct perf_evlist *evlist) |
| 106 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 107 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 108 | |
| 109 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 110 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); |
| 111 | TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config); |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | static int test__checkevent_breakpoint(struct perf_evlist *evlist) |
| 116 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 117 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 118 | |
| 119 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 120 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 121 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 122 | TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == |
| 123 | evsel->attr.bp_type); |
| 124 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == |
| 125 | evsel->attr.bp_len); |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) |
| 130 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 131 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 132 | |
| 133 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 134 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 135 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 136 | TEST_ASSERT_VAL("wrong bp_type", |
| 137 | HW_BREAKPOINT_X == evsel->attr.bp_type); |
| 138 | TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len); |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) |
| 143 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 144 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 145 | |
| 146 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 147 | TEST_ASSERT_VAL("wrong type", |
| 148 | PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 149 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 150 | TEST_ASSERT_VAL("wrong bp_type", |
| 151 | HW_BREAKPOINT_R == evsel->attr.bp_type); |
| 152 | TEST_ASSERT_VAL("wrong bp_len", |
| 153 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) |
| 158 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 159 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 160 | |
| 161 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 162 | TEST_ASSERT_VAL("wrong type", |
| 163 | PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 164 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 165 | TEST_ASSERT_VAL("wrong bp_type", |
| 166 | HW_BREAKPOINT_W == evsel->attr.bp_type); |
| 167 | TEST_ASSERT_VAL("wrong bp_len", |
| 168 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); |
| 169 | return 0; |
| 170 | } |
| 171 | |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 172 | static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) |
| 173 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 174 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 175 | |
| 176 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 177 | TEST_ASSERT_VAL("wrong type", |
| 178 | PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 179 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 180 | TEST_ASSERT_VAL("wrong bp_type", |
| 181 | (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type); |
| 182 | TEST_ASSERT_VAL("wrong bp_len", |
| 183 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); |
| 184 | return 0; |
| 185 | } |
| 186 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 187 | static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) |
| 188 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 189 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 190 | |
| 191 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 192 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 193 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 194 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 195 | |
| 196 | return test__checkevent_tracepoint(evlist); |
| 197 | } |
| 198 | |
| 199 | static int |
| 200 | test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) |
| 201 | { |
| 202 | struct perf_evsel *evsel; |
| 203 | |
| 204 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); |
| 205 | |
Arnaldo Carvalho de Melo | 0050f7a | 2014-01-10 10:37:27 -0300 | [diff] [blame] | 206 | evlist__for_each(evlist, evsel) { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 207 | TEST_ASSERT_VAL("wrong exclude_user", |
| 208 | !evsel->attr.exclude_user); |
| 209 | TEST_ASSERT_VAL("wrong exclude_kernel", |
| 210 | evsel->attr.exclude_kernel); |
| 211 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 212 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 213 | } |
| 214 | |
| 215 | return test__checkevent_tracepoint_multi(evlist); |
| 216 | } |
| 217 | |
| 218 | static int test__checkevent_raw_modifier(struct perf_evlist *evlist) |
| 219 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 220 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 221 | |
| 222 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 223 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 224 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 225 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 226 | |
| 227 | return test__checkevent_raw(evlist); |
| 228 | } |
| 229 | |
| 230 | static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) |
| 231 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 232 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 233 | |
| 234 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 235 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 236 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 237 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 238 | |
| 239 | return test__checkevent_numeric(evlist); |
| 240 | } |
| 241 | |
| 242 | static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) |
| 243 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 244 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 245 | |
| 246 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 247 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 248 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 249 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 250 | |
| 251 | return test__checkevent_symbolic_name(evlist); |
| 252 | } |
| 253 | |
| 254 | static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) |
| 255 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 256 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 257 | |
| 258 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 259 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 260 | |
| 261 | return test__checkevent_symbolic_name(evlist); |
| 262 | } |
| 263 | |
| 264 | static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) |
| 265 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 266 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 267 | |
| 268 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 269 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 270 | |
| 271 | return test__checkevent_symbolic_name(evlist); |
| 272 | } |
| 273 | |
| 274 | static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) |
| 275 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 276 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 277 | |
| 278 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 279 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 280 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 281 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 282 | |
| 283 | return test__checkevent_symbolic_alias(evlist); |
| 284 | } |
| 285 | |
| 286 | static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) |
| 287 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 288 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 289 | |
| 290 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 291 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 292 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 293 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 294 | |
| 295 | return test__checkevent_genhw(evlist); |
| 296 | } |
| 297 | |
| 298 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) |
| 299 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 300 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 301 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 302 | |
| 303 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 304 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 305 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 306 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 307 | TEST_ASSERT_VAL("wrong name", |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 308 | !strcmp(perf_evsel__name(evsel), "mem:0:u")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 309 | |
| 310 | return test__checkevent_breakpoint(evlist); |
| 311 | } |
| 312 | |
| 313 | static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) |
| 314 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 315 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 316 | |
| 317 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 318 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 319 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 320 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 321 | TEST_ASSERT_VAL("wrong name", |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 322 | !strcmp(perf_evsel__name(evsel), "mem:0:x:k")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 323 | |
| 324 | return test__checkevent_breakpoint_x(evlist); |
| 325 | } |
| 326 | |
| 327 | static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) |
| 328 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 329 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 330 | |
| 331 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 332 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 333 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 334 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 335 | TEST_ASSERT_VAL("wrong name", |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 336 | !strcmp(perf_evsel__name(evsel), "mem:0:r:hp")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 337 | |
| 338 | return test__checkevent_breakpoint_r(evlist); |
| 339 | } |
| 340 | |
| 341 | static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) |
| 342 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 343 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 344 | |
| 345 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 346 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 347 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 348 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 349 | TEST_ASSERT_VAL("wrong name", |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 350 | !strcmp(perf_evsel__name(evsel), "mem:0:w:up")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 351 | |
| 352 | return test__checkevent_breakpoint_w(evlist); |
| 353 | } |
| 354 | |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 355 | static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) |
| 356 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 357 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 358 | |
| 359 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 360 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 361 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 362 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 363 | TEST_ASSERT_VAL("wrong name", |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 364 | !strcmp(perf_evsel__name(evsel), "mem:0:rw:kp")); |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 365 | |
| 366 | return test__checkevent_breakpoint_rw(evlist); |
| 367 | } |
| 368 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 369 | static int test__checkevent_pmu(struct perf_evlist *evlist) |
| 370 | { |
| 371 | |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 372 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 373 | |
| 374 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 375 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 376 | TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); |
| 377 | TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); |
| 378 | TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); |
| 379 | TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period); |
| 380 | |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | static int test__checkevent_list(struct perf_evlist *evlist) |
| 385 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 386 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 387 | |
| 388 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 389 | |
| 390 | /* r1 */ |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 391 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 392 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
| 393 | TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); |
| 394 | TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2); |
| 395 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 396 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 397 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 398 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 399 | |
| 400 | /* syscalls:sys_enter_open:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 401 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 402 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 403 | TEST_ASSERT_VAL("wrong sample_type", |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 404 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 405 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 406 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 407 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 408 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 409 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 410 | |
| 411 | /* 1:1:hp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 412 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 413 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 414 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
| 415 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 416 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 417 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 418 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 423 | static int test__checkevent_pmu_name(struct perf_evlist *evlist) |
| 424 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 425 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 426 | |
Jiri Olsa | 7a25b2d | 2012-06-21 12:25:16 +0200 | [diff] [blame] | 427 | /* cpu/config=1,name=krava/u */ |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 428 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 429 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 430 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
Arnaldo Carvalho de Melo | 22c8b84 | 2012-06-12 13:55:13 -0300 | [diff] [blame] | 431 | TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 432 | |
Jiri Olsa | 7a25b2d | 2012-06-21 12:25:16 +0200 | [diff] [blame] | 433 | /* cpu/config=2/u" */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 434 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 435 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 436 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 437 | TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); |
Jiri Olsa | 7a25b2d | 2012-06-21 12:25:16 +0200 | [diff] [blame] | 438 | TEST_ASSERT_VAL("wrong name", |
Robert Richter | ac2ba9f | 2012-08-16 21:10:21 +0200 | [diff] [blame] | 439 | !strcmp(perf_evsel__name(evsel), "cpu/config=2/u")); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 440 | |
| 441 | return 0; |
| 442 | } |
| 443 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 444 | static int test__checkevent_pmu_events(struct perf_evlist *evlist) |
| 445 | { |
Arnaldo Carvalho de Melo | 9a354cd | 2013-11-13 15:54:30 -0300 | [diff] [blame] | 446 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 447 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 448 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 449 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 450 | TEST_ASSERT_VAL("wrong exclude_user", |
| 451 | !evsel->attr.exclude_user); |
| 452 | TEST_ASSERT_VAL("wrong exclude_kernel", |
| 453 | evsel->attr.exclude_kernel); |
| 454 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 455 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 456 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 457 | |
| 458 | return 0; |
| 459 | } |
| 460 | |
Kan Liang | ffe5978 | 2014-10-07 11:08:52 -0400 | [diff] [blame] | 461 | |
| 462 | static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist) |
| 463 | { |
| 464 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 465 | |
| 466 | /* pmu-event:u */ |
| 467 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 468 | TEST_ASSERT_VAL("wrong exclude_user", |
| 469 | !evsel->attr.exclude_user); |
| 470 | TEST_ASSERT_VAL("wrong exclude_kernel", |
| 471 | evsel->attr.exclude_kernel); |
| 472 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 473 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 474 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
| 475 | |
| 476 | /* cpu/pmu-event/u*/ |
| 477 | evsel = perf_evsel__next(evsel); |
| 478 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 479 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 480 | TEST_ASSERT_VAL("wrong exclude_user", |
| 481 | !evsel->attr.exclude_user); |
| 482 | TEST_ASSERT_VAL("wrong exclude_kernel", |
| 483 | evsel->attr.exclude_kernel); |
| 484 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 485 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 486 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
| 487 | |
| 488 | return 0; |
| 489 | } |
| 490 | |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 491 | static int test__checkterms_simple(struct list_head *terms) |
| 492 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 493 | struct parse_events_term *term; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 494 | |
| 495 | /* config=10 */ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 496 | term = list_entry(terms->next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 497 | TEST_ASSERT_VAL("wrong type term", |
| 498 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); |
| 499 | TEST_ASSERT_VAL("wrong type val", |
| 500 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 501 | TEST_ASSERT_VAL("wrong val", term->val.num == 10); |
| 502 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 503 | |
| 504 | /* config1 */ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 505 | term = list_entry(term->list.next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 506 | TEST_ASSERT_VAL("wrong type term", |
| 507 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); |
| 508 | TEST_ASSERT_VAL("wrong type val", |
| 509 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 510 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); |
| 511 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 512 | |
| 513 | /* config2=3 */ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 514 | term = list_entry(term->list.next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 515 | TEST_ASSERT_VAL("wrong type term", |
| 516 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); |
| 517 | TEST_ASSERT_VAL("wrong type val", |
| 518 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 519 | TEST_ASSERT_VAL("wrong val", term->val.num == 3); |
| 520 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 521 | |
| 522 | /* umask=1*/ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 523 | term = list_entry(term->list.next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 524 | TEST_ASSERT_VAL("wrong type term", |
| 525 | term->type_term == PARSE_EVENTS__TERM_TYPE_USER); |
| 526 | TEST_ASSERT_VAL("wrong type val", |
| 527 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 528 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); |
| 529 | TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); |
| 530 | |
| 531 | return 0; |
| 532 | } |
| 533 | |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 534 | static int test__group1(struct perf_evlist *evlist) |
| 535 | { |
| 536 | struct perf_evsel *evsel, *leader; |
| 537 | |
| 538 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 539 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 540 | |
| 541 | /* instructions:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 542 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 543 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 544 | TEST_ASSERT_VAL("wrong config", |
| 545 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 546 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 547 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 548 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 549 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 550 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 551 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 552 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 553 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 554 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 555 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 556 | |
| 557 | /* cycles:upp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 558 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 559 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 560 | TEST_ASSERT_VAL("wrong config", |
| 561 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 562 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 563 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 564 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 565 | /* use of precise requires exclude_guest */ |
| 566 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 567 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 568 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); |
| 569 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 570 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 571 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 572 | |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | static int test__group2(struct perf_evlist *evlist) |
| 577 | { |
| 578 | struct perf_evsel *evsel, *leader; |
| 579 | |
| 580 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 581 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 582 | |
| 583 | /* faults + :ku modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 584 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 585 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
| 586 | TEST_ASSERT_VAL("wrong config", |
| 587 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); |
| 588 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 589 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 590 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 591 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 592 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 593 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 594 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 595 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 596 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 597 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 598 | |
| 599 | /* cache-references + :u modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 600 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 601 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 602 | TEST_ASSERT_VAL("wrong config", |
| 603 | PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); |
| 604 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 605 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 606 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 607 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 608 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 609 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 610 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 611 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 612 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 613 | |
| 614 | /* cycles:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 615 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 616 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 617 | TEST_ASSERT_VAL("wrong config", |
| 618 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 619 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 620 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 621 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 622 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 623 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 624 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 625 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 626 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 627 | |
| 628 | return 0; |
| 629 | } |
| 630 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 631 | static int test__group3(struct perf_evlist *evlist __maybe_unused) |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 632 | { |
| 633 | struct perf_evsel *evsel, *leader; |
| 634 | |
| 635 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 636 | TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 637 | |
| 638 | /* group1 syscalls:sys_enter_open:H */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 639 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 640 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 641 | TEST_ASSERT_VAL("wrong sample_type", |
| 642 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
| 643 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 644 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 645 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 646 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 647 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 648 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 649 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 650 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 651 | TEST_ASSERT_VAL("wrong group name", |
| 652 | !strcmp(leader->group_name, "group1")); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 653 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 654 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 655 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 656 | |
| 657 | /* group1 cycles:kppp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 658 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 659 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 660 | TEST_ASSERT_VAL("wrong config", |
| 661 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 662 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 663 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 664 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 665 | /* use of precise requires exclude_guest */ |
| 666 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 667 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 668 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); |
| 669 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 670 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 671 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 672 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 673 | |
| 674 | /* group2 cycles + G modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 675 | evsel = leader = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 676 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 677 | TEST_ASSERT_VAL("wrong config", |
| 678 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 679 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 680 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 681 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 682 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 683 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 684 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 685 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 686 | TEST_ASSERT_VAL("wrong group name", |
| 687 | !strcmp(leader->group_name, "group2")); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 688 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 689 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 690 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 691 | |
| 692 | /* group2 1:3 + G modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 693 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 694 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 695 | TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); |
| 696 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 697 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 698 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 699 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 700 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 701 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 702 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 703 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 704 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 705 | |
| 706 | /* instructions:u */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 707 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 708 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 709 | TEST_ASSERT_VAL("wrong config", |
| 710 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 711 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 712 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 713 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 714 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 715 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 716 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 717 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 718 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 719 | |
| 720 | return 0; |
| 721 | } |
| 722 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 723 | static int test__group4(struct perf_evlist *evlist __maybe_unused) |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 724 | { |
| 725 | struct perf_evsel *evsel, *leader; |
| 726 | |
| 727 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 728 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 729 | |
| 730 | /* cycles:u + p */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 731 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 732 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 733 | TEST_ASSERT_VAL("wrong config", |
| 734 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 735 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 736 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 737 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 738 | /* use of precise requires exclude_guest */ |
| 739 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 740 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 741 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); |
| 742 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 743 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 744 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 745 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 746 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 747 | |
| 748 | /* instructions:kp + p */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 749 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 750 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 751 | TEST_ASSERT_VAL("wrong config", |
| 752 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 753 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 754 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 755 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 756 | /* use of precise requires exclude_guest */ |
| 757 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 758 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 759 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); |
| 760 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 761 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 762 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 763 | |
| 764 | return 0; |
| 765 | } |
| 766 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 767 | static int test__group5(struct perf_evlist *evlist __maybe_unused) |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 768 | { |
| 769 | struct perf_evsel *evsel, *leader; |
| 770 | |
| 771 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 772 | TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 773 | |
| 774 | /* cycles + G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 775 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 776 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 777 | TEST_ASSERT_VAL("wrong config", |
| 778 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 779 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 780 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 781 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 782 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 783 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 784 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 785 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 786 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 787 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 788 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 789 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 790 | |
| 791 | /* instructions + G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 792 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 793 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 794 | TEST_ASSERT_VAL("wrong config", |
| 795 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 796 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 797 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 798 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 799 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 800 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 801 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 802 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 803 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 804 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 805 | |
| 806 | /* cycles:G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 807 | evsel = leader = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 808 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 809 | TEST_ASSERT_VAL("wrong config", |
| 810 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 811 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 812 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 813 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 814 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 815 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 816 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 817 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 818 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 819 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 820 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 821 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 822 | |
| 823 | /* instructions:G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 824 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 825 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 826 | TEST_ASSERT_VAL("wrong config", |
| 827 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 828 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 829 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 830 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 831 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 832 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 833 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 834 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 835 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 836 | |
| 837 | /* cycles */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 838 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 839 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 840 | TEST_ASSERT_VAL("wrong config", |
| 841 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 842 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 843 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 844 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 845 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 846 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 847 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 848 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 849 | |
| 850 | return 0; |
| 851 | } |
| 852 | |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 853 | static int test__group_gh1(struct perf_evlist *evlist) |
| 854 | { |
| 855 | struct perf_evsel *evsel, *leader; |
| 856 | |
| 857 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 858 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 859 | |
| 860 | /* cycles + :H group modifier */ |
| 861 | evsel = leader = perf_evlist__first(evlist); |
| 862 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 863 | TEST_ASSERT_VAL("wrong config", |
| 864 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 865 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 866 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 867 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 868 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 869 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 870 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 871 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 872 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 873 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 874 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 875 | |
| 876 | /* cache-misses:G + :H group modifier */ |
| 877 | evsel = perf_evsel__next(evsel); |
| 878 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 879 | TEST_ASSERT_VAL("wrong config", |
| 880 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 881 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 882 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 883 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 884 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 885 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 886 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 887 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 888 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 889 | |
| 890 | return 0; |
| 891 | } |
| 892 | |
| 893 | static int test__group_gh2(struct perf_evlist *evlist) |
| 894 | { |
| 895 | struct perf_evsel *evsel, *leader; |
| 896 | |
| 897 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 898 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 899 | |
| 900 | /* cycles + :G group modifier */ |
| 901 | evsel = leader = perf_evlist__first(evlist); |
| 902 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 903 | TEST_ASSERT_VAL("wrong config", |
| 904 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 905 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 906 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 907 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 908 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 909 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 910 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 911 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 912 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 913 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 914 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 915 | |
| 916 | /* cache-misses:H + :G group modifier */ |
| 917 | evsel = perf_evsel__next(evsel); |
| 918 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 919 | TEST_ASSERT_VAL("wrong config", |
| 920 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 921 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 922 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 923 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 924 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 925 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 926 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 927 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 928 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 929 | |
| 930 | return 0; |
| 931 | } |
| 932 | |
| 933 | static int test__group_gh3(struct perf_evlist *evlist) |
| 934 | { |
| 935 | struct perf_evsel *evsel, *leader; |
| 936 | |
| 937 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 938 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 939 | |
| 940 | /* cycles:G + :u group modifier */ |
| 941 | evsel = leader = perf_evlist__first(evlist); |
| 942 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 943 | TEST_ASSERT_VAL("wrong config", |
| 944 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 945 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 946 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 947 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 948 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 949 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 950 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 951 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 952 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 953 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 954 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 955 | |
| 956 | /* cache-misses:H + :u group modifier */ |
| 957 | evsel = perf_evsel__next(evsel); |
| 958 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 959 | TEST_ASSERT_VAL("wrong config", |
| 960 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 961 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 962 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 963 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 964 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 965 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 966 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 967 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 968 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 969 | |
| 970 | return 0; |
| 971 | } |
| 972 | |
| 973 | static int test__group_gh4(struct perf_evlist *evlist) |
| 974 | { |
| 975 | struct perf_evsel *evsel, *leader; |
| 976 | |
| 977 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 978 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 979 | |
| 980 | /* cycles:G + :uG group modifier */ |
| 981 | evsel = leader = perf_evlist__first(evlist); |
| 982 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 983 | TEST_ASSERT_VAL("wrong config", |
| 984 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 985 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 986 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 987 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 988 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 989 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 990 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 991 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 992 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 993 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 994 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 995 | |
| 996 | /* cache-misses:H + :uG group modifier */ |
| 997 | evsel = perf_evsel__next(evsel); |
| 998 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 999 | TEST_ASSERT_VAL("wrong config", |
| 1000 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 1001 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1002 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1003 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1004 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 1005 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1006 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1007 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1008 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 1009 | |
| 1010 | return 0; |
| 1011 | } |
| 1012 | |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 1013 | static int test__leader_sample1(struct perf_evlist *evlist) |
| 1014 | { |
| 1015 | struct perf_evsel *evsel, *leader; |
| 1016 | |
| 1017 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 1018 | |
| 1019 | /* cycles - sampling group leader */ |
| 1020 | evsel = leader = perf_evlist__first(evlist); |
| 1021 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1022 | TEST_ASSERT_VAL("wrong config", |
| 1023 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 1024 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1025 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 1026 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 1027 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1028 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1029 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1030 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1031 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1032 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1033 | |
| 1034 | /* cache-misses - not sampling */ |
| 1035 | evsel = perf_evsel__next(evsel); |
| 1036 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1037 | TEST_ASSERT_VAL("wrong config", |
| 1038 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 1039 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1040 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 1041 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 1042 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1043 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1044 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1045 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1046 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1047 | |
| 1048 | /* branch-misses - not sampling */ |
| 1049 | evsel = perf_evsel__next(evsel); |
| 1050 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1051 | TEST_ASSERT_VAL("wrong config", |
| 1052 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); |
| 1053 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1054 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 1055 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 1056 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1057 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1058 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1059 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1060 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1061 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1062 | |
| 1063 | return 0; |
| 1064 | } |
| 1065 | |
| 1066 | static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused) |
| 1067 | { |
| 1068 | struct perf_evsel *evsel, *leader; |
| 1069 | |
| 1070 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 1071 | |
| 1072 | /* instructions - sampling group leader */ |
| 1073 | evsel = leader = perf_evlist__first(evlist); |
| 1074 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1075 | TEST_ASSERT_VAL("wrong config", |
| 1076 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 1077 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1078 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1079 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1080 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1081 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1082 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1083 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1084 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1085 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1086 | |
| 1087 | /* branch-misses - not sampling */ |
| 1088 | evsel = perf_evsel__next(evsel); |
| 1089 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1090 | TEST_ASSERT_VAL("wrong config", |
| 1091 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); |
| 1092 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1093 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1094 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1095 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1096 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1097 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1098 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1099 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1100 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1101 | |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1105 | static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) |
| 1106 | { |
| 1107 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 1108 | |
| 1109 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1110 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1111 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1112 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 1113 | TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); |
| 1114 | |
| 1115 | return test__checkevent_symbolic_name(evlist); |
| 1116 | } |
| 1117 | |
| 1118 | static int test__pinned_group(struct perf_evlist *evlist) |
| 1119 | { |
| 1120 | struct perf_evsel *evsel, *leader; |
| 1121 | |
| 1122 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 1123 | |
| 1124 | /* cycles - group leader */ |
| 1125 | evsel = leader = perf_evlist__first(evlist); |
| 1126 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1127 | TEST_ASSERT_VAL("wrong config", |
| 1128 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 1129 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1130 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1131 | TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); |
| 1132 | |
| 1133 | /* cache-misses - can not be pinned, but will go on with the leader */ |
| 1134 | evsel = perf_evsel__next(evsel); |
| 1135 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1136 | TEST_ASSERT_VAL("wrong config", |
| 1137 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 1138 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
| 1139 | |
| 1140 | /* branch-misses - ditto */ |
| 1141 | evsel = perf_evsel__next(evsel); |
| 1142 | TEST_ASSERT_VAL("wrong config", |
| 1143 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); |
| 1144 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
| 1145 | |
| 1146 | return 0; |
| 1147 | } |
| 1148 | |
Jacob Shin | ec32398 | 2014-05-29 17:26:52 +0200 | [diff] [blame] | 1149 | static int test__checkevent_breakpoint_len(struct perf_evlist *evlist) |
| 1150 | { |
| 1151 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 1152 | |
| 1153 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 1154 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 1155 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 1156 | TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == |
| 1157 | evsel->attr.bp_type); |
| 1158 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 == |
| 1159 | evsel->attr.bp_len); |
| 1160 | |
| 1161 | return 0; |
| 1162 | } |
| 1163 | |
| 1164 | static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist) |
| 1165 | { |
| 1166 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 1167 | |
| 1168 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 1169 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 1170 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 1171 | TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W == |
| 1172 | evsel->attr.bp_type); |
| 1173 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 == |
| 1174 | evsel->attr.bp_len); |
| 1175 | |
| 1176 | return 0; |
| 1177 | } |
| 1178 | |
| 1179 | static int |
| 1180 | test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist) |
| 1181 | { |
| 1182 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 1183 | |
| 1184 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1185 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1186 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1187 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1188 | |
| 1189 | return test__checkevent_breakpoint_rw(evlist); |
| 1190 | } |
| 1191 | |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1192 | static int count_tracepoints(void) |
| 1193 | { |
| 1194 | char events_path[PATH_MAX]; |
| 1195 | struct dirent *events_ent; |
Steven Rostedt (Red Hat) | 23773ca | 2015-02-02 14:35:07 -0500 | [diff] [blame^] | 1196 | const char *mountpoint; |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1197 | DIR *events_dir; |
| 1198 | int cnt = 0; |
| 1199 | |
Steven Rostedt (Red Hat) | 23773ca | 2015-02-02 14:35:07 -0500 | [diff] [blame^] | 1200 | mountpoint = tracefs_find_mountpoint(); |
| 1201 | if (mountpoint) { |
| 1202 | scnprintf(events_path, PATH_MAX, "%s/events", |
| 1203 | mountpoint); |
| 1204 | } else { |
| 1205 | mountpoint = debugfs_find_mountpoint(); |
| 1206 | scnprintf(events_path, PATH_MAX, "%s/tracing/events", |
| 1207 | mountpoint); |
| 1208 | } |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1209 | |
| 1210 | events_dir = opendir(events_path); |
| 1211 | |
| 1212 | TEST_ASSERT_VAL("Can't open events dir", events_dir); |
| 1213 | |
| 1214 | while ((events_ent = readdir(events_dir))) { |
| 1215 | char sys_path[PATH_MAX]; |
| 1216 | struct dirent *sys_ent; |
| 1217 | DIR *sys_dir; |
| 1218 | |
| 1219 | if (!strcmp(events_ent->d_name, ".") |
| 1220 | || !strcmp(events_ent->d_name, "..") |
| 1221 | || !strcmp(events_ent->d_name, "enable") |
| 1222 | || !strcmp(events_ent->d_name, "header_event") |
| 1223 | || !strcmp(events_ent->d_name, "header_page")) |
| 1224 | continue; |
| 1225 | |
| 1226 | scnprintf(sys_path, PATH_MAX, "%s/%s", |
| 1227 | events_path, events_ent->d_name); |
| 1228 | |
| 1229 | sys_dir = opendir(sys_path); |
| 1230 | TEST_ASSERT_VAL("Can't open sys dir", sys_dir); |
| 1231 | |
| 1232 | while ((sys_ent = readdir(sys_dir))) { |
| 1233 | if (!strcmp(sys_ent->d_name, ".") |
| 1234 | || !strcmp(sys_ent->d_name, "..") |
| 1235 | || !strcmp(sys_ent->d_name, "enable") |
| 1236 | || !strcmp(sys_ent->d_name, "filter")) |
| 1237 | continue; |
| 1238 | |
| 1239 | cnt++; |
| 1240 | } |
| 1241 | |
| 1242 | closedir(sys_dir); |
| 1243 | } |
| 1244 | |
| 1245 | closedir(events_dir); |
| 1246 | return cnt; |
| 1247 | } |
| 1248 | |
| 1249 | static int test__all_tracepoints(struct perf_evlist *evlist) |
| 1250 | { |
| 1251 | TEST_ASSERT_VAL("wrong events count", |
| 1252 | count_tracepoints() == evlist->nr_entries); |
| 1253 | |
| 1254 | return test__checkevent_tracepoint_multi(evlist); |
| 1255 | } |
| 1256 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1257 | struct evlist_test { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1258 | const char *name; |
| 1259 | __u32 type; |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1260 | const int id; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1261 | int (*check)(struct perf_evlist *evlist); |
| 1262 | }; |
| 1263 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1264 | static struct evlist_test test__events[] = { |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1265 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1266 | .name = "syscalls:sys_enter_open", |
| 1267 | .check = test__checkevent_tracepoint, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1268 | .id = 0, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1269 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1270 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1271 | .name = "syscalls:*", |
| 1272 | .check = test__checkevent_tracepoint_multi, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1273 | .id = 1, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1274 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1275 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1276 | .name = "r1a", |
| 1277 | .check = test__checkevent_raw, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1278 | .id = 2, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1279 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1280 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1281 | .name = "1:1", |
| 1282 | .check = test__checkevent_numeric, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1283 | .id = 3, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1284 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1285 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1286 | .name = "instructions", |
| 1287 | .check = test__checkevent_symbolic_name, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1288 | .id = 4, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1289 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1290 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1291 | .name = "cycles/period=100000,config2/", |
| 1292 | .check = test__checkevent_symbolic_name_config, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1293 | .id = 5, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1294 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1295 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1296 | .name = "faults", |
| 1297 | .check = test__checkevent_symbolic_alias, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1298 | .id = 6, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1299 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1300 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1301 | .name = "L1-dcache-load-miss", |
| 1302 | .check = test__checkevent_genhw, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1303 | .id = 7, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1304 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1305 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1306 | .name = "mem:0", |
| 1307 | .check = test__checkevent_breakpoint, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1308 | .id = 8, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1309 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1310 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1311 | .name = "mem:0:x", |
| 1312 | .check = test__checkevent_breakpoint_x, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1313 | .id = 9, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1314 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1315 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1316 | .name = "mem:0:r", |
| 1317 | .check = test__checkevent_breakpoint_r, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1318 | .id = 10, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1319 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1320 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1321 | .name = "mem:0:w", |
| 1322 | .check = test__checkevent_breakpoint_w, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1323 | .id = 11, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1324 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1325 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1326 | .name = "syscalls:sys_enter_open:k", |
| 1327 | .check = test__checkevent_tracepoint_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1328 | .id = 12, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1329 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1330 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1331 | .name = "syscalls:*:u", |
| 1332 | .check = test__checkevent_tracepoint_multi_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1333 | .id = 13, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1334 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1335 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1336 | .name = "r1a:kp", |
| 1337 | .check = test__checkevent_raw_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1338 | .id = 14, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1339 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1340 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1341 | .name = "1:1:hp", |
| 1342 | .check = test__checkevent_numeric_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1343 | .id = 15, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1344 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1345 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1346 | .name = "instructions:h", |
| 1347 | .check = test__checkevent_symbolic_name_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1348 | .id = 16, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1349 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1350 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1351 | .name = "faults:u", |
| 1352 | .check = test__checkevent_symbolic_alias_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1353 | .id = 17, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1354 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1355 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1356 | .name = "L1-dcache-load-miss:kp", |
| 1357 | .check = test__checkevent_genhw_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1358 | .id = 18, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1359 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1360 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1361 | .name = "mem:0:u", |
| 1362 | .check = test__checkevent_breakpoint_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1363 | .id = 19, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1364 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1365 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1366 | .name = "mem:0:x:k", |
| 1367 | .check = test__checkevent_breakpoint_x_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1368 | .id = 20, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1369 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1370 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1371 | .name = "mem:0:r:hp", |
| 1372 | .check = test__checkevent_breakpoint_r_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1373 | .id = 21, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1374 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1375 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1376 | .name = "mem:0:w:up", |
| 1377 | .check = test__checkevent_breakpoint_w_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1378 | .id = 22, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1379 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1380 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1381 | .name = "r1,syscalls:sys_enter_open:k,1:1:hp", |
| 1382 | .check = test__checkevent_list, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1383 | .id = 23, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1384 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1385 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1386 | .name = "instructions:G", |
| 1387 | .check = test__checkevent_exclude_host_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1388 | .id = 24, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1389 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1390 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1391 | .name = "instructions:H", |
| 1392 | .check = test__checkevent_exclude_guest_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1393 | .id = 25, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1394 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1395 | { |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 1396 | .name = "mem:0:rw", |
| 1397 | .check = test__checkevent_breakpoint_rw, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1398 | .id = 26, |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 1399 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1400 | { |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 1401 | .name = "mem:0:rw:kp", |
| 1402 | .check = test__checkevent_breakpoint_rw_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1403 | .id = 27, |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 1404 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1405 | { |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1406 | .name = "{instructions:k,cycles:upp}", |
| 1407 | .check = test__group1, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1408 | .id = 28, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1409 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1410 | { |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1411 | .name = "{faults:k,cache-references}:u,cycles:k", |
| 1412 | .check = test__group2, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1413 | .id = 29, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1414 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1415 | { |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1416 | .name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", |
| 1417 | .check = test__group3, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1418 | .id = 30, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1419 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1420 | { |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1421 | .name = "{cycles:u,instructions:kp}:p", |
| 1422 | .check = test__group4, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1423 | .id = 31, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1424 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1425 | { |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1426 | .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", |
| 1427 | .check = test__group5, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1428 | .id = 32, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1429 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1430 | { |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1431 | .name = "*:*", |
| 1432 | .check = test__all_tracepoints, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1433 | .id = 33, |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1434 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1435 | { |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1436 | .name = "{cycles,cache-misses:G}:H", |
| 1437 | .check = test__group_gh1, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1438 | .id = 34, |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1439 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1440 | { |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1441 | .name = "{cycles,cache-misses:H}:G", |
| 1442 | .check = test__group_gh2, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1443 | .id = 35, |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1444 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1445 | { |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1446 | .name = "{cycles:G,cache-misses:H}:u", |
| 1447 | .check = test__group_gh3, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1448 | .id = 36, |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1449 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1450 | { |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1451 | .name = "{cycles:G,cache-misses:H}:uG", |
| 1452 | .check = test__group_gh4, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1453 | .id = 37, |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1454 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1455 | { |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 1456 | .name = "{cycles,cache-misses,branch-misses}:S", |
| 1457 | .check = test__leader_sample1, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1458 | .id = 38, |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 1459 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1460 | { |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 1461 | .name = "{instructions,branch-misses}:Su", |
| 1462 | .check = test__leader_sample2, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1463 | .id = 39, |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 1464 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1465 | { |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1466 | .name = "instructions:uDp", |
| 1467 | .check = test__checkevent_pinned_modifier, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1468 | .id = 40, |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1469 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1470 | { |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1471 | .name = "{cycles,cache-misses,branch-misses}:D", |
| 1472 | .check = test__pinned_group, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1473 | .id = 41, |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1474 | }, |
Jacob Shin | ec32398 | 2014-05-29 17:26:52 +0200 | [diff] [blame] | 1475 | { |
| 1476 | .name = "mem:0/1", |
| 1477 | .check = test__checkevent_breakpoint_len, |
| 1478 | .id = 42, |
| 1479 | }, |
| 1480 | { |
| 1481 | .name = "mem:0/2:w", |
| 1482 | .check = test__checkevent_breakpoint_len_w, |
| 1483 | .id = 43, |
| 1484 | }, |
| 1485 | { |
| 1486 | .name = "mem:0/4:rw:u", |
| 1487 | .check = test__checkevent_breakpoint_len_rw_modifier, |
| 1488 | .id = 44 |
| 1489 | }, |
Alexander Yarygin | c0bc8c6 | 2014-04-25 17:34:07 +0200 | [diff] [blame] | 1490 | #if defined(__s390x__) |
| 1491 | { |
| 1492 | .name = "kvm-s390:kvm_s390_create_vm", |
| 1493 | .check = test__checkevent_tracepoint, |
| 1494 | .id = 100, |
| 1495 | }, |
| 1496 | #endif |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1497 | }; |
| 1498 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1499 | static struct evlist_test test__events_pmu[] = { |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1500 | { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1501 | .name = "cpu/config=10,config1,config2=3,period=1000/u", |
| 1502 | .check = test__checkevent_pmu, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1503 | .id = 0, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1504 | }, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1505 | { |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 1506 | .name = "cpu/config=1,name=krava/u,cpu/config=2/u", |
| 1507 | .check = test__checkevent_pmu_name, |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1508 | .id = 1, |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 1509 | }, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1510 | }; |
| 1511 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1512 | struct terms_test { |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1513 | const char *str; |
| 1514 | __u32 type; |
| 1515 | int (*check)(struct list_head *terms); |
| 1516 | }; |
| 1517 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1518 | static struct terms_test test__terms[] = { |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1519 | [0] = { |
| 1520 | .str = "config=10,config1,config2=3,umask=1", |
| 1521 | .check = test__checkterms_simple, |
| 1522 | }, |
| 1523 | }; |
| 1524 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1525 | static int test_event(struct evlist_test *e) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1526 | { |
| 1527 | struct perf_evlist *evlist; |
| 1528 | int ret; |
| 1529 | |
Namhyung Kim | 334fe7a | 2013-03-11 16:43:12 +0900 | [diff] [blame] | 1530 | evlist = perf_evlist__new(); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1531 | if (evlist == NULL) |
| 1532 | return -ENOMEM; |
| 1533 | |
Jiri Olsa | d8f7bbc | 2013-01-15 14:39:51 +0100 | [diff] [blame] | 1534 | ret = parse_events(evlist, e->name); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1535 | if (ret) { |
| 1536 | pr_debug("failed to parse event '%s', err %d\n", |
| 1537 | e->name, ret); |
Arnaldo Carvalho de Melo | 2d4352c | 2014-01-03 17:30:04 -0300 | [diff] [blame] | 1538 | } else { |
| 1539 | ret = e->check(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1540 | } |
Arnaldo Carvalho de Melo | 48000a1 | 2014-12-17 17:24:45 -0300 | [diff] [blame] | 1541 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1542 | perf_evlist__delete(evlist); |
| 1543 | |
| 1544 | return ret; |
| 1545 | } |
| 1546 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1547 | static int test_events(struct evlist_test *events, unsigned cnt) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1548 | { |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1549 | int ret1, ret2 = 0; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1550 | unsigned i; |
| 1551 | |
| 1552 | for (i = 0; i < cnt; i++) { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1553 | struct evlist_test *e = &events[i]; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1554 | |
Alexander Yarygin | 615b8f9 | 2014-04-25 17:34:06 +0200 | [diff] [blame] | 1555 | pr_debug("running test %d '%s'\n", e->id, e->name); |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1556 | ret1 = test_event(e); |
| 1557 | if (ret1) |
| 1558 | ret2 = ret1; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1559 | } |
| 1560 | |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1561 | return ret2; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1562 | } |
| 1563 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1564 | static int test_term(struct terms_test *t) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1565 | { |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1566 | struct list_head terms; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1567 | int ret; |
| 1568 | |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1569 | INIT_LIST_HEAD(&terms); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1570 | |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1571 | ret = parse_events_terms(&terms, t->str); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1572 | if (ret) { |
| 1573 | pr_debug("failed to parse terms '%s', err %d\n", |
| 1574 | t->str , ret); |
| 1575 | return ret; |
| 1576 | } |
| 1577 | |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1578 | ret = t->check(&terms); |
| 1579 | parse_events__free_terms(&terms); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1580 | |
| 1581 | return ret; |
| 1582 | } |
| 1583 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1584 | static int test_terms(struct terms_test *terms, unsigned cnt) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1585 | { |
| 1586 | int ret = 0; |
| 1587 | unsigned i; |
| 1588 | |
| 1589 | for (i = 0; i < cnt; i++) { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1590 | struct terms_test *t = &terms[i]; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1591 | |
| 1592 | pr_debug("running test %d '%s'\n", i, t->str); |
| 1593 | ret = test_term(t); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1594 | if (ret) |
| 1595 | break; |
| 1596 | } |
| 1597 | |
| 1598 | return ret; |
| 1599 | } |
| 1600 | |
| 1601 | static int test_pmu(void) |
| 1602 | { |
| 1603 | struct stat st; |
| 1604 | char path[PATH_MAX]; |
| 1605 | int ret; |
| 1606 | |
| 1607 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", |
Arnaldo Carvalho de Melo | cf38fad | 2013-11-05 14:48:50 -0300 | [diff] [blame] | 1608 | sysfs__mountpoint()); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1609 | |
| 1610 | ret = stat(path, &st); |
| 1611 | if (ret) |
Masanari Iida | 3fd44cd | 2012-07-18 01:20:59 +0900 | [diff] [blame] | 1612 | pr_debug("omitting PMU cpu tests\n"); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1613 | return !ret; |
| 1614 | } |
| 1615 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1616 | static int test_pmu_events(void) |
| 1617 | { |
| 1618 | struct stat st; |
| 1619 | char path[PATH_MAX]; |
| 1620 | struct dirent *ent; |
| 1621 | DIR *dir; |
| 1622 | int ret; |
| 1623 | |
| 1624 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", |
Arnaldo Carvalho de Melo | cf38fad | 2013-11-05 14:48:50 -0300 | [diff] [blame] | 1625 | sysfs__mountpoint()); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1626 | |
| 1627 | ret = stat(path, &st); |
| 1628 | if (ret) { |
Masanari Iida | a895d57 | 2013-04-09 02:06:50 +0900 | [diff] [blame] | 1629 | pr_debug("omitting PMU cpu events tests\n"); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1630 | return 0; |
| 1631 | } |
| 1632 | |
| 1633 | dir = opendir(path); |
| 1634 | if (!dir) { |
| 1635 | pr_debug("can't open pmu event dir"); |
| 1636 | return -1; |
| 1637 | } |
| 1638 | |
| 1639 | while (!ret && (ent = readdir(dir))) { |
| 1640 | #define MAX_NAME 100 |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1641 | struct evlist_test e; |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1642 | char name[MAX_NAME]; |
| 1643 | |
| 1644 | if (!strcmp(ent->d_name, ".") || |
| 1645 | !strcmp(ent->d_name, "..")) |
| 1646 | continue; |
| 1647 | |
| 1648 | snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name); |
| 1649 | |
| 1650 | e.name = name; |
| 1651 | e.check = test__checkevent_pmu_events; |
| 1652 | |
| 1653 | ret = test_event(&e); |
Kan Liang | ffe5978 | 2014-10-07 11:08:52 -0400 | [diff] [blame] | 1654 | if (ret) |
| 1655 | break; |
| 1656 | snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name); |
| 1657 | e.name = name; |
| 1658 | e.check = test__checkevent_pmu_events_mix; |
| 1659 | ret = test_event(&e); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1660 | #undef MAX_NAME |
| 1661 | } |
| 1662 | |
| 1663 | closedir(dir); |
| 1664 | return ret; |
| 1665 | } |
| 1666 | |
Jiri Olsa | c81251e | 2012-11-10 01:46:51 +0100 | [diff] [blame] | 1667 | int test__parse_events(void) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1668 | { |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1669 | int ret1, ret2 = 0; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1670 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1671 | #define TEST_EVENTS(tests) \ |
| 1672 | do { \ |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1673 | ret1 = test_events(tests, ARRAY_SIZE(tests)); \ |
| 1674 | if (!ret2) \ |
| 1675 | ret2 = ret1; \ |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1676 | } while (0) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1677 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1678 | TEST_EVENTS(test__events); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1679 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1680 | if (test_pmu()) |
| 1681 | TEST_EVENTS(test__events_pmu); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1682 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1683 | if (test_pmu()) { |
| 1684 | int ret = test_pmu_events(); |
| 1685 | if (ret) |
| 1686 | return ret; |
| 1687 | } |
| 1688 | |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1689 | ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); |
| 1690 | if (!ret2) |
| 1691 | ret2 = ret1; |
| 1692 | |
| 1693 | return ret2; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1694 | } |