1 // SPDX-License-Identifier: GPL-2.0 2 #include "parse-events.h" 3 #include "evsel.h" 4 #include "evlist.h" 5 #include <api/fs/fs.h> 6 #include "tests.h" 7 #include "debug.h" 8 #include "pmu.h" 9 #include "pmu-hybrid.h" 10 #include "pmus.h" 11 #include <dirent.h> 12 #include <errno.h> 13 #include "fncache.h" 14 #include <sys/types.h> 15 #include <sys/stat.h> 16 #include <unistd.h> 17 #include <linux/kernel.h> 18 #include <linux/hw_breakpoint.h> 19 #include <api/fs/tracing_path.h> 20 21 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ 22 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) 23 24 static bool test_config(const struct evsel *evsel, __u64 expected_config) 25 { 26 __u32 type = evsel->core.attr.type; 27 __u64 config = evsel->core.attr.config; 28 29 if (type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_CACHE) { 30 /* 31 * HARDWARE and HW_CACHE events encode the PMU's extended type 32 * in the top 32-bits. Mask in order to ignore. 33 */ 34 config &= PERF_HW_EVENT_MASK; 35 } 36 return config == expected_config; 37 } 38 39 #ifdef HAVE_LIBTRACEEVENT 40 41 #if defined(__s390x__) 42 /* Return true if kvm module is available and loaded. Test this 43 * and return success when trace point kvm_s390_create_vm 44 * exists. Otherwise this test always fails. 45 */ 46 static bool kvm_s390_create_vm_valid(void) 47 { 48 char *eventfile; 49 bool rc = false; 50 51 eventfile = get_events_file("kvm-s390"); 52 53 if (eventfile) { 54 DIR *mydir = opendir(eventfile); 55 56 if (mydir) { 57 rc = true; 58 closedir(mydir); 59 } 60 put_events_file(eventfile); 61 } 62 63 return rc; 64 } 65 #endif 66 67 static int test__checkevent_tracepoint(struct evlist *evlist) 68 { 69 struct evsel *evsel = evlist__first(evlist); 70 71 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 72 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist__nr_groups(evlist)); 73 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type); 74 TEST_ASSERT_VAL("wrong sample_type", 75 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type); 76 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period); 77 return TEST_OK; 78 } 79 80 static int test__checkevent_tracepoint_multi(struct evlist *evlist) 81 { 82 struct evsel *evsel; 83 84 TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1); 85 TEST_ASSERT_VAL("wrong number of groups", 0 == evlist__nr_groups(evlist)); 86 87 evlist__for_each_entry(evlist, evsel) { 88 TEST_ASSERT_VAL("wrong type", 89 PERF_TYPE_TRACEPOINT == evsel->core.attr.type); 90 TEST_ASSERT_VAL("wrong sample_type", 91 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type); 92 TEST_ASSERT_VAL("wrong sample_period", 93 1 == evsel->core.attr.sample_period); 94 } 95 return TEST_OK; 96 } 97 #endif /* HAVE_LIBTRACEEVENT */ 98 99 static int test__checkevent_raw(struct evlist *evlist) 100 { 101 struct evsel *evsel = evlist__first(evlist); 102 103 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 104 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 105 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a)); 106 return TEST_OK; 107 } 108 109 static int test__checkevent_numeric(struct evlist *evlist) 110 { 111 struct evsel *evsel = evlist__first(evlist); 112 113 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 114 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type); 115 TEST_ASSERT_VAL("wrong config", test_config(evsel, 1)); 116 return TEST_OK; 117 } 118 119 static int test__checkevent_symbolic_name(struct evlist *evlist) 120 { 121 struct evsel *evsel = evlist__first(evlist); 122 123 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 124 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 125 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 126 return TEST_OK; 127 } 128 129 static int test__checkevent_symbolic_name_config(struct evlist *evlist) 130 { 131 struct evsel *evsel = evlist__first(evlist); 132 133 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 134 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 135 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 136 /* 137 * The period value gets configured within evlist__config, 138 * while this test executes only parse events method. 139 */ 140 TEST_ASSERT_VAL("wrong period", 141 0 == evsel->core.attr.sample_period); 142 TEST_ASSERT_VAL("wrong config1", 143 0 == evsel->core.attr.config1); 144 TEST_ASSERT_VAL("wrong config2", 145 1 == evsel->core.attr.config2); 146 return TEST_OK; 147 } 148 149 static int test__checkevent_symbolic_alias(struct evlist *evlist) 150 { 151 struct evsel *evsel = evlist__first(evlist); 152 153 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 154 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); 155 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_PAGE_FAULTS)); 156 return TEST_OK; 157 } 158 159 static int test__checkevent_genhw(struct evlist *evlist) 160 { 161 struct evsel *evsel = evlist__first(evlist); 162 163 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 164 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type); 165 TEST_ASSERT_VAL("wrong config", test_config(evsel, 1 << 16)); 166 return TEST_OK; 167 } 168 169 static int test__checkevent_breakpoint(struct evlist *evlist) 170 { 171 struct evsel *evsel = evlist__first(evlist); 172 173 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 174 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 175 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 176 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == 177 evsel->core.attr.bp_type); 178 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == 179 evsel->core.attr.bp_len); 180 return TEST_OK; 181 } 182 183 static int test__checkevent_breakpoint_x(struct evlist *evlist) 184 { 185 struct evsel *evsel = evlist__first(evlist); 186 187 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 188 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 189 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 190 TEST_ASSERT_VAL("wrong bp_type", 191 HW_BREAKPOINT_X == evsel->core.attr.bp_type); 192 TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->core.attr.bp_len); 193 return TEST_OK; 194 } 195 196 static int test__checkevent_breakpoint_r(struct evlist *evlist) 197 { 198 struct evsel *evsel = evlist__first(evlist); 199 200 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 201 TEST_ASSERT_VAL("wrong type", 202 PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 203 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 204 TEST_ASSERT_VAL("wrong bp_type", 205 HW_BREAKPOINT_R == evsel->core.attr.bp_type); 206 TEST_ASSERT_VAL("wrong bp_len", 207 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len); 208 return TEST_OK; 209 } 210 211 static int test__checkevent_breakpoint_w(struct evlist *evlist) 212 { 213 struct evsel *evsel = evlist__first(evlist); 214 215 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 216 TEST_ASSERT_VAL("wrong type", 217 PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 218 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 219 TEST_ASSERT_VAL("wrong bp_type", 220 HW_BREAKPOINT_W == evsel->core.attr.bp_type); 221 TEST_ASSERT_VAL("wrong bp_len", 222 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len); 223 return TEST_OK; 224 } 225 226 static int test__checkevent_breakpoint_rw(struct evlist *evlist) 227 { 228 struct evsel *evsel = evlist__first(evlist); 229 230 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 231 TEST_ASSERT_VAL("wrong type", 232 PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 233 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 234 TEST_ASSERT_VAL("wrong bp_type", 235 (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->core.attr.bp_type); 236 TEST_ASSERT_VAL("wrong bp_len", 237 HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len); 238 return TEST_OK; 239 } 240 241 #ifdef HAVE_LIBTRACEEVENT 242 static int test__checkevent_tracepoint_modifier(struct evlist *evlist) 243 { 244 struct evsel *evsel = evlist__first(evlist); 245 246 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 247 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 248 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 249 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 250 251 return test__checkevent_tracepoint(evlist); 252 } 253 254 static int 255 test__checkevent_tracepoint_multi_modifier(struct evlist *evlist) 256 { 257 struct evsel *evsel; 258 259 TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1); 260 261 evlist__for_each_entry(evlist, evsel) { 262 TEST_ASSERT_VAL("wrong exclude_user", 263 !evsel->core.attr.exclude_user); 264 TEST_ASSERT_VAL("wrong exclude_kernel", 265 evsel->core.attr.exclude_kernel); 266 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 267 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 268 } 269 270 return test__checkevent_tracepoint_multi(evlist); 271 } 272 #endif /* HAVE_LIBTRACEEVENT */ 273 274 static int test__checkevent_raw_modifier(struct evlist *evlist) 275 { 276 struct evsel *evsel = evlist__first(evlist); 277 278 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 279 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 280 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 281 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 282 283 return test__checkevent_raw(evlist); 284 } 285 286 static int test__checkevent_numeric_modifier(struct evlist *evlist) 287 { 288 struct evsel *evsel = evlist__first(evlist); 289 290 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 291 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 292 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 293 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 294 295 return test__checkevent_numeric(evlist); 296 } 297 298 static int test__checkevent_symbolic_name_modifier(struct evlist *evlist) 299 { 300 struct evsel *evsel = evlist__first(evlist); 301 302 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 303 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 304 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 305 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 306 307 return test__checkevent_symbolic_name(evlist); 308 } 309 310 static int test__checkevent_exclude_host_modifier(struct evlist *evlist) 311 { 312 struct evsel *evsel = evlist__first(evlist); 313 314 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 315 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 316 317 return test__checkevent_symbolic_name(evlist); 318 } 319 320 static int test__checkevent_exclude_guest_modifier(struct evlist *evlist) 321 { 322 struct evsel *evsel = evlist__first(evlist); 323 324 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 325 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 326 327 return test__checkevent_symbolic_name(evlist); 328 } 329 330 static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist) 331 { 332 struct evsel *evsel = evlist__first(evlist); 333 334 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 335 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 336 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 337 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 338 339 return test__checkevent_symbolic_alias(evlist); 340 } 341 342 static int test__checkevent_genhw_modifier(struct evlist *evlist) 343 { 344 struct evsel *evsel = evlist__first(evlist); 345 346 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 347 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 348 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 349 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 350 351 return test__checkevent_genhw(evlist); 352 } 353 354 static int test__checkevent_exclude_idle_modifier(struct evlist *evlist) 355 { 356 struct evsel *evsel = evlist__first(evlist); 357 358 TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle); 359 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 360 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 361 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 362 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 363 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 364 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 365 366 return test__checkevent_symbolic_name(evlist); 367 } 368 369 static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist) 370 { 371 struct evsel *evsel = evlist__first(evlist); 372 373 TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle); 374 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 375 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 376 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 377 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 378 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 379 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 380 381 return test__checkevent_symbolic_name(evlist); 382 } 383 384 static int test__checkevent_breakpoint_modifier(struct evlist *evlist) 385 { 386 struct evsel *evsel = evlist__first(evlist); 387 388 389 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 390 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 391 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 392 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 393 TEST_ASSERT_VAL("wrong name", 394 !strcmp(evsel__name(evsel), "mem:0:u")); 395 396 return test__checkevent_breakpoint(evlist); 397 } 398 399 static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist) 400 { 401 struct evsel *evsel = evlist__first(evlist); 402 403 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 404 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 405 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 406 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 407 TEST_ASSERT_VAL("wrong name", 408 !strcmp(evsel__name(evsel), "mem:0:x:k")); 409 410 return test__checkevent_breakpoint_x(evlist); 411 } 412 413 static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist) 414 { 415 struct evsel *evsel = evlist__first(evlist); 416 417 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 418 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 419 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 420 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 421 TEST_ASSERT_VAL("wrong name", 422 !strcmp(evsel__name(evsel), "mem:0:r:hp")); 423 424 return test__checkevent_breakpoint_r(evlist); 425 } 426 427 static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist) 428 { 429 struct evsel *evsel = evlist__first(evlist); 430 431 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 432 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 433 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 434 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 435 TEST_ASSERT_VAL("wrong name", 436 !strcmp(evsel__name(evsel), "mem:0:w:up")); 437 438 return test__checkevent_breakpoint_w(evlist); 439 } 440 441 static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist) 442 { 443 struct evsel *evsel = evlist__first(evlist); 444 445 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 446 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 447 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 448 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 449 TEST_ASSERT_VAL("wrong name", 450 !strcmp(evsel__name(evsel), "mem:0:rw:kp")); 451 452 return test__checkevent_breakpoint_rw(evlist); 453 } 454 455 static int test__checkevent_pmu(struct evlist *evlist) 456 { 457 458 struct evsel *evsel = evlist__first(evlist); 459 460 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 461 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 462 TEST_ASSERT_VAL("wrong config", test_config(evsel, 10)); 463 TEST_ASSERT_VAL("wrong config1", 1 == evsel->core.attr.config1); 464 TEST_ASSERT_VAL("wrong config2", 3 == evsel->core.attr.config2); 465 TEST_ASSERT_VAL("wrong config3", 0 == evsel->core.attr.config3); 466 /* 467 * The period value gets configured within evlist__config, 468 * while this test executes only parse events method. 469 */ 470 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period); 471 472 return TEST_OK; 473 } 474 475 #ifdef HAVE_LIBTRACEEVENT 476 static int test__checkevent_list(struct evlist *evlist) 477 { 478 struct evsel *evsel = evlist__first(evlist); 479 480 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries); 481 482 /* r1 */ 483 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 484 TEST_ASSERT_VAL("wrong config", test_config(evsel, 1)); 485 TEST_ASSERT_VAL("wrong config1", 0 == evsel->core.attr.config1); 486 TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2); 487 TEST_ASSERT_VAL("wrong config3", 0 == evsel->core.attr.config3); 488 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 489 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 490 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 491 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 492 493 /* syscalls:sys_enter_openat:k */ 494 evsel = evsel__next(evsel); 495 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type); 496 TEST_ASSERT_VAL("wrong sample_type", 497 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type); 498 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period); 499 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 500 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 501 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 502 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 503 504 /* 1:1:hp */ 505 evsel = evsel__next(evsel); 506 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type); 507 TEST_ASSERT_VAL("wrong config", test_config(evsel, 1)); 508 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 509 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 510 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 511 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 512 513 return TEST_OK; 514 } 515 #endif 516 517 static int test__checkevent_pmu_name(struct evlist *evlist) 518 { 519 struct evsel *evsel = evlist__first(evlist); 520 521 /* cpu/config=1,name=krava/u */ 522 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 523 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 524 TEST_ASSERT_VAL("wrong config", test_config(evsel, 1)); 525 TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "krava")); 526 527 /* cpu/config=2/u" */ 528 evsel = evsel__next(evsel); 529 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 530 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 531 TEST_ASSERT_VAL("wrong config", test_config(evsel, 2)); 532 TEST_ASSERT_VAL("wrong name", 533 !strcmp(evsel__name(evsel), "cpu/config=2/u")); 534 535 return TEST_OK; 536 } 537 538 static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist) 539 { 540 struct evsel *evsel = evlist__first(evlist); 541 542 /* cpu/config=1,call-graph=fp,time,period=100000/ */ 543 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 544 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 545 TEST_ASSERT_VAL("wrong config", test_config(evsel, 1)); 546 /* 547 * The period, time and callgraph value gets configured within evlist__config, 548 * while this test executes only parse events method. 549 */ 550 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period); 551 TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel)); 552 TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type)); 553 554 /* cpu/config=2,call-graph=no,time=0,period=2000/ */ 555 evsel = evsel__next(evsel); 556 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 557 TEST_ASSERT_VAL("wrong config", test_config(evsel, 2)); 558 /* 559 * The period, time and callgraph value gets configured within evlist__config, 560 * while this test executes only parse events method. 561 */ 562 TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period); 563 TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel)); 564 TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type)); 565 566 return TEST_OK; 567 } 568 569 static int test__checkevent_pmu_events(struct evlist *evlist) 570 { 571 struct evsel *evsel = evlist__first(evlist); 572 573 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 574 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type || 575 strcmp(evsel->pmu_name, "cpu")); 576 TEST_ASSERT_VAL("wrong exclude_user", 577 !evsel->core.attr.exclude_user); 578 TEST_ASSERT_VAL("wrong exclude_kernel", 579 evsel->core.attr.exclude_kernel); 580 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 581 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 582 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); 583 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); 584 585 return TEST_OK; 586 } 587 588 589 static int test__checkevent_pmu_events_mix(struct evlist *evlist) 590 { 591 struct evsel *evsel = evlist__first(evlist); 592 593 /* pmu-event:u */ 594 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 595 TEST_ASSERT_VAL("wrong exclude_user", 596 !evsel->core.attr.exclude_user); 597 TEST_ASSERT_VAL("wrong exclude_kernel", 598 evsel->core.attr.exclude_kernel); 599 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 600 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 601 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); 602 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); 603 604 /* cpu/pmu-event/u*/ 605 evsel = evsel__next(evsel); 606 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 607 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type || 608 strcmp(evsel->pmu_name, "cpu")); 609 TEST_ASSERT_VAL("wrong exclude_user", 610 !evsel->core.attr.exclude_user); 611 TEST_ASSERT_VAL("wrong exclude_kernel", 612 evsel->core.attr.exclude_kernel); 613 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 614 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 615 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); 616 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned); 617 618 return TEST_OK; 619 } 620 621 static int test__checkterms_simple(struct list_head *terms) 622 { 623 struct parse_events_term *term; 624 625 /* config=10 */ 626 term = list_entry(terms->next, struct parse_events_term, list); 627 TEST_ASSERT_VAL("wrong type term", 628 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); 629 TEST_ASSERT_VAL("wrong type val", 630 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 631 TEST_ASSERT_VAL("wrong val", term->val.num == 10); 632 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config")); 633 634 /* config1 */ 635 term = list_entry(term->list.next, struct parse_events_term, list); 636 TEST_ASSERT_VAL("wrong type term", 637 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); 638 TEST_ASSERT_VAL("wrong type val", 639 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 640 TEST_ASSERT_VAL("wrong val", term->val.num == 1); 641 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config1")); 642 643 /* config2=3 */ 644 term = list_entry(term->list.next, struct parse_events_term, list); 645 TEST_ASSERT_VAL("wrong type term", 646 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); 647 TEST_ASSERT_VAL("wrong type val", 648 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 649 TEST_ASSERT_VAL("wrong val", term->val.num == 3); 650 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config2")); 651 652 /* config3=4 */ 653 term = list_entry(term->list.next, struct parse_events_term, list); 654 TEST_ASSERT_VAL("wrong type term", 655 term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG3); 656 TEST_ASSERT_VAL("wrong type val", 657 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 658 TEST_ASSERT_VAL("wrong val", term->val.num == 4); 659 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config3")); 660 661 /* umask=1*/ 662 term = list_entry(term->list.next, struct parse_events_term, list); 663 TEST_ASSERT_VAL("wrong type term", 664 term->type_term == PARSE_EVENTS__TERM_TYPE_USER); 665 TEST_ASSERT_VAL("wrong type val", 666 term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 667 TEST_ASSERT_VAL("wrong val", term->val.num == 1); 668 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); 669 670 /* 671 * read 672 * 673 * The perf_pmu__test_parse_init injects 'read' term into 674 * perf_pmu_events_list, so 'read' is evaluated as read term 675 * and not as raw event with 'ead' hex value. 676 */ 677 term = list_entry(term->list.next, struct parse_events_term, list); 678 TEST_ASSERT_VAL("wrong type term", 679 term->type_term == PARSE_EVENTS__TERM_TYPE_RAW); 680 TEST_ASSERT_VAL("wrong type val", 681 term->type_val == PARSE_EVENTS__TERM_TYPE_STR); 682 TEST_ASSERT_VAL("wrong val", !strcmp(term->val.str, "read")); 683 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "raw")); 684 685 /* 686 * r0xead 687 * 688 * To be still able to pass 'ead' value with 'r' syntax, 689 * we added support to parse 'r0xHEX' event. 690 */ 691 term = list_entry(term->list.next, struct parse_events_term, list); 692 TEST_ASSERT_VAL("wrong type term", 693 term->type_term == PARSE_EVENTS__TERM_TYPE_RAW); 694 TEST_ASSERT_VAL("wrong type val", 695 term->type_val == PARSE_EVENTS__TERM_TYPE_STR); 696 TEST_ASSERT_VAL("wrong val", !strcmp(term->val.str, "r0xead")); 697 TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "raw")); 698 return TEST_OK; 699 } 700 701 static int test__group1(struct evlist *evlist) 702 { 703 struct evsel *evsel, *leader; 704 705 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 706 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 707 708 /* instructions:k */ 709 evsel = leader = evlist__first(evlist); 710 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 711 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 712 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 713 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 714 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 715 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 716 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 717 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 718 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 719 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 720 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 721 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 722 723 /* cycles:upp */ 724 evsel = evsel__next(evsel); 725 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 726 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 727 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 728 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 729 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 730 /* use of precise requires exclude_guest */ 731 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 732 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 733 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2); 734 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 735 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 736 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 737 738 return TEST_OK; 739 } 740 741 static int test__group2(struct evlist *evlist) 742 { 743 struct evsel *evsel, *leader; 744 745 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries); 746 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 747 748 /* faults + :ku modifier */ 749 evsel = leader = evlist__first(evlist); 750 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); 751 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_PAGE_FAULTS)); 752 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 753 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 754 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 755 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 756 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 757 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 758 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 759 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 760 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 761 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 762 763 /* cache-references + :u modifier */ 764 evsel = evsel__next(evsel); 765 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 766 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_REFERENCES)); 767 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 768 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 769 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 770 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 771 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 772 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 773 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 774 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 775 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 776 777 /* cycles:k */ 778 evsel = evsel__next(evsel); 779 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 780 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 781 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 782 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 783 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 784 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 785 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 786 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 787 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 788 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 789 790 return TEST_OK; 791 } 792 793 #ifdef HAVE_LIBTRACEEVENT 794 static int test__group3(struct evlist *evlist __maybe_unused) 795 { 796 struct evsel *evsel, *leader; 797 798 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries); 799 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist__nr_groups(evlist)); 800 801 /* group1 syscalls:sys_enter_openat:H */ 802 evsel = leader = evlist__first(evlist); 803 TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type); 804 TEST_ASSERT_VAL("wrong sample_type", 805 PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type); 806 TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period); 807 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 808 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 809 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 810 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 811 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 812 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 813 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 814 TEST_ASSERT_VAL("wrong group name", 815 !strcmp(leader->group_name, "group1")); 816 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 817 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 818 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 819 820 /* group1 cycles:kppp */ 821 evsel = evsel__next(evsel); 822 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 823 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 824 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 825 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 826 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 827 /* use of precise requires exclude_guest */ 828 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 829 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 830 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 3); 831 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 832 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 833 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 834 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 835 836 /* group2 cycles + G modifier */ 837 evsel = leader = evsel__next(evsel); 838 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 839 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 840 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 841 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 842 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 843 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 844 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 845 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 846 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 847 TEST_ASSERT_VAL("wrong group name", 848 !strcmp(leader->group_name, "group2")); 849 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 850 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 851 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 852 853 /* group2 1:3 + G modifier */ 854 evsel = evsel__next(evsel); 855 TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type); 856 TEST_ASSERT_VAL("wrong config", test_config(evsel, 3)); 857 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 858 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 859 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 860 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 861 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 862 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 863 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 864 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 865 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 866 867 /* instructions:u */ 868 evsel = evsel__next(evsel); 869 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 870 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 871 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 872 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 873 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 874 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 875 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 876 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 877 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 878 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 879 880 return TEST_OK; 881 } 882 #endif 883 884 static int test__group4(struct evlist *evlist __maybe_unused) 885 { 886 struct evsel *evsel, *leader; 887 888 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 889 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 890 891 /* cycles:u + p */ 892 evsel = leader = evlist__first(evlist); 893 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 894 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 895 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 896 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 897 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 898 /* use of precise requires exclude_guest */ 899 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 900 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 901 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 1); 902 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 903 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 904 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 905 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 906 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 907 908 /* instructions:kp + p */ 909 evsel = evsel__next(evsel); 910 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 911 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 912 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 913 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 914 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 915 /* use of precise requires exclude_guest */ 916 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 917 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 918 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2); 919 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 920 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 921 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 922 923 return TEST_OK; 924 } 925 926 static int test__group5(struct evlist *evlist __maybe_unused) 927 { 928 struct evsel *evsel, *leader; 929 930 TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->core.nr_entries); 931 TEST_ASSERT_VAL("wrong number of groups", 2 == evlist__nr_groups(evlist)); 932 933 /* cycles + G */ 934 evsel = leader = evlist__first(evlist); 935 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 936 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 937 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 938 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 939 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 940 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 941 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 942 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 943 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 944 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 945 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 946 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 947 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 948 949 /* instructions + G */ 950 evsel = evsel__next(evsel); 951 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 952 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 953 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 954 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 955 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 956 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 957 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 958 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 959 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 960 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 961 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 962 963 /* cycles:G */ 964 evsel = leader = evsel__next(evsel); 965 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 966 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 967 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 968 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 969 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 970 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 971 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 972 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 973 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 974 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 975 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 976 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 977 TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 978 979 /* instructions:G */ 980 evsel = evsel__next(evsel); 981 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 982 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 983 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 984 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 985 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 986 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 987 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 988 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 989 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 990 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 991 992 /* cycles */ 993 evsel = evsel__next(evsel); 994 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 995 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 996 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 997 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 998 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 999 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1000 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1001 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1002 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 1003 1004 return TEST_OK; 1005 } 1006 1007 static int test__group_gh1(struct evlist *evlist) 1008 { 1009 struct evsel *evsel, *leader; 1010 1011 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1012 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 1013 1014 /* cycles + :H group modifier */ 1015 evsel = leader = evlist__first(evlist); 1016 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1017 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1018 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1019 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1020 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1021 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1022 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1023 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1024 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1025 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 1026 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 1027 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 1028 1029 /* cache-misses:G + :H group modifier */ 1030 evsel = evsel__next(evsel); 1031 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1032 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1033 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1034 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1035 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1036 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 1037 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1038 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1039 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1040 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 1041 1042 return TEST_OK; 1043 } 1044 1045 static int test__group_gh2(struct evlist *evlist) 1046 { 1047 struct evsel *evsel, *leader; 1048 1049 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1050 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 1051 1052 /* cycles + :G group modifier */ 1053 evsel = leader = evlist__first(evlist); 1054 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1055 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1056 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1057 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1058 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1059 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 1060 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 1061 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1062 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1063 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 1064 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 1065 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 1066 1067 /* cache-misses:H + :G group modifier */ 1068 evsel = evsel__next(evsel); 1069 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1070 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1071 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1072 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1073 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1074 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 1075 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1076 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1077 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1078 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 1079 1080 return TEST_OK; 1081 } 1082 1083 static int test__group_gh3(struct evlist *evlist) 1084 { 1085 struct evsel *evsel, *leader; 1086 1087 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1088 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 1089 1090 /* cycles:G + :u group modifier */ 1091 evsel = leader = evlist__first(evlist); 1092 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1093 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1094 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1095 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1096 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1097 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 1098 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 1099 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1100 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1101 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 1102 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 1103 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 1104 1105 /* cache-misses:H + :u group modifier */ 1106 evsel = evsel__next(evsel); 1107 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1108 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1109 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1110 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1111 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1112 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1113 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1114 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1115 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1116 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 1117 1118 return TEST_OK; 1119 } 1120 1121 static int test__group_gh4(struct evlist *evlist) 1122 { 1123 struct evsel *evsel, *leader; 1124 1125 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1126 TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist)); 1127 1128 /* cycles:G + :uG group modifier */ 1129 evsel = leader = evlist__first(evlist); 1130 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1131 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1132 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1133 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1134 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1135 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 1136 TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host); 1137 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1138 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1139 TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 1140 TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 1141 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 1142 1143 /* cache-misses:H + :uG group modifier */ 1144 evsel = evsel__next(evsel); 1145 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1146 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1147 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1148 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1149 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1150 TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); 1151 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1152 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1153 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1154 TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 1155 1156 return TEST_OK; 1157 } 1158 1159 static int test__leader_sample1(struct evlist *evlist) 1160 { 1161 struct evsel *evsel, *leader; 1162 1163 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries); 1164 1165 /* cycles - sampling group leader */ 1166 evsel = leader = evlist__first(evlist); 1167 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1168 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1169 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1170 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1171 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1172 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1173 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1174 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1175 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1176 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1177 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1178 1179 /* cache-misses - not sampling */ 1180 evsel = evsel__next(evsel); 1181 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1182 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1183 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1184 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1185 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1186 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1187 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1188 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1189 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1190 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1191 1192 /* branch-misses - not sampling */ 1193 evsel = evsel__next(evsel); 1194 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1195 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES)); 1196 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1197 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1198 TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); 1199 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1200 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1201 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1202 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1203 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1204 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1205 1206 return TEST_OK; 1207 } 1208 1209 static int test__leader_sample2(struct evlist *evlist __maybe_unused) 1210 { 1211 struct evsel *evsel, *leader; 1212 1213 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1214 1215 /* instructions - sampling group leader */ 1216 evsel = leader = evlist__first(evlist); 1217 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1218 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS)); 1219 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1220 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1221 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1222 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1223 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1224 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1225 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1226 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1227 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1228 1229 /* branch-misses - not sampling */ 1230 evsel = evsel__next(evsel); 1231 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1232 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES)); 1233 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1234 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1235 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1236 TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); 1237 TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); 1238 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1239 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1240 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1241 TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1242 1243 return TEST_OK; 1244 } 1245 1246 static int test__checkevent_pinned_modifier(struct evlist *evlist) 1247 { 1248 struct evsel *evsel = evlist__first(evlist); 1249 1250 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1251 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1252 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1253 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 1254 TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned); 1255 1256 return test__checkevent_symbolic_name(evlist); 1257 } 1258 1259 static int test__pinned_group(struct evlist *evlist) 1260 { 1261 struct evsel *evsel, *leader; 1262 1263 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries); 1264 1265 /* cycles - group leader */ 1266 evsel = leader = evlist__first(evlist); 1267 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1268 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1269 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1270 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1271 TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned); 1272 1273 /* cache-misses - can not be pinned, but will go on with the leader */ 1274 evsel = evsel__next(evsel); 1275 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1276 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1277 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); 1278 1279 /* branch-misses - ditto */ 1280 evsel = evsel__next(evsel); 1281 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES)); 1282 TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); 1283 1284 return TEST_OK; 1285 } 1286 1287 static int test__checkevent_exclusive_modifier(struct evlist *evlist) 1288 { 1289 struct evsel *evsel = evlist__first(evlist); 1290 1291 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1292 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1293 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1294 TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); 1295 TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); 1296 1297 return test__checkevent_symbolic_name(evlist); 1298 } 1299 1300 static int test__exclusive_group(struct evlist *evlist) 1301 { 1302 struct evsel *evsel, *leader; 1303 1304 TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries); 1305 1306 /* cycles - group leader */ 1307 evsel = leader = evlist__first(evlist); 1308 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1309 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1310 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1311 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1312 TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); 1313 1314 /* cache-misses - can not be pinned, but will go on with the leader */ 1315 evsel = evsel__next(evsel); 1316 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); 1317 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES)); 1318 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); 1319 1320 /* branch-misses - ditto */ 1321 evsel = evsel__next(evsel); 1322 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES)); 1323 TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); 1324 1325 return TEST_OK; 1326 } 1327 static int test__checkevent_breakpoint_len(struct evlist *evlist) 1328 { 1329 struct evsel *evsel = evlist__first(evlist); 1330 1331 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1332 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 1333 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 1334 TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == 1335 evsel->core.attr.bp_type); 1336 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 == 1337 evsel->core.attr.bp_len); 1338 1339 return TEST_OK; 1340 } 1341 1342 static int test__checkevent_breakpoint_len_w(struct evlist *evlist) 1343 { 1344 struct evsel *evsel = evlist__first(evlist); 1345 1346 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1347 TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type); 1348 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0)); 1349 TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W == 1350 evsel->core.attr.bp_type); 1351 TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 == 1352 evsel->core.attr.bp_len); 1353 1354 return TEST_OK; 1355 } 1356 1357 static int 1358 test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist) 1359 { 1360 struct evsel *evsel = evlist__first(evlist); 1361 1362 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1363 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1364 TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); 1365 TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); 1366 1367 return test__checkevent_breakpoint_rw(evlist); 1368 } 1369 1370 static int test__checkevent_precise_max_modifier(struct evlist *evlist) 1371 { 1372 struct evsel *evsel = evlist__first(evlist); 1373 1374 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1375 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); 1376 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_TASK_CLOCK)); 1377 return TEST_OK; 1378 } 1379 1380 static int test__checkevent_config_symbol(struct evlist *evlist) 1381 { 1382 struct evsel *evsel = evlist__first(evlist); 1383 1384 TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "insn")); 1385 return TEST_OK; 1386 } 1387 1388 static int test__checkevent_config_raw(struct evlist *evlist) 1389 { 1390 struct evsel *evsel = evlist__first(evlist); 1391 1392 TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "rawpmu")); 1393 return TEST_OK; 1394 } 1395 1396 static int test__checkevent_config_num(struct evlist *evlist) 1397 { 1398 struct evsel *evsel = evlist__first(evlist); 1399 1400 TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "numpmu")); 1401 return TEST_OK; 1402 } 1403 1404 static int test__checkevent_config_cache(struct evlist *evlist) 1405 { 1406 struct evsel *evsel = evlist__first(evlist); 1407 1408 TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "cachepmu")); 1409 return test__checkevent_genhw(evlist); 1410 } 1411 1412 static bool test__pmu_cpu_valid(void) 1413 { 1414 return !!perf_pmu__find("cpu"); 1415 } 1416 1417 static bool test__intel_pt_valid(void) 1418 { 1419 return !!perf_pmu__find("intel_pt"); 1420 } 1421 1422 static int test__intel_pt(struct evlist *evlist) 1423 { 1424 struct evsel *evsel = evlist__first(evlist); 1425 1426 TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "intel_pt//u")); 1427 return TEST_OK; 1428 } 1429 1430 static int test__checkevent_complex_name(struct evlist *evlist) 1431 { 1432 struct evsel *evsel = evlist__first(evlist); 1433 1434 TEST_ASSERT_VAL("wrong complex name parsing", 1435 evsel__name_is(evsel, 1436 "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks")); 1437 return TEST_OK; 1438 } 1439 1440 static int test__checkevent_raw_pmu(struct evlist *evlist) 1441 { 1442 struct evsel *evsel = evlist__first(evlist); 1443 1444 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1445 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); 1446 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a)); 1447 return TEST_OK; 1448 } 1449 1450 static int test__sym_event_slash(struct evlist *evlist) 1451 { 1452 struct evsel *evsel = evlist__first(evlist); 1453 1454 TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE); 1455 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1456 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1457 return TEST_OK; 1458 } 1459 1460 static int test__sym_event_dc(struct evlist *evlist) 1461 { 1462 struct evsel *evsel = evlist__first(evlist); 1463 1464 TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE); 1465 TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); 1466 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 1467 return TEST_OK; 1468 } 1469 1470 #ifdef HAVE_LIBTRACEEVENT 1471 static int count_tracepoints(void) 1472 { 1473 struct dirent *events_ent; 1474 DIR *events_dir; 1475 int cnt = 0; 1476 1477 events_dir = tracing_events__opendir(); 1478 1479 TEST_ASSERT_VAL("Can't open events dir", events_dir); 1480 1481 while ((events_ent = readdir(events_dir))) { 1482 char *sys_path; 1483 struct dirent *sys_ent; 1484 DIR *sys_dir; 1485 1486 if (!strcmp(events_ent->d_name, ".") 1487 || !strcmp(events_ent->d_name, "..") 1488 || !strcmp(events_ent->d_name, "enable") 1489 || !strcmp(events_ent->d_name, "header_event") 1490 || !strcmp(events_ent->d_name, "header_page")) 1491 continue; 1492 1493 sys_path = get_events_file(events_ent->d_name); 1494 TEST_ASSERT_VAL("Can't get sys path", sys_path); 1495 1496 sys_dir = opendir(sys_path); 1497 TEST_ASSERT_VAL("Can't open sys dir", sys_dir); 1498 1499 while ((sys_ent = readdir(sys_dir))) { 1500 if (!strcmp(sys_ent->d_name, ".") 1501 || !strcmp(sys_ent->d_name, "..") 1502 || !strcmp(sys_ent->d_name, "enable") 1503 || !strcmp(sys_ent->d_name, "filter")) 1504 continue; 1505 1506 cnt++; 1507 } 1508 1509 closedir(sys_dir); 1510 put_events_file(sys_path); 1511 } 1512 1513 closedir(events_dir); 1514 return cnt; 1515 } 1516 1517 static int test__all_tracepoints(struct evlist *evlist) 1518 { 1519 TEST_ASSERT_VAL("wrong events count", 1520 count_tracepoints() == evlist->core.nr_entries); 1521 1522 return test__checkevent_tracepoint_multi(evlist); 1523 } 1524 #endif /* HAVE_LIBTRACEVENT */ 1525 1526 static int test__hybrid_hw_event_with_pmu(struct evlist *evlist) 1527 { 1528 struct evsel *evsel = evlist__first(evlist); 1529 1530 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1531 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1532 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x3c)); 1533 return TEST_OK; 1534 } 1535 1536 static int test__hybrid_hw_group_event(struct evlist *evlist) 1537 { 1538 struct evsel *evsel, *leader; 1539 1540 evsel = leader = evlist__first(evlist); 1541 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1542 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1543 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x3c)); 1544 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1545 1546 evsel = evsel__next(evsel); 1547 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1548 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0xc0)); 1549 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1550 return TEST_OK; 1551 } 1552 1553 static int test__hybrid_sw_hw_group_event(struct evlist *evlist) 1554 { 1555 struct evsel *evsel, *leader; 1556 1557 evsel = leader = evlist__first(evlist); 1558 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1559 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); 1560 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1561 1562 evsel = evsel__next(evsel); 1563 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1564 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x3c)); 1565 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1566 return TEST_OK; 1567 } 1568 1569 static int test__hybrid_hw_sw_group_event(struct evlist *evlist) 1570 { 1571 struct evsel *evsel, *leader; 1572 1573 evsel = leader = evlist__first(evlist); 1574 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1575 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1576 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x3c)); 1577 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1578 1579 evsel = evsel__next(evsel); 1580 TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); 1581 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1582 return TEST_OK; 1583 } 1584 1585 static int test__hybrid_group_modifier1(struct evlist *evlist) 1586 { 1587 struct evsel *evsel, *leader; 1588 1589 evsel = leader = evlist__first(evlist); 1590 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1591 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1592 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x3c)); 1593 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1594 TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); 1595 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); 1596 1597 evsel = evsel__next(evsel); 1598 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1599 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0xc0)); 1600 TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); 1601 TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); 1602 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); 1603 return TEST_OK; 1604 } 1605 1606 static int test__hybrid_raw1(struct evlist *evlist) 1607 { 1608 struct evsel *evsel = evlist__first(evlist); 1609 1610 if (!perf_pmu__hybrid_mounted("cpu_atom")) { 1611 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1612 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1613 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a)); 1614 return TEST_OK; 1615 } 1616 1617 TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries); 1618 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1619 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a)); 1620 1621 /* The type of second event is randome value */ 1622 evsel = evsel__next(evsel); 1623 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a)); 1624 return TEST_OK; 1625 } 1626 1627 static int test__hybrid_raw2(struct evlist *evlist) 1628 { 1629 struct evsel *evsel = evlist__first(evlist); 1630 1631 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1632 TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type); 1633 TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a)); 1634 return TEST_OK; 1635 } 1636 1637 static int test__hybrid_cache_event(struct evlist *evlist) 1638 { 1639 struct evsel *evsel = evlist__first(evlist); 1640 1641 TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); 1642 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type); 1643 TEST_ASSERT_VAL("wrong config", 0x2 == (evsel->core.attr.config & 0xffffffff)); 1644 return TEST_OK; 1645 } 1646 1647 struct evlist_test { 1648 const char *name; 1649 bool (*valid)(void); 1650 int (*check)(struct evlist *evlist); 1651 }; 1652 1653 static const struct evlist_test test__events[] = { 1654 #ifdef HAVE_LIBTRACEEVENT 1655 { 1656 .name = "syscalls:sys_enter_openat", 1657 .check = test__checkevent_tracepoint, 1658 /* 0 */ 1659 }, 1660 { 1661 .name = "syscalls:*", 1662 .check = test__checkevent_tracepoint_multi, 1663 /* 1 */ 1664 }, 1665 #endif 1666 { 1667 .name = "r1a", 1668 .check = test__checkevent_raw, 1669 /* 2 */ 1670 }, 1671 { 1672 .name = "1:1", 1673 .check = test__checkevent_numeric, 1674 /* 3 */ 1675 }, 1676 { 1677 .name = "instructions", 1678 .check = test__checkevent_symbolic_name, 1679 /* 4 */ 1680 }, 1681 { 1682 .name = "cycles/period=100000,config2/", 1683 .check = test__checkevent_symbolic_name_config, 1684 /* 5 */ 1685 }, 1686 { 1687 .name = "faults", 1688 .check = test__checkevent_symbolic_alias, 1689 /* 6 */ 1690 }, 1691 { 1692 .name = "L1-dcache-load-miss", 1693 .check = test__checkevent_genhw, 1694 /* 7 */ 1695 }, 1696 { 1697 .name = "mem:0", 1698 .check = test__checkevent_breakpoint, 1699 /* 8 */ 1700 }, 1701 { 1702 .name = "mem:0:x", 1703 .check = test__checkevent_breakpoint_x, 1704 /* 9 */ 1705 }, 1706 { 1707 .name = "mem:0:r", 1708 .check = test__checkevent_breakpoint_r, 1709 /* 0 */ 1710 }, 1711 { 1712 .name = "mem:0:w", 1713 .check = test__checkevent_breakpoint_w, 1714 /* 1 */ 1715 }, 1716 #ifdef HAVE_LIBTRACEEVENT 1717 { 1718 .name = "syscalls:sys_enter_openat:k", 1719 .check = test__checkevent_tracepoint_modifier, 1720 /* 2 */ 1721 }, 1722 { 1723 .name = "syscalls:*:u", 1724 .check = test__checkevent_tracepoint_multi_modifier, 1725 /* 3 */ 1726 }, 1727 #endif 1728 { 1729 .name = "r1a:kp", 1730 .check = test__checkevent_raw_modifier, 1731 /* 4 */ 1732 }, 1733 { 1734 .name = "1:1:hp", 1735 .check = test__checkevent_numeric_modifier, 1736 /* 5 */ 1737 }, 1738 { 1739 .name = "instructions:h", 1740 .check = test__checkevent_symbolic_name_modifier, 1741 /* 6 */ 1742 }, 1743 { 1744 .name = "faults:u", 1745 .check = test__checkevent_symbolic_alias_modifier, 1746 /* 7 */ 1747 }, 1748 { 1749 .name = "L1-dcache-load-miss:kp", 1750 .check = test__checkevent_genhw_modifier, 1751 /* 8 */ 1752 }, 1753 { 1754 .name = "mem:0:u", 1755 .check = test__checkevent_breakpoint_modifier, 1756 /* 9 */ 1757 }, 1758 { 1759 .name = "mem:0:x:k", 1760 .check = test__checkevent_breakpoint_x_modifier, 1761 /* 0 */ 1762 }, 1763 { 1764 .name = "mem:0:r:hp", 1765 .check = test__checkevent_breakpoint_r_modifier, 1766 /* 1 */ 1767 }, 1768 { 1769 .name = "mem:0:w:up", 1770 .check = test__checkevent_breakpoint_w_modifier, 1771 /* 2 */ 1772 }, 1773 #ifdef HAVE_LIBTRACEEVENT 1774 { 1775 .name = "r1,syscalls:sys_enter_openat:k,1:1:hp", 1776 .check = test__checkevent_list, 1777 /* 3 */ 1778 }, 1779 #endif 1780 { 1781 .name = "instructions:G", 1782 .check = test__checkevent_exclude_host_modifier, 1783 /* 4 */ 1784 }, 1785 { 1786 .name = "instructions:H", 1787 .check = test__checkevent_exclude_guest_modifier, 1788 /* 5 */ 1789 }, 1790 { 1791 .name = "mem:0:rw", 1792 .check = test__checkevent_breakpoint_rw, 1793 /* 6 */ 1794 }, 1795 { 1796 .name = "mem:0:rw:kp", 1797 .check = test__checkevent_breakpoint_rw_modifier, 1798 /* 7 */ 1799 }, 1800 { 1801 .name = "{instructions:k,cycles:upp}", 1802 .check = test__group1, 1803 /* 8 */ 1804 }, 1805 { 1806 .name = "{faults:k,cache-references}:u,cycles:k", 1807 .check = test__group2, 1808 /* 9 */ 1809 }, 1810 #ifdef HAVE_LIBTRACEEVENT 1811 { 1812 .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", 1813 .check = test__group3, 1814 /* 0 */ 1815 }, 1816 #endif 1817 { 1818 .name = "{cycles:u,instructions:kp}:p", 1819 .check = test__group4, 1820 /* 1 */ 1821 }, 1822 { 1823 .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", 1824 .check = test__group5, 1825 /* 2 */ 1826 }, 1827 #ifdef HAVE_LIBTRACEEVENT 1828 { 1829 .name = "*:*", 1830 .check = test__all_tracepoints, 1831 /* 3 */ 1832 }, 1833 #endif 1834 { 1835 .name = "{cycles,cache-misses:G}:H", 1836 .check = test__group_gh1, 1837 /* 4 */ 1838 }, 1839 { 1840 .name = "{cycles,cache-misses:H}:G", 1841 .check = test__group_gh2, 1842 /* 5 */ 1843 }, 1844 { 1845 .name = "{cycles:G,cache-misses:H}:u", 1846 .check = test__group_gh3, 1847 /* 6 */ 1848 }, 1849 { 1850 .name = "{cycles:G,cache-misses:H}:uG", 1851 .check = test__group_gh4, 1852 /* 7 */ 1853 }, 1854 { 1855 .name = "{cycles,cache-misses,branch-misses}:S", 1856 .check = test__leader_sample1, 1857 /* 8 */ 1858 }, 1859 { 1860 .name = "{instructions,branch-misses}:Su", 1861 .check = test__leader_sample2, 1862 /* 9 */ 1863 }, 1864 { 1865 .name = "instructions:uDp", 1866 .check = test__checkevent_pinned_modifier, 1867 /* 0 */ 1868 }, 1869 { 1870 .name = "{cycles,cache-misses,branch-misses}:D", 1871 .check = test__pinned_group, 1872 /* 1 */ 1873 }, 1874 { 1875 .name = "mem:0/1", 1876 .check = test__checkevent_breakpoint_len, 1877 /* 2 */ 1878 }, 1879 { 1880 .name = "mem:0/2:w", 1881 .check = test__checkevent_breakpoint_len_w, 1882 /* 3 */ 1883 }, 1884 { 1885 .name = "mem:0/4:rw:u", 1886 .check = test__checkevent_breakpoint_len_rw_modifier, 1887 /* 4 */ 1888 }, 1889 #if defined(__s390x__) && defined(HAVE_LIBTRACEEVENT) 1890 { 1891 .name = "kvm-s390:kvm_s390_create_vm", 1892 .check = test__checkevent_tracepoint, 1893 .valid = kvm_s390_create_vm_valid, 1894 /* 0 */ 1895 }, 1896 #endif 1897 { 1898 .name = "instructions:I", 1899 .check = test__checkevent_exclude_idle_modifier, 1900 /* 5 */ 1901 }, 1902 { 1903 .name = "instructions:kIG", 1904 .check = test__checkevent_exclude_idle_modifier_1, 1905 /* 6 */ 1906 }, 1907 { 1908 .name = "task-clock:P,cycles", 1909 .check = test__checkevent_precise_max_modifier, 1910 /* 7 */ 1911 }, 1912 { 1913 .name = "instructions/name=insn/", 1914 .check = test__checkevent_config_symbol, 1915 /* 8 */ 1916 }, 1917 { 1918 .name = "r1234/name=rawpmu/", 1919 .check = test__checkevent_config_raw, 1920 /* 9 */ 1921 }, 1922 { 1923 .name = "4:0x6530160/name=numpmu/", 1924 .check = test__checkevent_config_num, 1925 /* 0 */ 1926 }, 1927 { 1928 .name = "L1-dcache-misses/name=cachepmu/", 1929 .check = test__checkevent_config_cache, 1930 /* 1 */ 1931 }, 1932 { 1933 .name = "intel_pt//u", 1934 .valid = test__intel_pt_valid, 1935 .check = test__intel_pt, 1936 /* 2 */ 1937 }, 1938 { 1939 .name = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk", 1940 .check = test__checkevent_complex_name, 1941 /* 3 */ 1942 }, 1943 { 1944 .name = "cycles//u", 1945 .check = test__sym_event_slash, 1946 /* 4 */ 1947 }, 1948 { 1949 .name = "cycles:k", 1950 .check = test__sym_event_dc, 1951 /* 5 */ 1952 }, 1953 { 1954 .name = "instructions:uep", 1955 .check = test__checkevent_exclusive_modifier, 1956 /* 6 */ 1957 }, 1958 { 1959 .name = "{cycles,cache-misses,branch-misses}:e", 1960 .check = test__exclusive_group, 1961 /* 7 */ 1962 }, 1963 }; 1964 1965 static const struct evlist_test test__events_pmu[] = { 1966 { 1967 .name = "cpu/config=10,config1,config2=3,period=1000/u", 1968 .valid = test__pmu_cpu_valid, 1969 .check = test__checkevent_pmu, 1970 /* 0 */ 1971 }, 1972 { 1973 .name = "cpu/config=1,name=krava/u,cpu/config=2/u", 1974 .valid = test__pmu_cpu_valid, 1975 .check = test__checkevent_pmu_name, 1976 /* 1 */ 1977 }, 1978 { 1979 .name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/", 1980 .valid = test__pmu_cpu_valid, 1981 .check = test__checkevent_pmu_partial_time_callgraph, 1982 /* 2 */ 1983 }, 1984 { 1985 .name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp", 1986 .valid = test__pmu_cpu_valid, 1987 .check = test__checkevent_complex_name, 1988 /* 3 */ 1989 }, 1990 { 1991 .name = "software/r1a/", 1992 .check = test__checkevent_raw_pmu, 1993 /* 4 */ 1994 }, 1995 { 1996 .name = "software/r0x1a/", 1997 .check = test__checkevent_raw_pmu, 1998 /* 5 */ 1999 }, 2000 }; 2001 2002 struct terms_test { 2003 const char *str; 2004 int (*check)(struct list_head *terms); 2005 }; 2006 2007 static const struct terms_test test__terms[] = { 2008 [0] = { 2009 .str = "config=10,config1,config2=3,config3=4,umask=1,read,r0xead", 2010 .check = test__checkterms_simple, 2011 }, 2012 }; 2013 2014 static const struct evlist_test test__hybrid_events[] = { 2015 { 2016 .name = "cpu_core/cpu-cycles/", 2017 .check = test__hybrid_hw_event_with_pmu, 2018 /* 0 */ 2019 }, 2020 { 2021 .name = "{cpu_core/cpu-cycles/,cpu_core/instructions/}", 2022 .check = test__hybrid_hw_group_event, 2023 /* 1 */ 2024 }, 2025 { 2026 .name = "{cpu-clock,cpu_core/cpu-cycles/}", 2027 .check = test__hybrid_sw_hw_group_event, 2028 /* 2 */ 2029 }, 2030 { 2031 .name = "{cpu_core/cpu-cycles/,cpu-clock}", 2032 .check = test__hybrid_hw_sw_group_event, 2033 /* 3 */ 2034 }, 2035 { 2036 .name = "{cpu_core/cpu-cycles/k,cpu_core/instructions/u}", 2037 .check = test__hybrid_group_modifier1, 2038 /* 4 */ 2039 }, 2040 { 2041 .name = "r1a", 2042 .check = test__hybrid_raw1, 2043 /* 5 */ 2044 }, 2045 { 2046 .name = "cpu_core/r1a/", 2047 .check = test__hybrid_raw2, 2048 /* 6 */ 2049 }, 2050 { 2051 .name = "cpu_core/config=10,config1,config2=3,period=1000/u", 2052 .check = test__checkevent_pmu, 2053 /* 7 */ 2054 }, 2055 { 2056 .name = "cpu_core/LLC-loads/", 2057 .check = test__hybrid_cache_event, 2058 /* 8 */ 2059 }, 2060 }; 2061 2062 static int test_event(const struct evlist_test *e) 2063 { 2064 struct parse_events_error err; 2065 struct evlist *evlist; 2066 int ret; 2067 2068 if (e->valid && !e->valid()) { 2069 pr_debug("... SKIP\n"); 2070 return TEST_OK; 2071 } 2072 2073 evlist = evlist__new(); 2074 if (evlist == NULL) { 2075 pr_err("Failed allocation"); 2076 return TEST_FAIL; 2077 } 2078 parse_events_error__init(&err); 2079 ret = parse_events(evlist, e->name, &err); 2080 if (ret) { 2081 pr_debug("failed to parse event '%s', err %d, str '%s'\n", 2082 e->name, ret, err.str); 2083 parse_events_error__print(&err, e->name); 2084 ret = TEST_FAIL; 2085 if (strstr(err.str, "can't access trace events")) 2086 ret = TEST_SKIP; 2087 } else { 2088 ret = e->check(evlist); 2089 } 2090 parse_events_error__exit(&err); 2091 evlist__delete(evlist); 2092 2093 return ret; 2094 } 2095 2096 static int test_event_fake_pmu(const char *str) 2097 { 2098 struct parse_events_error err; 2099 struct evlist *evlist; 2100 int ret; 2101 2102 evlist = evlist__new(); 2103 if (!evlist) 2104 return -ENOMEM; 2105 2106 parse_events_error__init(&err); 2107 ret = __parse_events(evlist, str, &err, &perf_pmu__fake, /*warn_if_reordered=*/true); 2108 if (ret) { 2109 pr_debug("failed to parse event '%s', err %d, str '%s'\n", 2110 str, ret, err.str); 2111 parse_events_error__print(&err, str); 2112 } 2113 2114 parse_events_error__exit(&err); 2115 evlist__delete(evlist); 2116 2117 return ret; 2118 } 2119 2120 static int combine_test_results(int existing, int latest) 2121 { 2122 if (existing == TEST_FAIL) 2123 return TEST_FAIL; 2124 if (existing == TEST_SKIP) 2125 return latest == TEST_OK ? TEST_SKIP : latest; 2126 return latest; 2127 } 2128 2129 static int test_events(const struct evlist_test *events, int cnt) 2130 { 2131 int ret = TEST_OK; 2132 2133 for (int i = 0; i < cnt; i++) { 2134 const struct evlist_test *e = &events[i]; 2135 int test_ret; 2136 2137 pr_debug("running test %d '%s'\n", i, e->name); 2138 test_ret = test_event(e); 2139 if (test_ret != TEST_OK) { 2140 pr_debug("Event test failure: test %d '%s'", i, e->name); 2141 ret = combine_test_results(ret, test_ret); 2142 } 2143 } 2144 2145 return ret; 2146 } 2147 2148 static int test__events2(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 2149 { 2150 return test_events(test__events, ARRAY_SIZE(test__events)); 2151 } 2152 2153 static int test_term(const struct terms_test *t) 2154 { 2155 struct list_head terms; 2156 int ret; 2157 2158 INIT_LIST_HEAD(&terms); 2159 2160 ret = parse_events_terms(&terms, t->str); 2161 if (ret) { 2162 pr_debug("failed to parse terms '%s', err %d\n", 2163 t->str , ret); 2164 return ret; 2165 } 2166 2167 ret = t->check(&terms); 2168 parse_events_terms__purge(&terms); 2169 2170 return ret; 2171 } 2172 2173 static int test_terms(const struct terms_test *terms, int cnt) 2174 { 2175 int ret = 0; 2176 2177 for (int i = 0; i < cnt; i++) { 2178 const struct terms_test *t = &terms[i]; 2179 2180 pr_debug("running test %d '%s'\n", i, t->str); 2181 ret = test_term(t); 2182 if (ret) 2183 break; 2184 } 2185 2186 return ret; 2187 } 2188 2189 static int test__terms2(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 2190 { 2191 return test_terms(test__terms, ARRAY_SIZE(test__terms)); 2192 } 2193 2194 static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 2195 { 2196 struct perf_pmu *pmu; 2197 int ret = TEST_OK; 2198 2199 if (list_empty(&pmus)) 2200 perf_pmu__scan(NULL); 2201 2202 perf_pmus__for_each_pmu(pmu) { 2203 struct stat st; 2204 char path[PATH_MAX]; 2205 struct dirent *ent; 2206 DIR *dir; 2207 int err; 2208 2209 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/", 2210 sysfs__mountpoint(), pmu->name); 2211 2212 err = stat(path, &st); 2213 if (err) { 2214 pr_debug("skipping PMU %s events tests: %s\n", pmu->name, path); 2215 continue; 2216 } 2217 2218 dir = opendir(path); 2219 if (!dir) { 2220 pr_debug("can't open pmu event dir: %s\n", path); 2221 ret = combine_test_results(ret, TEST_SKIP); 2222 continue; 2223 } 2224 2225 while ((ent = readdir(dir))) { 2226 struct evlist_test e = { .name = NULL, }; 2227 char name[2 * NAME_MAX + 1 + 12 + 3]; 2228 int test_ret; 2229 2230 /* Names containing . are special and cannot be used directly */ 2231 if (strchr(ent->d_name, '.')) 2232 continue; 2233 2234 snprintf(name, sizeof(name), "%s/event=%s/u", pmu->name, ent->d_name); 2235 2236 e.name = name; 2237 e.check = test__checkevent_pmu_events; 2238 2239 test_ret = test_event(&e); 2240 if (test_ret != TEST_OK) { 2241 pr_debug("Test PMU event failed for '%s'", name); 2242 ret = combine_test_results(ret, test_ret); 2243 } 2244 2245 if (!is_pmu_core(pmu->name)) 2246 continue; 2247 2248 /* 2249 * Names containing '-' are recognized as prefixes and suffixes 2250 * due to '-' being a legacy PMU separator. This fails when the 2251 * prefix or suffix collides with an existing legacy token. For 2252 * example, branch-brs has a prefix (branch) that collides with 2253 * a PE_NAME_CACHE_TYPE token causing a parse error as a suffix 2254 * isn't expected after this. As event names in the config 2255 * slashes are allowed a '-' in the name we check this works 2256 * above. 2257 */ 2258 if (strchr(ent->d_name, '-')) 2259 continue; 2260 2261 snprintf(name, sizeof(name), "%s:u,%s/event=%s/u", 2262 ent->d_name, pmu->name, ent->d_name); 2263 e.name = name; 2264 e.check = test__checkevent_pmu_events_mix; 2265 test_ret = test_event(&e); 2266 if (test_ret != TEST_OK) { 2267 pr_debug("Test PMU event failed for '%s'", name); 2268 ret = combine_test_results(ret, test_ret); 2269 } 2270 } 2271 2272 closedir(dir); 2273 } 2274 return ret; 2275 } 2276 2277 static int test__pmu_events2(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 2278 { 2279 return test_events(test__events_pmu, ARRAY_SIZE(test__events_pmu)); 2280 } 2281 2282 static bool test_alias(char **event, char **alias) 2283 { 2284 char path[PATH_MAX]; 2285 DIR *dir; 2286 struct dirent *dent; 2287 const char *sysfs = sysfs__mountpoint(); 2288 char buf[128]; 2289 FILE *file; 2290 2291 if (!sysfs) 2292 return false; 2293 2294 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/", sysfs); 2295 dir = opendir(path); 2296 if (!dir) 2297 return false; 2298 2299 while ((dent = readdir(dir))) { 2300 if (!strcmp(dent->d_name, ".") || 2301 !strcmp(dent->d_name, "..")) 2302 continue; 2303 2304 snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/alias", 2305 sysfs, dent->d_name); 2306 2307 if (!file_available(path)) 2308 continue; 2309 2310 file = fopen(path, "r"); 2311 if (!file) 2312 continue; 2313 2314 if (!fgets(buf, sizeof(buf), file)) { 2315 fclose(file); 2316 continue; 2317 } 2318 2319 /* Remove the last '\n' */ 2320 buf[strlen(buf) - 1] = 0; 2321 2322 fclose(file); 2323 *event = strdup(dent->d_name); 2324 *alias = strdup(buf); 2325 closedir(dir); 2326 2327 if (*event == NULL || *alias == NULL) { 2328 free(*event); 2329 free(*alias); 2330 return false; 2331 } 2332 2333 return true; 2334 } 2335 2336 closedir(dir); 2337 return false; 2338 } 2339 2340 static int test__hybrid(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 2341 { 2342 if (!perf_pmu__has_hybrid()) 2343 return TEST_SKIP; 2344 2345 return test_events(test__hybrid_events, ARRAY_SIZE(test__hybrid_events)); 2346 } 2347 2348 static int test__checkevent_pmu_events_alias(struct evlist *evlist) 2349 { 2350 struct evsel *evsel1 = evlist__first(evlist); 2351 struct evsel *evsel2 = evlist__last(evlist); 2352 2353 TEST_ASSERT_VAL("wrong type", evsel1->core.attr.type == evsel2->core.attr.type); 2354 TEST_ASSERT_VAL("wrong config", evsel1->core.attr.config == evsel2->core.attr.config); 2355 return TEST_OK; 2356 } 2357 2358 static int test__pmu_events_alias(char *event, char *alias) 2359 { 2360 struct evlist_test e = { .name = NULL, }; 2361 char name[2 * NAME_MAX + 20]; 2362 2363 snprintf(name, sizeof(name), "%s/event=1/,%s/event=1/", 2364 event, alias); 2365 2366 e.name = name; 2367 e.check = test__checkevent_pmu_events_alias; 2368 return test_event(&e); 2369 } 2370 2371 static int test__alias(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 2372 { 2373 char *event, *alias; 2374 int ret; 2375 2376 if (!test_alias(&event, &alias)) 2377 return TEST_SKIP; 2378 2379 ret = test__pmu_events_alias(event, alias); 2380 2381 free(event); 2382 free(alias); 2383 return ret; 2384 } 2385 2386 static int test__pmu_events_alias2(struct test_suite *test __maybe_unused, 2387 int subtest __maybe_unused) 2388 { 2389 static const char events[][30] = { 2390 "event-hyphen", 2391 "event-two-hyph", 2392 }; 2393 int ret = TEST_OK; 2394 2395 for (unsigned int i = 0; i < ARRAY_SIZE(events); i++) { 2396 int test_ret = test_event_fake_pmu(&events[i][0]); 2397 2398 if (test_ret != TEST_OK) { 2399 pr_debug("check_parse_fake %s failed\n", &events[i][0]); 2400 ret = combine_test_results(ret, test_ret); 2401 } 2402 } 2403 2404 return ret; 2405 } 2406 2407 static struct test_case tests__parse_events[] = { 2408 TEST_CASE_REASON("Test event parsing", 2409 events2, 2410 "permissions"), 2411 TEST_CASE_REASON("Test parsing of \"hybrid\" CPU events", 2412 hybrid, 2413 "not hybrid"), 2414 TEST_CASE_REASON("Parsing of all PMU events from sysfs", 2415 pmu_events, 2416 "permissions"), 2417 TEST_CASE_REASON("Parsing of given PMU events from sysfs", 2418 pmu_events2, 2419 "permissions"), 2420 TEST_CASE_REASON("Parsing of aliased events from sysfs", alias, 2421 "no aliases in sysfs"), 2422 TEST_CASE("Parsing of aliased events", pmu_events_alias2), 2423 TEST_CASE("Parsing of terms (event modifiers)", terms2), 2424 { .name = NULL, } 2425 }; 2426 2427 struct test_suite suite__parse_events = { 2428 .desc = "Parse event definition strings", 2429 .test_cases = tests__parse_events, 2430 }; 2431