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" |
Jiri Olsa | 4299a54 | 2013-11-05 15:14:45 +0100 | [diff] [blame] | 5 | #include "fs.h" |
Borislav Petkov | 553873e | 2013-12-09 17:14:23 +0100 | [diff] [blame] | 6 | #include <api/fs/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 | |
Arnaldo Carvalho de Melo | 0050f7a | 2014-01-10 10:37:27 -0300 | [diff] [blame] | 33 | evlist__for_each(evlist, evsel) { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 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 | |
Arnaldo Carvalho de Melo | 0050f7a | 2014-01-10 10:37:27 -0300 | [diff] [blame] | 204 | evlist__for_each(evlist, evsel) { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 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 | { |
Arnaldo Carvalho de Melo | 9a354cd | 2013-11-13 15:54:30 -0300 | [diff] [blame] | 444 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 445 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 446 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
| 447 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
| 448 | TEST_ASSERT_VAL("wrong exclude_user", |
| 449 | !evsel->attr.exclude_user); |
| 450 | TEST_ASSERT_VAL("wrong exclude_kernel", |
| 451 | evsel->attr.exclude_kernel); |
| 452 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 453 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 454 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 455 | |
| 456 | return 0; |
| 457 | } |
| 458 | |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 459 | static int test__checkterms_simple(struct list_head *terms) |
| 460 | { |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 461 | struct parse_events_term *term; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 462 | |
| 463 | /* config=10 */ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 464 | term = list_entry(terms->next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 465 | TEST_ASSERT_VAL("wrong type term", |
| 466 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); |
| 467 | TEST_ASSERT_VAL("wrong type val", |
| 468 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 469 | TEST_ASSERT_VAL("wrong val", term->val.num == 10); |
| 470 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 471 | |
| 472 | /* config1 */ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 473 | term = list_entry(term->list.next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 474 | TEST_ASSERT_VAL("wrong type term", |
| 475 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); |
| 476 | TEST_ASSERT_VAL("wrong type val", |
| 477 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 478 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); |
| 479 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 480 | |
| 481 | /* config2=3 */ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 482 | term = list_entry(term->list.next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 483 | TEST_ASSERT_VAL("wrong type term", |
| 484 | term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); |
| 485 | TEST_ASSERT_VAL("wrong type val", |
| 486 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 487 | TEST_ASSERT_VAL("wrong val", term->val.num == 3); |
| 488 | TEST_ASSERT_VAL("wrong config", !term->config); |
| 489 | |
| 490 | /* umask=1*/ |
Arnaldo Carvalho de Melo | 6cee6cd | 2013-01-18 16:29:49 -0300 | [diff] [blame] | 491 | term = list_entry(term->list.next, struct parse_events_term, list); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 492 | TEST_ASSERT_VAL("wrong type term", |
| 493 | term->type_term == PARSE_EVENTS__TERM_TYPE_USER); |
| 494 | TEST_ASSERT_VAL("wrong type val", |
| 495 | term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); |
| 496 | TEST_ASSERT_VAL("wrong val", term->val.num == 1); |
| 497 | TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); |
| 498 | |
| 499 | return 0; |
| 500 | } |
| 501 | |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 502 | static int test__group1(struct perf_evlist *evlist) |
| 503 | { |
| 504 | struct perf_evsel *evsel, *leader; |
| 505 | |
| 506 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 507 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 508 | |
| 509 | /* instructions:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 510 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 511 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 512 | TEST_ASSERT_VAL("wrong config", |
| 513 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 514 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 515 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 516 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 517 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 518 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 519 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 520 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 521 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 522 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 523 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 524 | |
| 525 | /* cycles:upp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 526 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 527 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 528 | TEST_ASSERT_VAL("wrong config", |
| 529 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 530 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 531 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 532 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 533 | /* use of precise requires exclude_guest */ |
| 534 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 535 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 536 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); |
| 537 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 538 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 539 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 540 | |
| 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | static int test__group2(struct perf_evlist *evlist) |
| 545 | { |
| 546 | struct perf_evsel *evsel, *leader; |
| 547 | |
| 548 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 549 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 550 | |
| 551 | /* faults + :ku modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 552 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 553 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
| 554 | TEST_ASSERT_VAL("wrong config", |
| 555 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); |
| 556 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 557 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 558 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 559 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 560 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 561 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 562 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 563 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 564 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 565 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 566 | |
| 567 | /* cache-references + :u modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 568 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 569 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 570 | TEST_ASSERT_VAL("wrong config", |
| 571 | PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); |
| 572 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 573 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 574 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 575 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 576 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 577 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 578 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 579 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 580 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 581 | |
| 582 | /* cycles:k */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 583 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 584 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 585 | TEST_ASSERT_VAL("wrong config", |
| 586 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 587 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 588 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 589 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 590 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 591 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 592 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 593 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 594 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 595 | |
| 596 | return 0; |
| 597 | } |
| 598 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 599 | static int test__group3(struct perf_evlist *evlist __maybe_unused) |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 600 | { |
| 601 | struct perf_evsel *evsel, *leader; |
| 602 | |
| 603 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 604 | TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 605 | |
| 606 | /* group1 syscalls:sys_enter_open:H */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 607 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 608 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
| 609 | TEST_ASSERT_VAL("wrong sample_type", |
| 610 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
| 611 | TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); |
| 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); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 618 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 619 | TEST_ASSERT_VAL("wrong group name", |
| 620 | !strcmp(leader->group_name, "group1")); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 621 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 622 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 623 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 624 | |
| 625 | /* group1 cycles:kppp */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 626 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 627 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 628 | TEST_ASSERT_VAL("wrong config", |
| 629 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 630 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 631 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 632 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 633 | /* use of precise requires exclude_guest */ |
| 634 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 635 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 636 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); |
| 637 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 638 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 639 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 640 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 641 | |
| 642 | /* group2 cycles + G modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 643 | evsel = leader = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 644 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 645 | TEST_ASSERT_VAL("wrong config", |
| 646 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 647 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 648 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 649 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 650 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 651 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 652 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 653 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 654 | TEST_ASSERT_VAL("wrong group name", |
| 655 | !strcmp(leader->group_name, "group2")); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 656 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 657 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 658 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 659 | |
| 660 | /* group2 1:3 + G modifier */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 661 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 662 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
| 663 | TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); |
| 664 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 665 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 666 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 667 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 668 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 669 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 670 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 671 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 672 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 673 | |
| 674 | /* instructions:u */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 675 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 676 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 677 | TEST_ASSERT_VAL("wrong config", |
| 678 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 679 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 680 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 681 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 682 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 683 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 684 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 685 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 686 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 687 | |
| 688 | return 0; |
| 689 | } |
| 690 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 691 | static int test__group4(struct perf_evlist *evlist __maybe_unused) |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 692 | { |
| 693 | struct perf_evsel *evsel, *leader; |
| 694 | |
| 695 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 696 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 697 | |
| 698 | /* cycles:u + p */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 699 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 700 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 701 | TEST_ASSERT_VAL("wrong config", |
| 702 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 703 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 704 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 705 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 706 | /* use of precise requires exclude_guest */ |
| 707 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 708 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 709 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); |
| 710 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 711 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 712 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 713 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 714 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 715 | |
| 716 | /* instructions:kp + p */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 717 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 718 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 719 | TEST_ASSERT_VAL("wrong config", |
| 720 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 721 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
| 722 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 723 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
Jiri Olsa | 42be739 | 2012-10-20 18:29:34 +0200 | [diff] [blame] | 724 | /* use of precise requires exclude_guest */ |
| 725 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 726 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 727 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); |
| 728 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 729 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 730 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 731 | |
| 732 | return 0; |
| 733 | } |
| 734 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 735 | static int test__group5(struct perf_evlist *evlist __maybe_unused) |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 736 | { |
| 737 | struct perf_evsel *evsel, *leader; |
| 738 | |
| 739 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 740 | TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 741 | |
| 742 | /* cycles + G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 743 | evsel = leader = perf_evlist__first(evlist); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 744 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 745 | TEST_ASSERT_VAL("wrong config", |
| 746 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 747 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 748 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 749 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 750 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 751 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 752 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 753 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 754 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 755 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 756 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 757 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 758 | |
| 759 | /* instructions + G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 760 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 761 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 762 | TEST_ASSERT_VAL("wrong config", |
| 763 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 764 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 765 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 766 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 767 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 768 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 769 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 770 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 771 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 772 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 773 | |
| 774 | /* cycles:G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 775 | evsel = leader = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 776 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 777 | TEST_ASSERT_VAL("wrong config", |
| 778 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 779 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 780 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 781 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 782 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 783 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 784 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 785 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 786 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 787 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 788 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 789 | TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 790 | |
| 791 | /* instructions:G */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 792 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 793 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 794 | TEST_ASSERT_VAL("wrong config", |
| 795 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 796 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 797 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 798 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 799 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 800 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 801 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 802 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
Namhyung Kim | 8d7d847 | 2013-01-22 18:09:30 +0900 | [diff] [blame] | 803 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 804 | |
| 805 | /* cycles */ |
Arnaldo Carvalho de Melo | 0c21f73 | 2012-08-14 16:42:15 -0300 | [diff] [blame] | 806 | evsel = perf_evsel__next(evsel); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 807 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 808 | TEST_ASSERT_VAL("wrong config", |
| 809 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 810 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 811 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 812 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 813 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 814 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 815 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
Namhyung Kim | 823254e | 2012-11-29 15:38:30 +0900 | [diff] [blame] | 816 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 817 | |
| 818 | return 0; |
| 819 | } |
| 820 | |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 821 | static int test__group_gh1(struct perf_evlist *evlist) |
| 822 | { |
| 823 | struct perf_evsel *evsel, *leader; |
| 824 | |
| 825 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 826 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 827 | |
| 828 | /* cycles + :H group modifier */ |
| 829 | evsel = leader = perf_evlist__first(evlist); |
| 830 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 831 | TEST_ASSERT_VAL("wrong config", |
| 832 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 833 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 834 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 835 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 836 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 837 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 838 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 839 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 840 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 841 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 842 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 843 | |
| 844 | /* cache-misses:G + :H group modifier */ |
| 845 | evsel = perf_evsel__next(evsel); |
| 846 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 847 | TEST_ASSERT_VAL("wrong config", |
| 848 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 849 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 850 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 851 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 852 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 853 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 854 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 855 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 856 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 857 | |
| 858 | return 0; |
| 859 | } |
| 860 | |
| 861 | static int test__group_gh2(struct perf_evlist *evlist) |
| 862 | { |
| 863 | struct perf_evsel *evsel, *leader; |
| 864 | |
| 865 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 866 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 867 | |
| 868 | /* cycles + :G group modifier */ |
| 869 | evsel = leader = perf_evlist__first(evlist); |
| 870 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 871 | TEST_ASSERT_VAL("wrong config", |
| 872 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 873 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 874 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 875 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 876 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 877 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 878 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 879 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 880 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 881 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 882 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 883 | |
| 884 | /* cache-misses:H + :G group modifier */ |
| 885 | evsel = perf_evsel__next(evsel); |
| 886 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 887 | TEST_ASSERT_VAL("wrong config", |
| 888 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 889 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 890 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 891 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 892 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 893 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 894 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 895 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 896 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 897 | |
| 898 | return 0; |
| 899 | } |
| 900 | |
| 901 | static int test__group_gh3(struct perf_evlist *evlist) |
| 902 | { |
| 903 | struct perf_evsel *evsel, *leader; |
| 904 | |
| 905 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 906 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 907 | |
| 908 | /* cycles:G + :u group modifier */ |
| 909 | evsel = leader = perf_evlist__first(evlist); |
| 910 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 911 | TEST_ASSERT_VAL("wrong config", |
| 912 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 913 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 914 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 915 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 916 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 917 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 918 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 919 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 920 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 921 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 922 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 923 | |
| 924 | /* cache-misses:H + :u group modifier */ |
| 925 | evsel = perf_evsel__next(evsel); |
| 926 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 927 | TEST_ASSERT_VAL("wrong config", |
| 928 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 929 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 930 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 931 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 932 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 933 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 934 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 935 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 936 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 937 | |
| 938 | return 0; |
| 939 | } |
| 940 | |
| 941 | static int test__group_gh4(struct perf_evlist *evlist) |
| 942 | { |
| 943 | struct perf_evsel *evsel, *leader; |
| 944 | |
| 945 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 946 | TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); |
| 947 | |
| 948 | /* cycles:G + :uG group modifier */ |
| 949 | evsel = leader = perf_evlist__first(evlist); |
| 950 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 951 | TEST_ASSERT_VAL("wrong config", |
| 952 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 953 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 954 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 955 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 956 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 957 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
| 958 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 959 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 960 | TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); |
| 961 | TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); |
| 962 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); |
| 963 | |
| 964 | /* cache-misses:H + :uG group modifier */ |
| 965 | evsel = perf_evsel__next(evsel); |
| 966 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 967 | TEST_ASSERT_VAL("wrong config", |
| 968 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 969 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 970 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 971 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 972 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
| 973 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 974 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 975 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 976 | TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); |
| 977 | |
| 978 | return 0; |
| 979 | } |
| 980 | |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 981 | static int test__leader_sample1(struct perf_evlist *evlist) |
| 982 | { |
| 983 | struct perf_evsel *evsel, *leader; |
| 984 | |
| 985 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 986 | |
| 987 | /* cycles - sampling group leader */ |
| 988 | evsel = leader = perf_evlist__first(evlist); |
| 989 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 990 | TEST_ASSERT_VAL("wrong config", |
| 991 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 992 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 993 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 994 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 995 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 996 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 997 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 998 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 999 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1000 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1001 | |
| 1002 | /* cache-misses - not sampling */ |
| 1003 | evsel = perf_evsel__next(evsel); |
| 1004 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1005 | TEST_ASSERT_VAL("wrong config", |
| 1006 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 1007 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1008 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 1009 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 1010 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1011 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1012 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1013 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1014 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1015 | |
| 1016 | /* branch-misses - not sampling */ |
| 1017 | evsel = perf_evsel__next(evsel); |
| 1018 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1019 | TEST_ASSERT_VAL("wrong config", |
| 1020 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); |
| 1021 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1022 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
| 1023 | TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); |
| 1024 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1025 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1026 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1027 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1028 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1029 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1030 | |
| 1031 | return 0; |
| 1032 | } |
| 1033 | |
| 1034 | static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused) |
| 1035 | { |
| 1036 | struct perf_evsel *evsel, *leader; |
| 1037 | |
| 1038 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
| 1039 | |
| 1040 | /* instructions - sampling group leader */ |
| 1041 | evsel = leader = perf_evlist__first(evlist); |
| 1042 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1043 | TEST_ASSERT_VAL("wrong config", |
| 1044 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
| 1045 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1046 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1047 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1048 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1049 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1050 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1051 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1052 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1053 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1054 | |
| 1055 | /* branch-misses - not sampling */ |
| 1056 | evsel = perf_evsel__next(evsel); |
| 1057 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1058 | TEST_ASSERT_VAL("wrong config", |
| 1059 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); |
| 1060 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1061 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1062 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1063 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
| 1064 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
| 1065 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
| 1066 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1067 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1068 | TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); |
| 1069 | |
| 1070 | return 0; |
| 1071 | } |
| 1072 | |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1073 | static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) |
| 1074 | { |
| 1075 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
| 1076 | |
| 1077 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
| 1078 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
| 1079 | TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); |
| 1080 | TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); |
| 1081 | TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); |
| 1082 | |
| 1083 | return test__checkevent_symbolic_name(evlist); |
| 1084 | } |
| 1085 | |
| 1086 | static int test__pinned_group(struct perf_evlist *evlist) |
| 1087 | { |
| 1088 | struct perf_evsel *evsel, *leader; |
| 1089 | |
| 1090 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
| 1091 | |
| 1092 | /* cycles - group leader */ |
| 1093 | evsel = leader = perf_evlist__first(evlist); |
| 1094 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1095 | TEST_ASSERT_VAL("wrong config", |
| 1096 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
| 1097 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
| 1098 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
| 1099 | TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); |
| 1100 | |
| 1101 | /* cache-misses - can not be pinned, but will go on with the leader */ |
| 1102 | evsel = perf_evsel__next(evsel); |
| 1103 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
| 1104 | TEST_ASSERT_VAL("wrong config", |
| 1105 | PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); |
| 1106 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
| 1107 | |
| 1108 | /* branch-misses - ditto */ |
| 1109 | evsel = perf_evsel__next(evsel); |
| 1110 | TEST_ASSERT_VAL("wrong config", |
| 1111 | PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); |
| 1112 | TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); |
| 1113 | |
| 1114 | return 0; |
| 1115 | } |
| 1116 | |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1117 | static int count_tracepoints(void) |
| 1118 | { |
| 1119 | char events_path[PATH_MAX]; |
| 1120 | struct dirent *events_ent; |
| 1121 | DIR *events_dir; |
| 1122 | int cnt = 0; |
| 1123 | |
| 1124 | scnprintf(events_path, PATH_MAX, "%s/tracing/events", |
| 1125 | debugfs_find_mountpoint()); |
| 1126 | |
| 1127 | events_dir = opendir(events_path); |
| 1128 | |
| 1129 | TEST_ASSERT_VAL("Can't open events dir", events_dir); |
| 1130 | |
| 1131 | while ((events_ent = readdir(events_dir))) { |
| 1132 | char sys_path[PATH_MAX]; |
| 1133 | struct dirent *sys_ent; |
| 1134 | DIR *sys_dir; |
| 1135 | |
| 1136 | if (!strcmp(events_ent->d_name, ".") |
| 1137 | || !strcmp(events_ent->d_name, "..") |
| 1138 | || !strcmp(events_ent->d_name, "enable") |
| 1139 | || !strcmp(events_ent->d_name, "header_event") |
| 1140 | || !strcmp(events_ent->d_name, "header_page")) |
| 1141 | continue; |
| 1142 | |
| 1143 | scnprintf(sys_path, PATH_MAX, "%s/%s", |
| 1144 | events_path, events_ent->d_name); |
| 1145 | |
| 1146 | sys_dir = opendir(sys_path); |
| 1147 | TEST_ASSERT_VAL("Can't open sys dir", sys_dir); |
| 1148 | |
| 1149 | while ((sys_ent = readdir(sys_dir))) { |
| 1150 | if (!strcmp(sys_ent->d_name, ".") |
| 1151 | || !strcmp(sys_ent->d_name, "..") |
| 1152 | || !strcmp(sys_ent->d_name, "enable") |
| 1153 | || !strcmp(sys_ent->d_name, "filter")) |
| 1154 | continue; |
| 1155 | |
| 1156 | cnt++; |
| 1157 | } |
| 1158 | |
| 1159 | closedir(sys_dir); |
| 1160 | } |
| 1161 | |
| 1162 | closedir(events_dir); |
| 1163 | return cnt; |
| 1164 | } |
| 1165 | |
| 1166 | static int test__all_tracepoints(struct perf_evlist *evlist) |
| 1167 | { |
| 1168 | TEST_ASSERT_VAL("wrong events count", |
| 1169 | count_tracepoints() == evlist->nr_entries); |
| 1170 | |
| 1171 | return test__checkevent_tracepoint_multi(evlist); |
| 1172 | } |
| 1173 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1174 | struct evlist_test { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1175 | const char *name; |
| 1176 | __u32 type; |
| 1177 | int (*check)(struct perf_evlist *evlist); |
| 1178 | }; |
| 1179 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1180 | static struct evlist_test test__events[] = { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1181 | [0] = { |
| 1182 | .name = "syscalls:sys_enter_open", |
| 1183 | .check = test__checkevent_tracepoint, |
| 1184 | }, |
| 1185 | [1] = { |
| 1186 | .name = "syscalls:*", |
| 1187 | .check = test__checkevent_tracepoint_multi, |
| 1188 | }, |
| 1189 | [2] = { |
| 1190 | .name = "r1a", |
| 1191 | .check = test__checkevent_raw, |
| 1192 | }, |
| 1193 | [3] = { |
| 1194 | .name = "1:1", |
| 1195 | .check = test__checkevent_numeric, |
| 1196 | }, |
| 1197 | [4] = { |
| 1198 | .name = "instructions", |
| 1199 | .check = test__checkevent_symbolic_name, |
| 1200 | }, |
| 1201 | [5] = { |
| 1202 | .name = "cycles/period=100000,config2/", |
| 1203 | .check = test__checkevent_symbolic_name_config, |
| 1204 | }, |
| 1205 | [6] = { |
| 1206 | .name = "faults", |
| 1207 | .check = test__checkevent_symbolic_alias, |
| 1208 | }, |
| 1209 | [7] = { |
| 1210 | .name = "L1-dcache-load-miss", |
| 1211 | .check = test__checkevent_genhw, |
| 1212 | }, |
| 1213 | [8] = { |
| 1214 | .name = "mem:0", |
| 1215 | .check = test__checkevent_breakpoint, |
| 1216 | }, |
| 1217 | [9] = { |
| 1218 | .name = "mem:0:x", |
| 1219 | .check = test__checkevent_breakpoint_x, |
| 1220 | }, |
| 1221 | [10] = { |
| 1222 | .name = "mem:0:r", |
| 1223 | .check = test__checkevent_breakpoint_r, |
| 1224 | }, |
| 1225 | [11] = { |
| 1226 | .name = "mem:0:w", |
| 1227 | .check = test__checkevent_breakpoint_w, |
| 1228 | }, |
| 1229 | [12] = { |
| 1230 | .name = "syscalls:sys_enter_open:k", |
| 1231 | .check = test__checkevent_tracepoint_modifier, |
| 1232 | }, |
| 1233 | [13] = { |
| 1234 | .name = "syscalls:*:u", |
| 1235 | .check = test__checkevent_tracepoint_multi_modifier, |
| 1236 | }, |
| 1237 | [14] = { |
| 1238 | .name = "r1a:kp", |
| 1239 | .check = test__checkevent_raw_modifier, |
| 1240 | }, |
| 1241 | [15] = { |
| 1242 | .name = "1:1:hp", |
| 1243 | .check = test__checkevent_numeric_modifier, |
| 1244 | }, |
| 1245 | [16] = { |
| 1246 | .name = "instructions:h", |
| 1247 | .check = test__checkevent_symbolic_name_modifier, |
| 1248 | }, |
| 1249 | [17] = { |
| 1250 | .name = "faults:u", |
| 1251 | .check = test__checkevent_symbolic_alias_modifier, |
| 1252 | }, |
| 1253 | [18] = { |
| 1254 | .name = "L1-dcache-load-miss:kp", |
| 1255 | .check = test__checkevent_genhw_modifier, |
| 1256 | }, |
| 1257 | [19] = { |
| 1258 | .name = "mem:0:u", |
| 1259 | .check = test__checkevent_breakpoint_modifier, |
| 1260 | }, |
| 1261 | [20] = { |
| 1262 | .name = "mem:0:x:k", |
| 1263 | .check = test__checkevent_breakpoint_x_modifier, |
| 1264 | }, |
| 1265 | [21] = { |
| 1266 | .name = "mem:0:r:hp", |
| 1267 | .check = test__checkevent_breakpoint_r_modifier, |
| 1268 | }, |
| 1269 | [22] = { |
| 1270 | .name = "mem:0:w:up", |
| 1271 | .check = test__checkevent_breakpoint_w_modifier, |
| 1272 | }, |
| 1273 | [23] = { |
| 1274 | .name = "r1,syscalls:sys_enter_open:k,1:1:hp", |
| 1275 | .check = test__checkevent_list, |
| 1276 | }, |
| 1277 | [24] = { |
| 1278 | .name = "instructions:G", |
| 1279 | .check = test__checkevent_exclude_host_modifier, |
| 1280 | }, |
| 1281 | [25] = { |
| 1282 | .name = "instructions:H", |
| 1283 | .check = test__checkevent_exclude_guest_modifier, |
| 1284 | }, |
Jiri Olsa | 7582732 | 2012-06-29 09:22:54 +0200 | [diff] [blame] | 1285 | [26] = { |
| 1286 | .name = "mem:0:rw", |
| 1287 | .check = test__checkevent_breakpoint_rw, |
| 1288 | }, |
| 1289 | [27] = { |
| 1290 | .name = "mem:0:rw:kp", |
| 1291 | .check = test__checkevent_breakpoint_rw_modifier, |
| 1292 | }, |
Jiri Olsa | 905f5ee | 2012-08-08 12:23:52 +0200 | [diff] [blame] | 1293 | [28] = { |
| 1294 | .name = "{instructions:k,cycles:upp}", |
| 1295 | .check = test__group1, |
| 1296 | }, |
| 1297 | [29] = { |
| 1298 | .name = "{faults:k,cache-references}:u,cycles:k", |
| 1299 | .check = test__group2, |
| 1300 | }, |
| 1301 | [30] = { |
| 1302 | .name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", |
| 1303 | .check = test__group3, |
| 1304 | }, |
| 1305 | [31] = { |
| 1306 | .name = "{cycles:u,instructions:kp}:p", |
| 1307 | .check = test__group4, |
| 1308 | }, |
| 1309 | [32] = { |
| 1310 | .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", |
| 1311 | .check = test__group5, |
| 1312 | }, |
Jiri Olsa | 82ce75d | 2012-12-17 14:08:38 +0100 | [diff] [blame] | 1313 | [33] = { |
| 1314 | .name = "*:*", |
| 1315 | .check = test__all_tracepoints, |
| 1316 | }, |
Jiri Olsa | 5a30a99 | 2013-02-04 10:56:43 +0100 | [diff] [blame] | 1317 | [34] = { |
| 1318 | .name = "{cycles,cache-misses:G}:H", |
| 1319 | .check = test__group_gh1, |
| 1320 | }, |
| 1321 | [35] = { |
| 1322 | .name = "{cycles,cache-misses:H}:G", |
| 1323 | .check = test__group_gh2, |
| 1324 | }, |
| 1325 | [36] = { |
| 1326 | .name = "{cycles:G,cache-misses:H}:u", |
| 1327 | .check = test__group_gh3, |
| 1328 | }, |
| 1329 | [37] = { |
| 1330 | .name = "{cycles:G,cache-misses:H}:uG", |
| 1331 | .check = test__group_gh4, |
| 1332 | }, |
Jiri Olsa | a9f93f9 | 2013-02-01 20:37:11 +0100 | [diff] [blame] | 1333 | [38] = { |
| 1334 | .name = "{cycles,cache-misses,branch-misses}:S", |
| 1335 | .check = test__leader_sample1, |
| 1336 | }, |
| 1337 | [39] = { |
| 1338 | .name = "{instructions,branch-misses}:Su", |
| 1339 | .check = test__leader_sample2, |
| 1340 | }, |
Michael Ellerman | c9ee780 | 2013-08-06 23:28:06 +1000 | [diff] [blame] | 1341 | [40] = { |
| 1342 | .name = "instructions:uDp", |
| 1343 | .check = test__checkevent_pinned_modifier, |
| 1344 | }, |
| 1345 | [41] = { |
| 1346 | .name = "{cycles,cache-misses,branch-misses}:D", |
| 1347 | .check = test__pinned_group, |
| 1348 | }, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1349 | }; |
| 1350 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1351 | static struct evlist_test test__events_pmu[] = { |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1352 | [0] = { |
| 1353 | .name = "cpu/config=10,config1,config2=3,period=1000/u", |
| 1354 | .check = test__checkevent_pmu, |
| 1355 | }, |
Jiri Olsa | 6b5fc39 | 2012-05-21 09:12:53 +0200 | [diff] [blame] | 1356 | [1] = { |
| 1357 | .name = "cpu/config=1,name=krava/u,cpu/config=2/u", |
| 1358 | .check = test__checkevent_pmu_name, |
| 1359 | }, |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1360 | }; |
| 1361 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1362 | struct terms_test { |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1363 | const char *str; |
| 1364 | __u32 type; |
| 1365 | int (*check)(struct list_head *terms); |
| 1366 | }; |
| 1367 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1368 | static struct terms_test test__terms[] = { |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1369 | [0] = { |
| 1370 | .str = "config=10,config1,config2=3,umask=1", |
| 1371 | .check = test__checkterms_simple, |
| 1372 | }, |
| 1373 | }; |
| 1374 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1375 | static int test_event(struct evlist_test *e) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1376 | { |
| 1377 | struct perf_evlist *evlist; |
| 1378 | int ret; |
| 1379 | |
Namhyung Kim | 334fe7a | 2013-03-11 16:43:12 +0900 | [diff] [blame] | 1380 | evlist = perf_evlist__new(); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1381 | if (evlist == NULL) |
| 1382 | return -ENOMEM; |
| 1383 | |
Jiri Olsa | d8f7bbc | 2013-01-15 14:39:51 +0100 | [diff] [blame] | 1384 | ret = parse_events(evlist, e->name); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1385 | if (ret) { |
| 1386 | pr_debug("failed to parse event '%s', err %d\n", |
| 1387 | e->name, ret); |
Arnaldo Carvalho de Melo | 2d4352c | 2014-01-03 17:30:04 -0300 | [diff] [blame] | 1388 | } else { |
| 1389 | ret = e->check(evlist); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1390 | } |
Arnaldo Carvalho de Melo | 2d4352c | 2014-01-03 17:30:04 -0300 | [diff] [blame] | 1391 | |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1392 | perf_evlist__delete(evlist); |
| 1393 | |
| 1394 | return ret; |
| 1395 | } |
| 1396 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1397 | static int test_events(struct evlist_test *events, unsigned cnt) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1398 | { |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1399 | int ret1, ret2 = 0; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1400 | unsigned i; |
| 1401 | |
| 1402 | for (i = 0; i < cnt; i++) { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1403 | struct evlist_test *e = &events[i]; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1404 | |
| 1405 | pr_debug("running test %d '%s'\n", i, e->name); |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1406 | ret1 = test_event(e); |
| 1407 | if (ret1) |
| 1408 | ret2 = ret1; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1409 | } |
| 1410 | |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1411 | return ret2; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1412 | } |
| 1413 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1414 | static int test_term(struct terms_test *t) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1415 | { |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1416 | struct list_head terms; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1417 | int ret; |
| 1418 | |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1419 | INIT_LIST_HEAD(&terms); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1420 | |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1421 | ret = parse_events_terms(&terms, t->str); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1422 | if (ret) { |
| 1423 | pr_debug("failed to parse terms '%s', err %d\n", |
| 1424 | t->str , ret); |
| 1425 | return ret; |
| 1426 | } |
| 1427 | |
David Ahern | c549aca | 2013-07-02 13:27:24 -0600 | [diff] [blame] | 1428 | ret = t->check(&terms); |
| 1429 | parse_events__free_terms(&terms); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1430 | |
| 1431 | return ret; |
| 1432 | } |
| 1433 | |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1434 | static int test_terms(struct terms_test *terms, unsigned cnt) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1435 | { |
| 1436 | int ret = 0; |
| 1437 | unsigned i; |
| 1438 | |
| 1439 | for (i = 0; i < cnt; i++) { |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1440 | struct terms_test *t = &terms[i]; |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1441 | |
| 1442 | pr_debug("running test %d '%s'\n", i, t->str); |
| 1443 | ret = test_term(t); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1444 | if (ret) |
| 1445 | break; |
| 1446 | } |
| 1447 | |
| 1448 | return ret; |
| 1449 | } |
| 1450 | |
| 1451 | static int test_pmu(void) |
| 1452 | { |
| 1453 | struct stat st; |
| 1454 | char path[PATH_MAX]; |
| 1455 | int ret; |
| 1456 | |
| 1457 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", |
Arnaldo Carvalho de Melo | cf38fad | 2013-11-05 14:48:50 -0300 | [diff] [blame] | 1458 | sysfs__mountpoint()); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1459 | |
| 1460 | ret = stat(path, &st); |
| 1461 | if (ret) |
Masanari Iida | 3fd44cd | 2012-07-18 01:20:59 +0900 | [diff] [blame] | 1462 | pr_debug("omitting PMU cpu tests\n"); |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1463 | return !ret; |
| 1464 | } |
| 1465 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1466 | static int test_pmu_events(void) |
| 1467 | { |
| 1468 | struct stat st; |
| 1469 | char path[PATH_MAX]; |
| 1470 | struct dirent *ent; |
| 1471 | DIR *dir; |
| 1472 | int ret; |
| 1473 | |
| 1474 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", |
Arnaldo Carvalho de Melo | cf38fad | 2013-11-05 14:48:50 -0300 | [diff] [blame] | 1475 | sysfs__mountpoint()); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1476 | |
| 1477 | ret = stat(path, &st); |
| 1478 | if (ret) { |
Masanari Iida | a895d57 | 2013-04-09 02:06:50 +0900 | [diff] [blame] | 1479 | pr_debug("omitting PMU cpu events tests\n"); |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1480 | return 0; |
| 1481 | } |
| 1482 | |
| 1483 | dir = opendir(path); |
| 1484 | if (!dir) { |
| 1485 | pr_debug("can't open pmu event dir"); |
| 1486 | return -1; |
| 1487 | } |
| 1488 | |
| 1489 | while (!ret && (ent = readdir(dir))) { |
| 1490 | #define MAX_NAME 100 |
Arnaldo Carvalho de Melo | 23b6339 | 2013-01-18 16:56:57 -0300 | [diff] [blame] | 1491 | struct evlist_test e; |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1492 | char name[MAX_NAME]; |
| 1493 | |
| 1494 | if (!strcmp(ent->d_name, ".") || |
| 1495 | !strcmp(ent->d_name, "..")) |
| 1496 | continue; |
| 1497 | |
| 1498 | snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name); |
| 1499 | |
| 1500 | e.name = name; |
| 1501 | e.check = test__checkevent_pmu_events; |
| 1502 | |
| 1503 | ret = test_event(&e); |
| 1504 | #undef MAX_NAME |
| 1505 | } |
| 1506 | |
| 1507 | closedir(dir); |
| 1508 | return ret; |
| 1509 | } |
| 1510 | |
Jiri Olsa | c81251e | 2012-11-10 01:46:51 +0100 | [diff] [blame] | 1511 | int test__parse_events(void) |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1512 | { |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1513 | int ret1, ret2 = 0; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1514 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1515 | #define TEST_EVENTS(tests) \ |
| 1516 | do { \ |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1517 | ret1 = test_events(tests, ARRAY_SIZE(tests)); \ |
| 1518 | if (!ret2) \ |
| 1519 | ret2 = ret1; \ |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1520 | } while (0) |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1521 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1522 | TEST_EVENTS(test__events); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1523 | |
Jiri Olsa | ebf124f | 2012-07-04 00:00:47 +0200 | [diff] [blame] | 1524 | if (test_pmu()) |
| 1525 | TEST_EVENTS(test__events_pmu); |
Jiri Olsa | 4429392 | 2012-06-15 14:31:42 +0800 | [diff] [blame] | 1526 | |
Jiri Olsa | 3f3a206 | 2012-10-10 14:53:18 +0200 | [diff] [blame] | 1527 | if (test_pmu()) { |
| 1528 | int ret = test_pmu_events(); |
| 1529 | if (ret) |
| 1530 | return ret; |
| 1531 | } |
| 1532 | |
Robert Richter | 9bfbbc6 | 2012-08-21 20:03:15 +0200 | [diff] [blame] | 1533 | ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); |
| 1534 | if (!ret2) |
| 1535 | ret2 = ret1; |
| 1536 | |
| 1537 | return ret2; |
Jiri Olsa | f50246e | 2012-05-21 09:12:49 +0200 | [diff] [blame] | 1538 | } |