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