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" |
| 5 | #include "sysfs.h" |
| 6 | #include "../../../include/linux/hw_breakpoint.h" |
| 7 | |
| 8 | #define TEST_ASSERT_VAL(text, cond) \ |
| 9 | do { \ |
| 10 | if (!(cond)) { \ |
| 11 | pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \ |
| 12 | return -1; \ |
| 13 | } \ |
| 14 | } while (0) |
| 15 | |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 16 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ |
| 17 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) |
| 18 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 19 | static int test__checkevent_tracepoint(struct perf_evlist *evlist) |
| 20 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 21 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 22 | |
| 23 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 24 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 25 | TEST_ASSERT_VAL("wrong sample_type", |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 26 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 27 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) |
| 32 | { |
| 33 | struct perf_evsel *evsel; |
| 34 | |
| 35 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); |
| 36 | |
| 37 | list_for_each_entry(evsel, &evlist->entries, node) { |
| 38 | TEST_ASSERT_VAL("wrong type", |
| 39 | PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 40 | TEST_ASSERT_VAL("wrong sample_type", |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 41 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 42 | TEST_ASSERT_VAL("wrong sample_period", |
| 43 | 1 == evsel->attr.sample_period); |
| 44 | } |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | static int test__checkevent_raw(struct perf_evlist *evlist) |
| 49 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 50 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 51 | |
| 52 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 53 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 54 | TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config); |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static int test__checkevent_numeric(struct perf_evlist *evlist) |
| 59 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 60 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 61 | |
| 62 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 63 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 64 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | static int test__checkevent_symbolic_name(struct perf_evlist *evlist) |
| 69 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 70 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 71 | |
| 72 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 73 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 74 | TEST_ASSERT_VAL("wrong config", |
| 75 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) |
| 80 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 81 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 82 | |
| 83 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 84 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 85 | TEST_ASSERT_VAL("wrong config", |
| 86 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 87 | TEST_ASSERT_VAL("wrong period", |
| 88 | 100000 == evsel->attr.sample_period); |
| 89 | TEST_ASSERT_VAL("wrong config1", |
| 90 | 0 == evsel->attr.config1); |
| 91 | TEST_ASSERT_VAL("wrong config2", |
| 92 | 1 == evsel->attr.config2); |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) |
| 97 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 98 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 99 | |
| 100 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 101 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
| 102 | TEST_ASSERT_VAL("wrong config", |
| 103 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static int test__checkevent_genhw(struct perf_evlist *evlist) |
| 108 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 109 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 110 | |
| 111 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 112 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); |
| 113 | TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config); |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | static int test__checkevent_breakpoint(struct perf_evlist *evlist) |
| 118 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 119 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 120 | |
| 121 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 122 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 123 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 124 | TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == |
| 125 | evsel->attr.bp_type); |
| 126 | TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == |
| 127 | evsel->attr.bp_len); |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) |
| 132 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 133 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 134 | |
| 135 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 136 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 137 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 138 | TEST_ASSERT_VAL("wrong bp_type", |
| 139 | HW_BREAKPOINT_X == evsel->attr.bp_type); |
| 140 | TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len); |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) |
| 145 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 146 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 147 | |
| 148 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 149 | TEST_ASSERT_VAL("wrong type", |
| 150 | PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 151 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 152 | TEST_ASSERT_VAL("wrong bp_type", |
| 153 | HW_BREAKPOINT_R == evsel->attr.bp_type); |
| 154 | TEST_ASSERT_VAL("wrong bp_len", |
| 155 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) |
| 160 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 161 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 162 | |
| 163 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 164 | TEST_ASSERT_VAL("wrong type", |
| 165 | PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 166 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 167 | TEST_ASSERT_VAL("wrong bp_type", |
| 168 | HW_BREAKPOINT_W == evsel->attr.bp_type); |
| 169 | TEST_ASSERT_VAL("wrong bp_len", |
| 170 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); |
| 171 | return 0; |
| 172 | } |
| 173 | |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 174 | static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) |
| 175 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 176 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 177 | |
| 178 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 179 | TEST_ASSERT_VAL("wrong type", |
| 180 | PERF_TYPE_BREAKPOINT == evsel->attr.type); |
| 181 | TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); |
| 182 | TEST_ASSERT_VAL("wrong bp_type", |
| 183 | (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type); |
| 184 | TEST_ASSERT_VAL("wrong bp_len", |
| 185 | HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); |
| 186 | return 0; |
| 187 | } |
| 188 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 189 | static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) |
| 190 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 191 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 192 | |
| 193 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 194 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 195 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 196 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 197 | |
| 198 | return test__checkevent_tracepoint(evlist); |
| 199 | } |
| 200 | |
| 201 | static int |
| 202 | test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) |
| 203 | { |
| 204 | struct perf_evsel *evsel; |
| 205 | |
| 206 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); |
| 207 | |
| 208 | list_for_each_entry(evsel, &evlist->entries, node) { |
| 209 | TEST_ASSERT_VAL("wrong exclude_user", |
| 210 | !evsel->attr.exclude_user); |
| 211 | TEST_ASSERT_VAL("wrong exclude_kernel", |
| 212 | evsel->attr.exclude_kernel); |
| 213 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 214 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 215 | } |
| 216 | |
| 217 | return test__checkevent_tracepoint_multi(evlist); |
| 218 | } |
| 219 | |
| 220 | static int test__checkevent_raw_modifier(struct perf_evlist *evlist) |
| 221 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 222 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 223 | |
| 224 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 225 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 226 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 227 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 228 | |
| 229 | return test__checkevent_raw(evlist); |
| 230 | } |
| 231 | |
| 232 | static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) |
| 233 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 234 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 235 | |
| 236 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 237 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 238 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 239 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 240 | |
| 241 | return test__checkevent_numeric(evlist); |
| 242 | } |
| 243 | |
| 244 | static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) |
| 245 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 246 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 247 | |
| 248 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 249 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 250 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 251 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 252 | |
| 253 | return test__checkevent_symbolic_name(evlist); |
| 254 | } |
| 255 | |
| 256 | static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) |
| 257 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 258 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 259 | |
| 260 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 261 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 262 | |
| 263 | return test__checkevent_symbolic_name(evlist); |
| 264 | } |
| 265 | |
| 266 | static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) |
| 267 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 268 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 269 | |
| 270 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 271 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 272 | |
| 273 | return test__checkevent_symbolic_name(evlist); |
| 274 | } |
| 275 | |
| 276 | static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) |
| 277 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 278 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 279 | |
| 280 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 281 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 282 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 283 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 284 | |
| 285 | return test__checkevent_symbolic_alias(evlist); |
| 286 | } |
| 287 | |
| 288 | static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) |
| 289 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 290 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 291 | |
| 292 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 293 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 294 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 295 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 296 | |
| 297 | return test__checkevent_genhw(evlist); |
| 298 | } |
| 299 | |
| 300 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) |
| 301 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 302 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 303 | |
| 304 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 305 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 306 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 307 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 308 | TEST_ASSERT_VAL("wrong name", |
| 309 | !strcmp(perf_evsel__name(evsel), "mem:0x0:rw:u")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 310 | |
| 311 | return test__checkevent_breakpoint(evlist); |
| 312 | } |
| 313 | |
| 314 | static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) |
| 315 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 316 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 317 | |
| 318 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 319 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 320 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 321 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 322 | TEST_ASSERT_VAL("wrong name", |
| 323 | !strcmp(perf_evsel__name(evsel), "mem:0x0:x:k")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 324 | |
| 325 | return test__checkevent_breakpoint_x(evlist); |
| 326 | } |
| 327 | |
| 328 | static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) |
| 329 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 330 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 331 | |
| 332 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 333 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 334 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 335 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 336 | TEST_ASSERT_VAL("wrong name", |
| 337 | !strcmp(perf_evsel__name(evsel), "mem:0x0:r:hp")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 338 | |
| 339 | return test__checkevent_breakpoint_r(evlist); |
| 340 | } |
| 341 | |
| 342 | static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) |
| 343 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 344 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 345 | |
| 346 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 347 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 348 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 349 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 350 | TEST_ASSERT_VAL("wrong name", |
| 351 | !strcmp(perf_evsel__name(evsel), "mem:0x0:w:up")); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 352 | |
| 353 | return test__checkevent_breakpoint_w(evlist); |
| 354 | } |
| 355 | |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 356 | static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) |
| 357 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 358 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 359 | |
| 360 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 361 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 362 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 363 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
Jiri Olsa | 287e74a | 2012-06-28 23:18:49 +0200 | [diff] [blame] | 364 | TEST_ASSERT_VAL("wrong name", |
| 365 | !strcmp(perf_evsel__name(evsel), "mem:0x0:rw:kp")); |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 366 | |
| 367 | return test__checkevent_breakpoint_rw(evlist); |
| 368 | } |
| 369 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 370 | static int test__checkevent_pmu(struct perf_evlist *evlist) |
| 371 | { |
| 372 | |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 373 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 374 | |
| 375 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 376 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 377 | TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); |
| 378 | TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); |
| 379 | TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); |
| 380 | TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period); |
| 381 | |
| 382 | return 0; |
| 383 | } |
| 384 | |
| 385 | static int test__checkevent_list(struct perf_evlist *evlist) |
| 386 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 387 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 388 | |
| 389 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 390 | |
| 391 | /* r1 */ |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 392 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 393 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
| 394 | TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); |
| 395 | TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2); |
| 396 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 397 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 398 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 399 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 400 | |
| 401 | /* syscalls:sys_enter_open:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 402 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 403 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 404 | TEST_ASSERT_VAL("wrong sample_type", |
Jiri Olsa | 30f31c0 | 2012-08-01 14:48:58 +0200 | [diff] [blame] | 405 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 406 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 407 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 408 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 409 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 410 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 411 | |
| 412 | /* 1:1:hp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 413 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 414 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 415 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
| 416 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 417 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 418 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 419 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 424 | static int test__checkevent_pmu_name(struct perf_evlist *evlist) |
| 425 | { |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 426 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 427 | |
Jiri Olsa | 7a25b2d | 2012-06-21 12:25:16 +0200 | [diff] [blame] | 428 | /* cpu/config=1,name=krava/u */ |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 429 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 430 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 431 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
Arnaldo Carvalho de Melo | 22c8b84 | 2012-06-12 13:55:13 -0300 | [diff] [blame] | 432 | TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 433 | |
Jiri Olsa | 7a25b2d | 2012-06-21 12:25:16 +0200 | [diff] [blame] | 434 | /* cpu/config=2/u" */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 435 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 436 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 437 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 438 | TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); |
Jiri Olsa | 7a25b2d | 2012-06-21 12:25:16 +0200 | [diff] [blame] | 439 | TEST_ASSERT_VAL("wrong name", |
| 440 | !strcmp(perf_evsel__name(evsel), "raw 0x2:u")); |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 441 | |
| 442 | return 0; |
| 443 | } |
| 444 | |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 445 | static int test__checkterms_simple(struct list_head *terms) |
| 446 | { |
| 447 | struct parse_events__term *term; |
| 448 | |
| 449 | /* config=10 */ |
| 450 | term = list_entry(terms->next, struct parse_events__term, list); |
| 451 | TEST_ASSERT_VAL("wrong type term", |
| 452 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); |
| 453 | TEST_ASSERT_VAL("wrong type val", |
| 454 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 455 | TEST_ASSERT_VAL("wrong val", term->val.num == 10); |
| 456 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 457 | |
| 458 | /* config1 */ |
| 459 | term = list_entry(term->list.next, struct parse_events__term, list); |
| 460 | TEST_ASSERT_VAL("wrong type term", |
| 461 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); |
| 462 | TEST_ASSERT_VAL("wrong type val", |
| 463 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 464 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); |
| 465 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 466 | |
| 467 | /* config2=3 */ |
| 468 | term = list_entry(term->list.next, struct parse_events__term, list); |
| 469 | TEST_ASSERT_VAL("wrong type term", |
| 470 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); |
| 471 | TEST_ASSERT_VAL("wrong type val", |
| 472 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 473 | TEST_ASSERT_VAL("wrong val", term->val.num == 3); |
| 474 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 475 | |
| 476 | /* umask=1*/ |
| 477 | term = list_entry(term->list.next, struct parse_events__term, list); |
| 478 | TEST_ASSERT_VAL("wrong type term", |
| 479 | term->type_term == PARSE_EVENTS__TERM_TYPE_USER); |
| 480 | TEST_ASSERT_VAL("wrong type val", |
| 481 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 482 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); |
| 483 | TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); |
| 484 | |
| 485 | return 0; |
| 486 | } |
| 487 | |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 488 | static int test__group1(struct perf_evlist *evlist) |
| 489 | { |
| 490 | struct perf_evsel *evsel, *leader; |
| 491 | |
| 492 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 493 | |
| 494 | /* instructions:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 495 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 496 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 497 | TEST_ASSERT_VAL("wrong config", |
| 498 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 499 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 500 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 501 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 502 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 503 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 504 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 505 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 506 | |
| 507 | /* cycles:upp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 508 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 509 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 510 | TEST_ASSERT_VAL("wrong config", |
| 511 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 512 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 513 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 514 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 515 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 516 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 517 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); |
| 518 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 519 | |
| 520 | return 0; |
| 521 | } |
| 522 | |
| 523 | static int test__group2(struct perf_evlist *evlist) |
| 524 | { |
| 525 | struct perf_evsel *evsel, *leader; |
| 526 | |
| 527 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 528 | |
| 529 | /* faults + :ku modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 530 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 531 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
| 532 | TEST_ASSERT_VAL("wrong config", |
| 533 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); |
| 534 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 535 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 536 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 537 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 538 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 539 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 540 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 541 | |
| 542 | /* cache-references + :u modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 543 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 544 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 545 | TEST_ASSERT_VAL("wrong config", |
| 546 | PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); |
| 547 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 548 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 549 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 550 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 551 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 552 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 553 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 554 | |
| 555 | /* cycles:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 556 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 557 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 558 | TEST_ASSERT_VAL("wrong config", |
| 559 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 560 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 561 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 562 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 563 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 564 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 565 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 566 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 567 | |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | static int test__group3(struct perf_evlist *evlist __used) |
| 572 | { |
| 573 | struct perf_evsel *evsel, *leader; |
| 574 | |
| 575 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
| 576 | |
| 577 | /* group1 syscalls:sys_enter_open:H */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 578 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 579 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 580 | TEST_ASSERT_VAL("wrong sample_type", |
| 581 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
| 582 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 583 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 584 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 585 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 586 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 587 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 588 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 589 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 590 | TEST_ASSERT_VAL("wrong group name", |
| 591 | !strcmp(leader->group_name, "group1")); |
| 592 | |
| 593 | /* group1 cycles:kppp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 594 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 595 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 596 | TEST_ASSERT_VAL("wrong config", |
| 597 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 598 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 599 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 600 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 601 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 602 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 603 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); |
| 604 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 605 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 606 | |
| 607 | /* group2 cycles + G modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 608 | evsel = leader = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 609 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 610 | TEST_ASSERT_VAL("wrong config", |
| 611 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 612 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 613 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 614 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 615 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 616 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 617 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 618 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 619 | TEST_ASSERT_VAL("wrong group name", |
| 620 | !strcmp(leader->group_name, "group2")); |
| 621 | |
| 622 | /* group2 1:3 + G modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 623 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 624 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 625 | TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); |
| 626 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 627 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 628 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 629 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 630 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 631 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 632 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 633 | |
| 634 | /* instructions:u */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 635 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 636 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 637 | TEST_ASSERT_VAL("wrong config", |
| 638 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 639 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 640 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 641 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 642 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 643 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 644 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 645 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 646 | |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | static int test__group4(struct perf_evlist *evlist __used) |
| 651 | { |
| 652 | struct perf_evsel *evsel, *leader; |
| 653 | |
| 654 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 655 | |
| 656 | /* cycles:u + p */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 657 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 658 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 659 | TEST_ASSERT_VAL("wrong config", |
| 660 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 661 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 662 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 663 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 664 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 665 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 666 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); |
| 667 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 668 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 669 | |
| 670 | /* instructions:kp + p */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 671 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 672 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 673 | TEST_ASSERT_VAL("wrong config", |
| 674 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 675 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 676 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 677 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 678 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 679 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 680 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); |
| 681 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | static int test__group5(struct perf_evlist *evlist __used) |
| 687 | { |
| 688 | struct perf_evsel *evsel, *leader; |
| 689 | |
| 690 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
| 691 | |
| 692 | /* cycles + G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 693 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 694 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 695 | TEST_ASSERT_VAL("wrong config", |
| 696 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 697 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 698 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 699 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 700 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 701 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 702 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 703 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 704 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 705 | |
| 706 | /* instructions + G */ |
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); |
| 717 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 718 | |
| 719 | /* cycles:G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 720 | evsel = leader = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 721 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 722 | TEST_ASSERT_VAL("wrong config", |
| 723 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 724 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 725 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 726 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 727 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 728 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 729 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 730 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 731 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 732 | |
| 733 | /* instructions:G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 734 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 735 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 736 | TEST_ASSERT_VAL("wrong config", |
| 737 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 738 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 739 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 740 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 741 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 742 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 743 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 744 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 745 | |
| 746 | /* cycles */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame^] | 747 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 748 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 749 | TEST_ASSERT_VAL("wrong config", |
| 750 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 751 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 752 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 753 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 754 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 755 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 756 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 757 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
| 758 | |
| 759 | return 0; |
| 760 | } |
| 761 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 762 | struct test__event_st { |
| 763 | const char *name; |
| 764 | __u32 type; |
| 765 | int (*check)(struct perf_evlist *evlist); |
| 766 | }; |
| 767 | |
| 768 | static struct test__event_st test__events[] = { |
| 769 | [0] = { |
| 770 | .name = "syscalls:sys_enter_open", |
| 771 | .check = test__checkevent_tracepoint, |
| 772 | }, |
| 773 | [1] = { |
| 774 | .name = "syscalls:*", |
| 775 | .check = test__checkevent_tracepoint_multi, |
| 776 | }, |
| 777 | [2] = { |
| 778 | .name = "r1a", |
| 779 | .check = test__checkevent_raw, |
| 780 | }, |
| 781 | [3] = { |
| 782 | .name = "1:1", |
| 783 | .check = test__checkevent_numeric, |
| 784 | }, |
| 785 | [4] = { |
| 786 | .name = "instructions", |
| 787 | .check = test__checkevent_symbolic_name, |
| 788 | }, |
| 789 | [5] = { |
| 790 | .name = "cycles/period=100000,config2/", |
| 791 | .check = test__checkevent_symbolic_name_config, |
| 792 | }, |
| 793 | [6] = { |
| 794 | .name = "faults", |
| 795 | .check = test__checkevent_symbolic_alias, |
| 796 | }, |
| 797 | [7] = { |
| 798 | .name = "L1-dcache-load-miss", |
| 799 | .check = test__checkevent_genhw, |
| 800 | }, |
| 801 | [8] = { |
| 802 | .name = "mem:0", |
| 803 | .check = test__checkevent_breakpoint, |
| 804 | }, |
| 805 | [9] = { |
| 806 | .name = "mem:0:x", |
| 807 | .check = test__checkevent_breakpoint_x, |
| 808 | }, |
| 809 | [10] = { |
| 810 | .name = "mem:0:r", |
| 811 | .check = test__checkevent_breakpoint_r, |
| 812 | }, |
| 813 | [11] = { |
| 814 | .name = "mem:0:w", |
| 815 | .check = test__checkevent_breakpoint_w, |
| 816 | }, |
| 817 | [12] = { |
| 818 | .name = "syscalls:sys_enter_open:k", |
| 819 | .check = test__checkevent_tracepoint_modifier, |
| 820 | }, |
| 821 | [13] = { |
| 822 | .name = "syscalls:*:u", |
| 823 | .check = test__checkevent_tracepoint_multi_modifier, |
| 824 | }, |
| 825 | [14] = { |
| 826 | .name = "r1a:kp", |
| 827 | .check = test__checkevent_raw_modifier, |
| 828 | }, |
| 829 | [15] = { |
| 830 | .name = "1:1:hp", |
| 831 | .check = test__checkevent_numeric_modifier, |
| 832 | }, |
| 833 | [16] = { |
| 834 | .name = "instructions:h", |
| 835 | .check = test__checkevent_symbolic_name_modifier, |
| 836 | }, |
| 837 | [17] = { |
| 838 | .name = "faults:u", |
| 839 | .check = test__checkevent_symbolic_alias_modifier, |
| 840 | }, |
| 841 | [18] = { |
| 842 | .name = "L1-dcache-load-miss:kp", |
| 843 | .check = test__checkevent_genhw_modifier, |
| 844 | }, |
| 845 | [19] = { |
| 846 | .name = "mem:0:u", |
| 847 | .check = test__checkevent_breakpoint_modifier, |
| 848 | }, |
| 849 | [20] = { |
| 850 | .name = "mem:0:x:k", |
| 851 | .check = test__checkevent_breakpoint_x_modifier, |
| 852 | }, |
| 853 | [21] = { |
| 854 | .name = "mem:0:r:hp", |
| 855 | .check = test__checkevent_breakpoint_r_modifier, |
| 856 | }, |
| 857 | [22] = { |
| 858 | .name = "mem:0:w:up", |
| 859 | .check = test__checkevent_breakpoint_w_modifier, |
| 860 | }, |
| 861 | [23] = { |
| 862 | .name = "r1,syscalls:sys_enter_open:k,1:1:hp", |
| 863 | .check = test__checkevent_list, |
| 864 | }, |
| 865 | [24] = { |
| 866 | .name = "instructions:G", |
| 867 | .check = test__checkevent_exclude_host_modifier, |
| 868 | }, |
| 869 | [25] = { |
| 870 | .name = "instructions:H", |
| 871 | .check = test__checkevent_exclude_guest_modifier, |
| 872 | }, |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 873 | [26] = { |
| 874 | .name = "mem:0:rw", |
| 875 | .check = test__checkevent_breakpoint_rw, |
| 876 | }, |
| 877 | [27] = { |
| 878 | .name = "mem:0:rw:kp", |
| 879 | .check = test__checkevent_breakpoint_rw_modifier, |
| 880 | }, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 881 | [28] = { |
| 882 | .name = "{instructions:k,cycles:upp}", |
| 883 | .check = test__group1, |
| 884 | }, |
| 885 | [29] = { |
| 886 | .name = "{faults:k,cache-references}:u,cycles:k", |
| 887 | .check = test__group2, |
| 888 | }, |
| 889 | [30] = { |
| 890 | .name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", |
| 891 | .check = test__group3, |
| 892 | }, |
| 893 | [31] = { |
| 894 | .name = "{cycles:u,instructions:kp}:p", |
| 895 | .check = test__group4, |
| 896 | }, |
| 897 | [32] = { |
| 898 | .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", |
| 899 | .check = test__group5, |
| 900 | }, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 901 | }; |
| 902 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 903 | static struct test__event_st test__events_pmu[] = { |
| 904 | [0] = { |
| 905 | .name = "cpu/config=10,config1,config2=3,period=1000/u", |
| 906 | .check = test__checkevent_pmu, |
| 907 | }, |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 908 | [1] = { |
| 909 | .name = "cpu/config=1,name=krava/u,cpu/config=2/u", |
| 910 | .check = test__checkevent_pmu_name, |
| 911 | }, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 912 | }; |
| 913 | |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 914 | struct test__term { |
| 915 | const char *str; |
| 916 | __u32 type; |
| 917 | int (*check)(struct list_head *terms); |
| 918 | }; |
| 919 | |
| 920 | static struct test__term test__terms[] = { |
| 921 | [0] = { |
| 922 | .str = "config=10,config1,config2=3,umask=1", |
| 923 | .check = test__checkterms_simple, |
| 924 | }, |
| 925 | }; |
| 926 | |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 927 | static int test_event(struct test__event_st *e) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 928 | { |
| 929 | struct perf_evlist *evlist; |
| 930 | int ret; |
| 931 | |
| 932 | evlist = perf_evlist__new(NULL, NULL); |
| 933 | if (evlist == NULL) |
| 934 | return -ENOMEM; |
| 935 | |
| 936 | ret = parse_events(evlist, e->name, 0); |
| 937 | if (ret) { |
| 938 | pr_debug("failed to parse event '%s', err %d\n", |
| 939 | e->name, ret); |
| 940 | return ret; |
| 941 | } |
| 942 | |
| 943 | ret = e->check(evlist); |
| 944 | perf_evlist__delete(evlist); |
| 945 | |
| 946 | return ret; |
| 947 | } |
| 948 | |
| 949 | static int test_events(struct test__event_st *events, unsigned cnt) |
| 950 | { |
| 951 | int ret = 0; |
| 952 | unsigned i; |
| 953 | |
| 954 | for (i = 0; i < cnt; i++) { |
| 955 | struct test__event_st *e = &events[i]; |
| 956 | |
| 957 | pr_debug("running test %d '%s'\n", i, e->name); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 958 | ret = test_event(e); |
| 959 | if (ret) |
| 960 | break; |
| 961 | } |
| 962 | |
| 963 | return ret; |
| 964 | } |
| 965 | |
| 966 | static int test_term(struct test__term *t) |
| 967 | { |
| 968 | struct list_head *terms; |
| 969 | int ret; |
| 970 | |
| 971 | terms = malloc(sizeof(*terms)); |
| 972 | if (!terms) |
| 973 | return -ENOMEM; |
| 974 | |
| 975 | INIT_LIST_HEAD(terms); |
| 976 | |
| 977 | ret = parse_events_terms(terms, t->str); |
| 978 | if (ret) { |
| 979 | pr_debug("failed to parse terms '%s', err %d\n", |
| 980 | t->str , ret); |
| 981 | return ret; |
| 982 | } |
| 983 | |
| 984 | ret = t->check(terms); |
| 985 | parse_events__free_terms(terms); |
| 986 | |
| 987 | return ret; |
| 988 | } |
| 989 | |
| 990 | static int test_terms(struct test__term *terms, unsigned cnt) |
| 991 | { |
| 992 | int ret = 0; |
| 993 | unsigned i; |
| 994 | |
| 995 | for (i = 0; i < cnt; i++) { |
| 996 | struct test__term *t = &terms[i]; |
| 997 | |
| 998 | pr_debug("running test %d '%s'\n", i, t->str); |
| 999 | ret = test_term(t); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1000 | if (ret) |
| 1001 | break; |
| 1002 | } |
| 1003 | |
| 1004 | return ret; |
| 1005 | } |
| 1006 | |
| 1007 | static int test_pmu(void) |
| 1008 | { |
| 1009 | struct stat st; |
| 1010 | char path[PATH_MAX]; |
| 1011 | int ret; |
| 1012 | |
| 1013 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", |
| 1014 | sysfs_find_mountpoint()); |
| 1015 | |
| 1016 | ret = stat(path, &st); |
| 1017 | if (ret) |
| 1018 | pr_debug("ommiting PMU cpu tests\n"); |
| 1019 | return !ret; |
| 1020 | } |
| 1021 | |
| 1022 | int parse_events__test(void) |
| 1023 | { |
| 1024 | int ret; |
| 1025 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1026 | #define TEST_EVENTS(tests) \ |
| 1027 | do { \ |
| 1028 | ret = test_events(tests, ARRAY_SIZE(tests)); \ |
| 1029 | if (ret) \ |
| 1030 | return ret; \ |
| 1031 | } while (0) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1032 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1033 | TEST_EVENTS(test__events); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1034 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1035 | if (test_pmu()) |
| 1036 | TEST_EVENTS(test__events_pmu); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1037 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1038 | return test_terms(test__terms, ARRAY_SIZE(test__terms)); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1039 | } |