1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2945aea22SJiri Olsa #include "parse-events.h" 3945aea22SJiri Olsa #include "evsel.h" 4945aea22SJiri Olsa #include "evlist.h" 5cd0cfad7SBorislav Petkov #include <api/fs/fs.h> 6c81251e8SJiri Olsa #include "tests.h" 784f5d36fSJiri Olsa #include "debug.h" 82690c730SNamhyung Kim #include "util.h" 976b31a29SArnaldo Carvalho de Melo #include <dirent.h> 10a43783aeSArnaldo Carvalho de Melo #include <errno.h> 117a8ef4c4SArnaldo Carvalho de Melo #include <sys/types.h> 127a8ef4c4SArnaldo Carvalho de Melo #include <sys/stat.h> 137a8ef4c4SArnaldo Carvalho de Melo #include <unistd.h> 14877a7a11SArnaldo Carvalho de Melo #include <linux/kernel.h> 15f0b9abfbSIngo Molnar #include <linux/hw_breakpoint.h> 1620a9ed28SArnaldo Carvalho de Melo #include <api/fs/tracing_path.h> 17945aea22SJiri Olsa 18945aea22SJiri Olsa #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ 19945aea22SJiri Olsa PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) 20945aea22SJiri Olsa 21945aea22SJiri Olsa static int test__checkevent_tracepoint(struct perf_evlist *evlist) 22945aea22SJiri Olsa { 23945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 24945aea22SJiri Olsa 25945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 268d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); 27945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 28945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 29945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 30945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); 31945aea22SJiri Olsa return 0; 32945aea22SJiri Olsa } 33945aea22SJiri Olsa 34945aea22SJiri Olsa static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) 35945aea22SJiri Olsa { 36945aea22SJiri Olsa struct perf_evsel *evsel; 37945aea22SJiri Olsa 38945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); 398d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); 40945aea22SJiri Olsa 41e5cadb93SArnaldo Carvalho de Melo evlist__for_each_entry(evlist, evsel) { 42945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 43945aea22SJiri Olsa PERF_TYPE_TRACEPOINT == evsel->attr.type); 44945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 45945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 46945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 47945aea22SJiri Olsa 1 == evsel->attr.sample_period); 48945aea22SJiri Olsa } 49945aea22SJiri Olsa return 0; 50945aea22SJiri Olsa } 51945aea22SJiri Olsa 52945aea22SJiri Olsa static int test__checkevent_raw(struct perf_evlist *evlist) 53945aea22SJiri Olsa { 54945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 55945aea22SJiri Olsa 56945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 57945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 58945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config); 59945aea22SJiri Olsa return 0; 60945aea22SJiri Olsa } 61945aea22SJiri Olsa 62945aea22SJiri Olsa static int test__checkevent_numeric(struct perf_evlist *evlist) 63945aea22SJiri Olsa { 64945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 65945aea22SJiri Olsa 66945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 67945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); 68945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 69945aea22SJiri Olsa return 0; 70945aea22SJiri Olsa } 71945aea22SJiri Olsa 72945aea22SJiri Olsa static int test__checkevent_symbolic_name(struct perf_evlist *evlist) 73945aea22SJiri Olsa { 74945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 75945aea22SJiri Olsa 76945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 77945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 78945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 79945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 80945aea22SJiri Olsa return 0; 81945aea22SJiri Olsa } 82945aea22SJiri Olsa 83945aea22SJiri Olsa static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) 84945aea22SJiri Olsa { 85945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 86945aea22SJiri Olsa 87945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 88945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 89945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 90945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 91ee4c7588SJiri Olsa /* 92ee4c7588SJiri Olsa * The period value gets configured within perf_evlist__config, 93ee4c7588SJiri Olsa * while this test executes only parse events method. 94ee4c7588SJiri Olsa */ 95945aea22SJiri Olsa TEST_ASSERT_VAL("wrong period", 96ee4c7588SJiri Olsa 0 == evsel->attr.sample_period); 97945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config1", 98945aea22SJiri Olsa 0 == evsel->attr.config1); 99945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config2", 100945aea22SJiri Olsa 1 == evsel->attr.config2); 101945aea22SJiri Olsa return 0; 102945aea22SJiri Olsa } 103945aea22SJiri Olsa 104945aea22SJiri Olsa static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) 105945aea22SJiri Olsa { 106945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 107945aea22SJiri Olsa 108945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 109945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); 110945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 111945aea22SJiri Olsa PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); 112945aea22SJiri Olsa return 0; 113945aea22SJiri Olsa } 114945aea22SJiri Olsa 115945aea22SJiri Olsa static int test__checkevent_genhw(struct perf_evlist *evlist) 116945aea22SJiri Olsa { 117945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 118945aea22SJiri Olsa 119945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 120945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); 121945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config); 122945aea22SJiri Olsa return 0; 123945aea22SJiri Olsa } 124945aea22SJiri Olsa 125945aea22SJiri Olsa static int test__checkevent_breakpoint(struct perf_evlist *evlist) 126945aea22SJiri Olsa { 127945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 128945aea22SJiri Olsa 129945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 130945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 131945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 132945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == 133945aea22SJiri Olsa evsel->attr.bp_type); 134945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == 135945aea22SJiri Olsa evsel->attr.bp_len); 136945aea22SJiri Olsa return 0; 137945aea22SJiri Olsa } 138945aea22SJiri Olsa 139945aea22SJiri Olsa static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) 140945aea22SJiri Olsa { 141945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 142945aea22SJiri Olsa 143945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 144945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 145945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 146945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 147945aea22SJiri Olsa HW_BREAKPOINT_X == evsel->attr.bp_type); 148945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len); 149945aea22SJiri Olsa return 0; 150945aea22SJiri Olsa } 151945aea22SJiri Olsa 152945aea22SJiri Olsa static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) 153945aea22SJiri Olsa { 154945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 155945aea22SJiri Olsa 156945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 157945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 158945aea22SJiri Olsa PERF_TYPE_BREAKPOINT == evsel->attr.type); 159945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 160945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 161945aea22SJiri Olsa HW_BREAKPOINT_R == evsel->attr.bp_type); 162945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", 163945aea22SJiri Olsa HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); 164945aea22SJiri Olsa return 0; 165945aea22SJiri Olsa } 166945aea22SJiri Olsa 167945aea22SJiri Olsa static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) 168945aea22SJiri Olsa { 169945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 170945aea22SJiri Olsa 171945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 172945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 173945aea22SJiri Olsa PERF_TYPE_BREAKPOINT == evsel->attr.type); 174945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 175945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 176945aea22SJiri Olsa HW_BREAKPOINT_W == evsel->attr.bp_type); 177945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", 178945aea22SJiri Olsa HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); 179945aea22SJiri Olsa return 0; 180945aea22SJiri Olsa } 181945aea22SJiri Olsa 182945aea22SJiri Olsa static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) 183945aea22SJiri Olsa { 184945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 185945aea22SJiri Olsa 186945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 187945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 188945aea22SJiri Olsa PERF_TYPE_BREAKPOINT == evsel->attr.type); 189945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 190945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 191945aea22SJiri Olsa (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type); 192945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", 193945aea22SJiri Olsa HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); 194945aea22SJiri Olsa return 0; 195945aea22SJiri Olsa } 196945aea22SJiri Olsa 197945aea22SJiri Olsa static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) 198945aea22SJiri Olsa { 199945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 200945aea22SJiri Olsa 201945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 202945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 203945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 204945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 205945aea22SJiri Olsa 206945aea22SJiri Olsa return test__checkevent_tracepoint(evlist); 207945aea22SJiri Olsa } 208945aea22SJiri Olsa 209945aea22SJiri Olsa static int 210945aea22SJiri Olsa test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) 211945aea22SJiri Olsa { 212945aea22SJiri Olsa struct perf_evsel *evsel; 213945aea22SJiri Olsa 214945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); 215945aea22SJiri Olsa 216e5cadb93SArnaldo Carvalho de Melo evlist__for_each_entry(evlist, evsel) { 217945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", 218945aea22SJiri Olsa !evsel->attr.exclude_user); 219945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", 220945aea22SJiri Olsa evsel->attr.exclude_kernel); 221945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 222945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 223945aea22SJiri Olsa } 224945aea22SJiri Olsa 225945aea22SJiri Olsa return test__checkevent_tracepoint_multi(evlist); 226945aea22SJiri Olsa } 227945aea22SJiri Olsa 228945aea22SJiri Olsa static int test__checkevent_raw_modifier(struct perf_evlist *evlist) 229945aea22SJiri Olsa { 230945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 231945aea22SJiri Olsa 232945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 233945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 234945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 235945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 236945aea22SJiri Olsa 237945aea22SJiri Olsa return test__checkevent_raw(evlist); 238945aea22SJiri Olsa } 239945aea22SJiri Olsa 240945aea22SJiri Olsa static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) 241945aea22SJiri Olsa { 242945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 243945aea22SJiri Olsa 244945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 245945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 246945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 247945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 248945aea22SJiri Olsa 249945aea22SJiri Olsa return test__checkevent_numeric(evlist); 250945aea22SJiri Olsa } 251945aea22SJiri Olsa 252945aea22SJiri Olsa static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) 253945aea22SJiri Olsa { 254945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 255945aea22SJiri Olsa 256945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 257945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 258945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 259945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 260945aea22SJiri Olsa 261945aea22SJiri Olsa return test__checkevent_symbolic_name(evlist); 262945aea22SJiri Olsa } 263945aea22SJiri Olsa 264945aea22SJiri Olsa static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) 265945aea22SJiri Olsa { 266945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 267945aea22SJiri Olsa 268945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 269945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 270945aea22SJiri Olsa 271945aea22SJiri Olsa return test__checkevent_symbolic_name(evlist); 272945aea22SJiri Olsa } 273945aea22SJiri Olsa 274945aea22SJiri Olsa static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) 275945aea22SJiri Olsa { 276945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 277945aea22SJiri Olsa 278945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 279945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 280945aea22SJiri Olsa 281945aea22SJiri Olsa return test__checkevent_symbolic_name(evlist); 282945aea22SJiri Olsa } 283945aea22SJiri Olsa 284945aea22SJiri Olsa static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) 285945aea22SJiri Olsa { 286945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 287945aea22SJiri Olsa 288945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 289945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 290945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 291945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 292945aea22SJiri Olsa 293945aea22SJiri Olsa return test__checkevent_symbolic_alias(evlist); 294945aea22SJiri Olsa } 295945aea22SJiri Olsa 296945aea22SJiri Olsa static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) 297945aea22SJiri Olsa { 298945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 299945aea22SJiri Olsa 300945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 301945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 302945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 303945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 304945aea22SJiri Olsa 305945aea22SJiri Olsa return test__checkevent_genhw(evlist); 306945aea22SJiri Olsa } 307945aea22SJiri Olsa 308a1e12da4SJiri Olsa static int test__checkevent_exclude_idle_modifier(struct perf_evlist *evlist) 309a1e12da4SJiri Olsa { 310a1e12da4SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 311a1e12da4SJiri Olsa 312a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); 313a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 314a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 315a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 316a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 317a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 318a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 319a1e12da4SJiri Olsa 320a1e12da4SJiri Olsa return test__checkevent_symbolic_name(evlist); 321a1e12da4SJiri Olsa } 322a1e12da4SJiri Olsa 323a1e12da4SJiri Olsa static int test__checkevent_exclude_idle_modifier_1(struct perf_evlist *evlist) 324a1e12da4SJiri Olsa { 325a1e12da4SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 326a1e12da4SJiri Olsa 327a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); 328a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 329a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 330a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 331a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 332a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 333a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 334a1e12da4SJiri Olsa 335a1e12da4SJiri Olsa return test__checkevent_symbolic_name(evlist); 336a1e12da4SJiri Olsa } 337a1e12da4SJiri Olsa 338945aea22SJiri Olsa static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) 339945aea22SJiri Olsa { 340945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 341945aea22SJiri Olsa 342945aea22SJiri Olsa 343945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 344945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 345945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 346945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 347945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 348945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:u")); 349945aea22SJiri Olsa 350945aea22SJiri Olsa return test__checkevent_breakpoint(evlist); 351945aea22SJiri Olsa } 352945aea22SJiri Olsa 353945aea22SJiri Olsa static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) 354945aea22SJiri Olsa { 355945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 356945aea22SJiri Olsa 357945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 358945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 359945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 360945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 361945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 362945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:x:k")); 363945aea22SJiri Olsa 364945aea22SJiri Olsa return test__checkevent_breakpoint_x(evlist); 365945aea22SJiri Olsa } 366945aea22SJiri Olsa 367945aea22SJiri Olsa static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) 368945aea22SJiri Olsa { 369945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 370945aea22SJiri Olsa 371945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 372945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 373945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 374945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 375945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 376945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:r:hp")); 377945aea22SJiri Olsa 378945aea22SJiri Olsa return test__checkevent_breakpoint_r(evlist); 379945aea22SJiri Olsa } 380945aea22SJiri Olsa 381945aea22SJiri Olsa static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) 382945aea22SJiri Olsa { 383945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 384945aea22SJiri Olsa 385945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 386945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 387945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 388945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 389945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 390945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:w:up")); 391945aea22SJiri Olsa 392945aea22SJiri Olsa return test__checkevent_breakpoint_w(evlist); 393945aea22SJiri Olsa } 394945aea22SJiri Olsa 395945aea22SJiri Olsa static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) 396945aea22SJiri Olsa { 397945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 398945aea22SJiri Olsa 399945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 400945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 401945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 402945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 403945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 404945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:rw:kp")); 405945aea22SJiri Olsa 406945aea22SJiri Olsa return test__checkevent_breakpoint_rw(evlist); 407945aea22SJiri Olsa } 408945aea22SJiri Olsa 409945aea22SJiri Olsa static int test__checkevent_pmu(struct perf_evlist *evlist) 410945aea22SJiri Olsa { 411945aea22SJiri Olsa 412945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 413945aea22SJiri Olsa 414945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 415945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 416945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); 417945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); 418945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); 419ee4c7588SJiri Olsa /* 420ee4c7588SJiri Olsa * The period value gets configured within perf_evlist__config, 421ee4c7588SJiri Olsa * while this test executes only parse events method. 422ee4c7588SJiri Olsa */ 423ee4c7588SJiri Olsa TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period); 424945aea22SJiri Olsa 425945aea22SJiri Olsa return 0; 426945aea22SJiri Olsa } 427945aea22SJiri Olsa 428945aea22SJiri Olsa static int test__checkevent_list(struct perf_evlist *evlist) 429945aea22SJiri Olsa { 430945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 431945aea22SJiri Olsa 432945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 433945aea22SJiri Olsa 434945aea22SJiri Olsa /* r1 */ 435945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 436945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 437945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); 438945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2); 439945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 440945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 441945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 442945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 443945aea22SJiri Olsa 44443f322b4SRiku Voipio /* syscalls:sys_enter_openat:k */ 445945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 446945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 447945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 448945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 449945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); 450945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 451945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 452945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 453945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 454945aea22SJiri Olsa 455945aea22SJiri Olsa /* 1:1:hp */ 456945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 457945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); 458945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 459945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 460945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 461945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 462945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 463945aea22SJiri Olsa 464945aea22SJiri Olsa return 0; 465945aea22SJiri Olsa } 466945aea22SJiri Olsa 467945aea22SJiri Olsa static int test__checkevent_pmu_name(struct perf_evlist *evlist) 468945aea22SJiri Olsa { 469945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 470945aea22SJiri Olsa 471945aea22SJiri Olsa /* cpu/config=1,name=krava/u */ 472945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 473945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 474945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 475945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); 476945aea22SJiri Olsa 477945aea22SJiri Olsa /* cpu/config=2/u" */ 478945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 479945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 480945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 481945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); 482945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 483945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "cpu/config=2/u")); 484945aea22SJiri Olsa 485945aea22SJiri Olsa return 0; 486945aea22SJiri Olsa } 487945aea22SJiri Olsa 48871ef150eSKan Liang static int test__checkevent_pmu_partial_time_callgraph(struct perf_evlist *evlist) 48971ef150eSKan Liang { 49071ef150eSKan Liang struct perf_evsel *evsel = perf_evlist__first(evlist); 49171ef150eSKan Liang 49271ef150eSKan Liang /* cpu/config=1,call-graph=fp,time,period=100000/ */ 49371ef150eSKan Liang TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 49471ef150eSKan Liang TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 49571ef150eSKan Liang TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 49671ef150eSKan Liang /* 49771ef150eSKan Liang * The period, time and callgraph value gets configured 49871ef150eSKan Liang * within perf_evlist__config, 49971ef150eSKan Liang * while this test executes only parse events method. 50071ef150eSKan Liang */ 50171ef150eSKan Liang TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period); 50227de9b2bSArnaldo Carvalho de Melo TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel)); 50371ef150eSKan Liang TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->attr.sample_type)); 50471ef150eSKan Liang 50571ef150eSKan Liang /* cpu/config=2,call-graph=no,time=0,period=2000/ */ 50671ef150eSKan Liang evsel = perf_evsel__next(evsel); 50771ef150eSKan Liang TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 50871ef150eSKan Liang TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); 50971ef150eSKan Liang /* 51071ef150eSKan Liang * The period, time and callgraph value gets configured 51171ef150eSKan Liang * within perf_evlist__config, 51271ef150eSKan Liang * while this test executes only parse events method. 51371ef150eSKan Liang */ 51471ef150eSKan Liang TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period); 51527de9b2bSArnaldo Carvalho de Melo TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel)); 51671ef150eSKan Liang TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->attr.sample_type)); 51771ef150eSKan Liang 51871ef150eSKan Liang return 0; 51971ef150eSKan Liang } 52071ef150eSKan Liang 521945aea22SJiri Olsa static int test__checkevent_pmu_events(struct perf_evlist *evlist) 522945aea22SJiri Olsa { 5239a354cdcSArnaldo Carvalho de Melo struct perf_evsel *evsel = perf_evlist__first(evlist); 524945aea22SJiri Olsa 525945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 526945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 527945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", 528945aea22SJiri Olsa !evsel->attr.exclude_user); 529945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", 530945aea22SJiri Olsa evsel->attr.exclude_kernel); 531945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 532945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 533c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 534945aea22SJiri Olsa 535945aea22SJiri Olsa return 0; 536945aea22SJiri Olsa } 537945aea22SJiri Olsa 538ffe59788SKan Liang 539ffe59788SKan Liang static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist) 540ffe59788SKan Liang { 541ffe59788SKan Liang struct perf_evsel *evsel = perf_evlist__first(evlist); 542ffe59788SKan Liang 543ffe59788SKan Liang /* pmu-event:u */ 544ffe59788SKan Liang TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 545ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_user", 546ffe59788SKan Liang !evsel->attr.exclude_user); 547ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_kernel", 548ffe59788SKan Liang evsel->attr.exclude_kernel); 549ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 550ffe59788SKan Liang TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 551ffe59788SKan Liang TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 552ffe59788SKan Liang 553ffe59788SKan Liang /* cpu/pmu-event/u*/ 554ffe59788SKan Liang evsel = perf_evsel__next(evsel); 555ffe59788SKan Liang TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 556ffe59788SKan Liang TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 557ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_user", 558ffe59788SKan Liang !evsel->attr.exclude_user); 559ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_kernel", 560ffe59788SKan Liang evsel->attr.exclude_kernel); 561ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 562ffe59788SKan Liang TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 563ffe59788SKan Liang TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 564ffe59788SKan Liang 565ffe59788SKan Liang return 0; 566ffe59788SKan Liang } 567ffe59788SKan Liang 568945aea22SJiri Olsa static int test__checkterms_simple(struct list_head *terms) 569945aea22SJiri Olsa { 5706cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 571945aea22SJiri Olsa 572945aea22SJiri Olsa /* config=10 */ 5736cee6cd3SArnaldo Carvalho de Melo term = list_entry(terms->next, struct parse_events_term, list); 574945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 575945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); 576945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 577945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 578945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 10); 579945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !term->config); 580945aea22SJiri Olsa 581945aea22SJiri Olsa /* config1 */ 5826cee6cd3SArnaldo Carvalho de Melo term = list_entry(term->list.next, struct parse_events_term, list); 583945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 584945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); 585945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 586945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 587945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 1); 588945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !term->config); 589945aea22SJiri Olsa 590945aea22SJiri Olsa /* config2=3 */ 5916cee6cd3SArnaldo Carvalho de Melo term = list_entry(term->list.next, struct parse_events_term, list); 592945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 593945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); 594945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 595945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 596945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 3); 597945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !term->config); 598945aea22SJiri Olsa 599945aea22SJiri Olsa /* umask=1*/ 6006cee6cd3SArnaldo Carvalho de Melo term = list_entry(term->list.next, struct parse_events_term, list); 601945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 602945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_USER); 603945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 604945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 605945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 1); 606945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); 607945aea22SJiri Olsa 608945aea22SJiri Olsa return 0; 609945aea22SJiri Olsa } 610945aea22SJiri Olsa 611945aea22SJiri Olsa static int test__group1(struct perf_evlist *evlist) 612945aea22SJiri Olsa { 613945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 614945aea22SJiri Olsa 615945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 6168d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 617945aea22SJiri Olsa 618945aea22SJiri Olsa /* instructions:k */ 619945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 620945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 621945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 622945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 623945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 624945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 625945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 626945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 627945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 628945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 629823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 6308d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 6318d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 632a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 633945aea22SJiri Olsa 634945aea22SJiri Olsa /* cycles:upp */ 635945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 636945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 637945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 638945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 639945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 640945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 641945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 642945aea22SJiri Olsa /* use of precise requires exclude_guest */ 643945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 644945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 645945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); 646945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 6478d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 648a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 649945aea22SJiri Olsa 650945aea22SJiri Olsa return 0; 651945aea22SJiri Olsa } 652945aea22SJiri Olsa 653945aea22SJiri Olsa static int test__group2(struct perf_evlist *evlist) 654945aea22SJiri Olsa { 655945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 656945aea22SJiri Olsa 657945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 6588d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 659945aea22SJiri Olsa 660945aea22SJiri Olsa /* faults + :ku modifier */ 661945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 662945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); 663945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 664945aea22SJiri Olsa PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); 665945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 666945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 667945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 668945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 669945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 670945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 671823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 6728d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 6738d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 674a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 675945aea22SJiri Olsa 676945aea22SJiri Olsa /* cache-references + :u modifier */ 677945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 678945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 679945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 680945aea22SJiri Olsa PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); 681945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 682945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 683945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 6845a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 685945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 686945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 687945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 6888d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 689a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 690945aea22SJiri Olsa 691945aea22SJiri Olsa /* cycles:k */ 692945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 693945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 694945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 695945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 696945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 697945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 698945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 699945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 700945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 701945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 702823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 703a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 704945aea22SJiri Olsa 705945aea22SJiri Olsa return 0; 706945aea22SJiri Olsa } 707945aea22SJiri Olsa 708945aea22SJiri Olsa static int test__group3(struct perf_evlist *evlist __maybe_unused) 709945aea22SJiri Olsa { 710945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 711945aea22SJiri Olsa 712945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); 7138d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); 714945aea22SJiri Olsa 71543f322b4SRiku Voipio /* group1 syscalls:sys_enter_openat:H */ 716945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 717945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 718945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 719945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 720945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); 721945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 722945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 723945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 724945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 725945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 726945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 727823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 728945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", 729945aea22SJiri Olsa !strcmp(leader->group_name, "group1")); 7308d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 7318d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 732a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 733945aea22SJiri Olsa 734945aea22SJiri Olsa /* group1 cycles:kppp */ 735945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 736945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 737945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 738945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 739945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 740945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 741945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 742945aea22SJiri Olsa /* use of precise requires exclude_guest */ 743945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 744945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 745945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); 746945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 747945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 7488d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 749a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 750945aea22SJiri Olsa 751945aea22SJiri Olsa /* group2 cycles + G modifier */ 752945aea22SJiri Olsa evsel = leader = perf_evsel__next(evsel); 753945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 754945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 755945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 756945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 757945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 758945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 759945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 760945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 761945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 762823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 763945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", 764945aea22SJiri Olsa !strcmp(leader->group_name, "group2")); 7658d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 7668d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 767a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 768945aea22SJiri Olsa 769945aea22SJiri Olsa /* group2 1:3 + G modifier */ 770945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 771945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); 772945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); 773945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 774945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 775945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 776945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 777945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 778945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 779945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 7808d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 781a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 782945aea22SJiri Olsa 783945aea22SJiri Olsa /* instructions:u */ 784945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 785945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 786945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 787945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 788945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 789945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 790945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 791945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 792945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 793945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 794823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 795a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 796945aea22SJiri Olsa 797945aea22SJiri Olsa return 0; 798945aea22SJiri Olsa } 799945aea22SJiri Olsa 800945aea22SJiri Olsa static int test__group4(struct perf_evlist *evlist __maybe_unused) 801945aea22SJiri Olsa { 802945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 803945aea22SJiri Olsa 804945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 8058d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 806945aea22SJiri Olsa 807945aea22SJiri Olsa /* cycles:u + p */ 808945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 809945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 810945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 811945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 812945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 813945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 814945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 815945aea22SJiri Olsa /* use of precise requires exclude_guest */ 816945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 817945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 818945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); 819945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 820823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 8218d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 8228d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 823a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 824945aea22SJiri Olsa 825945aea22SJiri Olsa /* instructions:kp + p */ 826945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 827945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 828945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 829945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 830945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 831945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 832945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 833945aea22SJiri Olsa /* use of precise requires exclude_guest */ 834945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 835945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 836945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); 837945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 8388d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 839a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 840945aea22SJiri Olsa 841945aea22SJiri Olsa return 0; 842945aea22SJiri Olsa } 843945aea22SJiri Olsa 844945aea22SJiri Olsa static int test__group5(struct perf_evlist *evlist __maybe_unused) 845945aea22SJiri Olsa { 846945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 847945aea22SJiri Olsa 848945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); 8498d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); 850945aea22SJiri Olsa 851945aea22SJiri Olsa /* cycles + G */ 852945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 853945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 854945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 855945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 856945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 857945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 858945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 859945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 860945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 861945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 862945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 863823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 8648d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 8658d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 866a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 867945aea22SJiri Olsa 868945aea22SJiri Olsa /* instructions + G */ 869945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 870945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 871945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 872945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 873945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 874945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 875945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 876945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 877945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 878945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 879945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 8808d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 881a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 882945aea22SJiri Olsa 883945aea22SJiri Olsa /* cycles:G */ 884945aea22SJiri Olsa evsel = leader = perf_evsel__next(evsel); 885945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 886945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 887945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 888945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 889945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 890945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 891945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 892945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 893945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 894945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 895823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 8968d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 8978d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 898a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 899945aea22SJiri Olsa 900945aea22SJiri Olsa /* instructions:G */ 901945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 902945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 903945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 904945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 905945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 906945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 907945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 908945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 909945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 910945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 911945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 9128d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 913945aea22SJiri Olsa 914945aea22SJiri Olsa /* cycles */ 915945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 916945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 917945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 918945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 919945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 920945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 921945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 922945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 923945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 924945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 925823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 926945aea22SJiri Olsa 927945aea22SJiri Olsa return 0; 928945aea22SJiri Olsa } 929945aea22SJiri Olsa 9305a30a99fSJiri Olsa static int test__group_gh1(struct perf_evlist *evlist) 9315a30a99fSJiri Olsa { 9325a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 9335a30a99fSJiri Olsa 9345a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 9355a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 9365a30a99fSJiri Olsa 9375a30a99fSJiri Olsa /* cycles + :H group modifier */ 9385a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 9395a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9405a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9415a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 9425a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9435a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 9445a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 9455a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 9465a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 9475a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9485a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 9495a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 9505a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 9515a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 9525a30a99fSJiri Olsa 9535a30a99fSJiri Olsa /* cache-misses:G + :H group modifier */ 9545a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 9555a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9565a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9575a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 9585a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9595a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 9605a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 9615a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 9625a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 9635a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9645a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 9655a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 9665a30a99fSJiri Olsa 9675a30a99fSJiri Olsa return 0; 9685a30a99fSJiri Olsa } 9695a30a99fSJiri Olsa 9705a30a99fSJiri Olsa static int test__group_gh2(struct perf_evlist *evlist) 9715a30a99fSJiri Olsa { 9725a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 9735a30a99fSJiri Olsa 9745a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 9755a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 9765a30a99fSJiri Olsa 9775a30a99fSJiri Olsa /* cycles + :G group modifier */ 9785a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 9795a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9805a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9815a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 9825a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9835a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 9845a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 9855a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 9865a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 9875a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9885a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 9895a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 9905a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 9915a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 9925a30a99fSJiri Olsa 9935a30a99fSJiri Olsa /* cache-misses:H + :G group modifier */ 9945a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 9955a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9965a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9975a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 9985a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9995a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 10005a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 10015a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 10025a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 10035a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10045a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 10055a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 10065a30a99fSJiri Olsa 10075a30a99fSJiri Olsa return 0; 10085a30a99fSJiri Olsa } 10095a30a99fSJiri Olsa 10105a30a99fSJiri Olsa static int test__group_gh3(struct perf_evlist *evlist) 10115a30a99fSJiri Olsa { 10125a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 10135a30a99fSJiri Olsa 10145a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 10155a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 10165a30a99fSJiri Olsa 10175a30a99fSJiri Olsa /* cycles:G + :u group modifier */ 10185a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 10195a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 10205a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 10215a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 10225a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 10235a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 10245a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 10255a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 10265a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 10275a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10285a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 10295a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 10305a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 10315a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 10325a30a99fSJiri Olsa 10335a30a99fSJiri Olsa /* cache-misses:H + :u group modifier */ 10345a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 10355a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 10365a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 10375a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 10385a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 10395a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 10405a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 10415a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 10425a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 10435a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10445a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 10455a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 10465a30a99fSJiri Olsa 10475a30a99fSJiri Olsa return 0; 10485a30a99fSJiri Olsa } 10495a30a99fSJiri Olsa 10505a30a99fSJiri Olsa static int test__group_gh4(struct perf_evlist *evlist) 10515a30a99fSJiri Olsa { 10525a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 10535a30a99fSJiri Olsa 10545a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 10555a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 10565a30a99fSJiri Olsa 10575a30a99fSJiri Olsa /* cycles:G + :uG group modifier */ 10585a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 10595a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 10605a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 10615a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 10625a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 10635a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 10645a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 10655a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 10665a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 10675a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10685a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 10695a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 10705a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 10715a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 10725a30a99fSJiri Olsa 10735a30a99fSJiri Olsa /* cache-misses:H + :uG group modifier */ 10745a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 10755a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 10765a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 10775a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 10785a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 10795a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 10805a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 10815a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 10825a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 10835a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10845a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 10855a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 10865a30a99fSJiri Olsa 10875a30a99fSJiri Olsa return 0; 10885a30a99fSJiri Olsa } 10895a30a99fSJiri Olsa 1090a9f93f97SJiri Olsa static int test__leader_sample1(struct perf_evlist *evlist) 1091a9f93f97SJiri Olsa { 1092a9f93f97SJiri Olsa struct perf_evsel *evsel, *leader; 1093a9f93f97SJiri Olsa 1094a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 1095a9f93f97SJiri Olsa 1096a9f93f97SJiri Olsa /* cycles - sampling group leader */ 1097a9f93f97SJiri Olsa evsel = leader = perf_evlist__first(evlist); 1098a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1099a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1100a9f93f97SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 1101a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1102a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 1103a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 1104a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1105a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1106a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1107a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1108a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1109a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1110a9f93f97SJiri Olsa 1111a9f93f97SJiri Olsa /* cache-misses - not sampling */ 1112a9f93f97SJiri Olsa evsel = perf_evsel__next(evsel); 1113a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1114a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1115a9f93f97SJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 1116a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1117a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 1118a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 1119a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1120a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1121a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1122a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1123a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1124a9f93f97SJiri Olsa 1125a9f93f97SJiri Olsa /* branch-misses - not sampling */ 1126a9f93f97SJiri Olsa evsel = perf_evsel__next(evsel); 1127a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1128a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1129a9f93f97SJiri Olsa PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1130a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1131a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 1132a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 1133a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1134a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1135a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1136a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1137a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1138a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1139a9f93f97SJiri Olsa 1140a9f93f97SJiri Olsa return 0; 1141a9f93f97SJiri Olsa } 1142a9f93f97SJiri Olsa 1143a9f93f97SJiri Olsa static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused) 1144a9f93f97SJiri Olsa { 1145a9f93f97SJiri Olsa struct perf_evsel *evsel, *leader; 1146a9f93f97SJiri Olsa 1147a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 1148a9f93f97SJiri Olsa 1149a9f93f97SJiri Olsa /* instructions - sampling group leader */ 1150a9f93f97SJiri Olsa evsel = leader = perf_evlist__first(evlist); 1151a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1152a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1153a9f93f97SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 1154a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1155a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1156a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1157a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1158a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1159a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1160a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1161a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1162a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1163a9f93f97SJiri Olsa 1164a9f93f97SJiri Olsa /* branch-misses - not sampling */ 1165a9f93f97SJiri Olsa evsel = perf_evsel__next(evsel); 1166a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1167a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1168a9f93f97SJiri Olsa PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1169a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1170a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1171a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1172a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1173a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1174a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1175a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1176a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1177a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1178a9f93f97SJiri Olsa 1179a9f93f97SJiri Olsa return 0; 1180a9f93f97SJiri Olsa } 1181a9f93f97SJiri Olsa 1182c9ee780fSMichael Ellerman static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) 1183c9ee780fSMichael Ellerman { 1184c9ee780fSMichael Ellerman struct perf_evsel *evsel = perf_evlist__first(evlist); 1185c9ee780fSMichael Ellerman 1186c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1187c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1188c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1189c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 1190c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); 1191c9ee780fSMichael Ellerman 1192c9ee780fSMichael Ellerman return test__checkevent_symbolic_name(evlist); 1193c9ee780fSMichael Ellerman } 1194c9ee780fSMichael Ellerman 1195c9ee780fSMichael Ellerman static int test__pinned_group(struct perf_evlist *evlist) 1196c9ee780fSMichael Ellerman { 1197c9ee780fSMichael Ellerman struct perf_evsel *evsel, *leader; 1198c9ee780fSMichael Ellerman 1199c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 1200c9ee780fSMichael Ellerman 1201c9ee780fSMichael Ellerman /* cycles - group leader */ 1202c9ee780fSMichael Ellerman evsel = leader = perf_evlist__first(evlist); 1203c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1204c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong config", 1205c9ee780fSMichael Ellerman PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 1206c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1207c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1208c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); 1209c9ee780fSMichael Ellerman 1210c9ee780fSMichael Ellerman /* cache-misses - can not be pinned, but will go on with the leader */ 1211c9ee780fSMichael Ellerman evsel = perf_evsel__next(evsel); 1212c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1213c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong config", 1214c9ee780fSMichael Ellerman PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 1215c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 1216c9ee780fSMichael Ellerman 1217c9ee780fSMichael Ellerman /* branch-misses - ditto */ 1218c9ee780fSMichael Ellerman evsel = perf_evsel__next(evsel); 1219c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong config", 1220c9ee780fSMichael Ellerman PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1221c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 1222c9ee780fSMichael Ellerman 1223c9ee780fSMichael Ellerman return 0; 1224c9ee780fSMichael Ellerman } 1225c9ee780fSMichael Ellerman 1226ec32398cSJacob Shin static int test__checkevent_breakpoint_len(struct perf_evlist *evlist) 1227ec32398cSJacob Shin { 1228ec32398cSJacob Shin struct perf_evsel *evsel = perf_evlist__first(evlist); 1229ec32398cSJacob Shin 1230ec32398cSJacob Shin TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 1231ec32398cSJacob Shin TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 1232ec32398cSJacob Shin TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 1233ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == 1234ec32398cSJacob Shin evsel->attr.bp_type); 1235ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 == 1236ec32398cSJacob Shin evsel->attr.bp_len); 1237ec32398cSJacob Shin 1238ec32398cSJacob Shin return 0; 1239ec32398cSJacob Shin } 1240ec32398cSJacob Shin 1241ec32398cSJacob Shin static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist) 1242ec32398cSJacob Shin { 1243ec32398cSJacob Shin struct perf_evsel *evsel = perf_evlist__first(evlist); 1244ec32398cSJacob Shin 1245ec32398cSJacob Shin TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 1246ec32398cSJacob Shin TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 1247ec32398cSJacob Shin TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 1248ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W == 1249ec32398cSJacob Shin evsel->attr.bp_type); 1250ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 == 1251ec32398cSJacob Shin evsel->attr.bp_len); 1252ec32398cSJacob Shin 1253ec32398cSJacob Shin return 0; 1254ec32398cSJacob Shin } 1255ec32398cSJacob Shin 1256ec32398cSJacob Shin static int 1257ec32398cSJacob Shin test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist) 1258ec32398cSJacob Shin { 1259ec32398cSJacob Shin struct perf_evsel *evsel = perf_evlist__first(evlist); 1260ec32398cSJacob Shin 1261ec32398cSJacob Shin TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1262ec32398cSJacob Shin TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1263ec32398cSJacob Shin TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1264ec32398cSJacob Shin TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1265ec32398cSJacob Shin 1266ec32398cSJacob Shin return test__checkevent_breakpoint_rw(evlist); 1267ec32398cSJacob Shin } 1268ec32398cSJacob Shin 1269ddd83c97SJiri Olsa static int test__checkevent_precise_max_modifier(struct perf_evlist *evlist) 1270ddd83c97SJiri Olsa { 1271ddd83c97SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 1272ddd83c97SJiri Olsa 1273ddd83c97SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 1274ddd83c97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); 1275ddd83c97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1276ddd83c97SJiri Olsa PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config); 1277ddd83c97SJiri Olsa return 0; 1278ddd83c97SJiri Olsa } 1279ddd83c97SJiri Olsa 128010bf358aSWang Nan static int test__checkevent_config_symbol(struct perf_evlist *evlist) 128110bf358aSWang Nan { 128210bf358aSWang Nan struct perf_evsel *evsel = perf_evlist__first(evlist); 128310bf358aSWang Nan 128410bf358aSWang Nan TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0); 128510bf358aSWang Nan return 0; 128610bf358aSWang Nan } 128710bf358aSWang Nan 128810bf358aSWang Nan static int test__checkevent_config_raw(struct perf_evlist *evlist) 128910bf358aSWang Nan { 129010bf358aSWang Nan struct perf_evsel *evsel = perf_evlist__first(evlist); 129110bf358aSWang Nan 129210bf358aSWang Nan TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0); 129310bf358aSWang Nan return 0; 129410bf358aSWang Nan } 129510bf358aSWang Nan 129610bf358aSWang Nan static int test__checkevent_config_num(struct perf_evlist *evlist) 129710bf358aSWang Nan { 129810bf358aSWang Nan struct perf_evsel *evsel = perf_evlist__first(evlist); 129910bf358aSWang Nan 130010bf358aSWang Nan TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0); 130110bf358aSWang Nan return 0; 130210bf358aSWang Nan } 130310bf358aSWang Nan 130443d0b978SWang Nan static int test__checkevent_config_cache(struct perf_evlist *evlist) 130543d0b978SWang Nan { 130643d0b978SWang Nan struct perf_evsel *evsel = perf_evlist__first(evlist); 130743d0b978SWang Nan 130843d0b978SWang Nan TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0); 130943d0b978SWang Nan return 0; 131043d0b978SWang Nan } 131110bf358aSWang Nan 1312*16ddcfbfSJiri Olsa static bool test__intel_pt_valid(void) 1313*16ddcfbfSJiri Olsa { 1314*16ddcfbfSJiri Olsa return !!perf_pmu__find("intel_pt"); 1315*16ddcfbfSJiri Olsa } 1316*16ddcfbfSJiri Olsa 1317b3f58c8dSArnaldo Carvalho de Melo static int test__intel_pt(struct perf_evlist *evlist) 1318b3f58c8dSArnaldo Carvalho de Melo { 1319b3f58c8dSArnaldo Carvalho de Melo struct perf_evsel *evsel = perf_evlist__first(evlist); 1320b3f58c8dSArnaldo Carvalho de Melo 1321b3f58c8dSArnaldo Carvalho de Melo TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0); 1322b3f58c8dSArnaldo Carvalho de Melo return 0; 1323b3f58c8dSArnaldo Carvalho de Melo } 1324b3f58c8dSArnaldo Carvalho de Melo 132582ce75d9SJiri Olsa static int count_tracepoints(void) 132682ce75d9SJiri Olsa { 132782ce75d9SJiri Olsa struct dirent *events_ent; 132882ce75d9SJiri Olsa DIR *events_dir; 132982ce75d9SJiri Olsa int cnt = 0; 133082ce75d9SJiri Olsa 13317014e0e3SArnaldo Carvalho de Melo events_dir = tracing_events__opendir(); 133282ce75d9SJiri Olsa 133382ce75d9SJiri Olsa TEST_ASSERT_VAL("Can't open events dir", events_dir); 133482ce75d9SJiri Olsa 133582ce75d9SJiri Olsa while ((events_ent = readdir(events_dir))) { 133625a7d914SArnaldo Carvalho de Melo char *sys_path; 133782ce75d9SJiri Olsa struct dirent *sys_ent; 133882ce75d9SJiri Olsa DIR *sys_dir; 133982ce75d9SJiri Olsa 134082ce75d9SJiri Olsa if (!strcmp(events_ent->d_name, ".") 134182ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "..") 134282ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "enable") 134382ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "header_event") 134482ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "header_page")) 134582ce75d9SJiri Olsa continue; 134682ce75d9SJiri Olsa 134725a7d914SArnaldo Carvalho de Melo sys_path = get_events_file(events_ent->d_name); 134825a7d914SArnaldo Carvalho de Melo TEST_ASSERT_VAL("Can't get sys path", sys_path); 134982ce75d9SJiri Olsa 135082ce75d9SJiri Olsa sys_dir = opendir(sys_path); 135182ce75d9SJiri Olsa TEST_ASSERT_VAL("Can't open sys dir", sys_dir); 135282ce75d9SJiri Olsa 135382ce75d9SJiri Olsa while ((sys_ent = readdir(sys_dir))) { 135482ce75d9SJiri Olsa if (!strcmp(sys_ent->d_name, ".") 135582ce75d9SJiri Olsa || !strcmp(sys_ent->d_name, "..") 135682ce75d9SJiri Olsa || !strcmp(sys_ent->d_name, "enable") 135782ce75d9SJiri Olsa || !strcmp(sys_ent->d_name, "filter")) 135882ce75d9SJiri Olsa continue; 135982ce75d9SJiri Olsa 136082ce75d9SJiri Olsa cnt++; 136182ce75d9SJiri Olsa } 136282ce75d9SJiri Olsa 136382ce75d9SJiri Olsa closedir(sys_dir); 136425a7d914SArnaldo Carvalho de Melo put_events_file(sys_path); 136582ce75d9SJiri Olsa } 136682ce75d9SJiri Olsa 136782ce75d9SJiri Olsa closedir(events_dir); 136882ce75d9SJiri Olsa return cnt; 136982ce75d9SJiri Olsa } 137082ce75d9SJiri Olsa 137182ce75d9SJiri Olsa static int test__all_tracepoints(struct perf_evlist *evlist) 137282ce75d9SJiri Olsa { 137382ce75d9SJiri Olsa TEST_ASSERT_VAL("wrong events count", 137482ce75d9SJiri Olsa count_tracepoints() == evlist->nr_entries); 137582ce75d9SJiri Olsa 137682ce75d9SJiri Olsa return test__checkevent_tracepoint_multi(evlist); 137782ce75d9SJiri Olsa } 137882ce75d9SJiri Olsa 137923b6339bSArnaldo Carvalho de Melo struct evlist_test { 1380945aea22SJiri Olsa const char *name; 1381945aea22SJiri Olsa __u32 type; 1382615b8f99SAlexander Yarygin const int id; 1383*16ddcfbfSJiri Olsa bool (*valid)(void); 1384945aea22SJiri Olsa int (*check)(struct perf_evlist *evlist); 1385945aea22SJiri Olsa }; 1386945aea22SJiri Olsa 138723b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events[] = { 1388615b8f99SAlexander Yarygin { 138943f322b4SRiku Voipio .name = "syscalls:sys_enter_openat", 1390945aea22SJiri Olsa .check = test__checkevent_tracepoint, 1391615b8f99SAlexander Yarygin .id = 0, 1392945aea22SJiri Olsa }, 1393615b8f99SAlexander Yarygin { 1394945aea22SJiri Olsa .name = "syscalls:*", 1395945aea22SJiri Olsa .check = test__checkevent_tracepoint_multi, 1396615b8f99SAlexander Yarygin .id = 1, 1397945aea22SJiri Olsa }, 1398615b8f99SAlexander Yarygin { 1399945aea22SJiri Olsa .name = "r1a", 1400945aea22SJiri Olsa .check = test__checkevent_raw, 1401615b8f99SAlexander Yarygin .id = 2, 1402945aea22SJiri Olsa }, 1403615b8f99SAlexander Yarygin { 1404945aea22SJiri Olsa .name = "1:1", 1405945aea22SJiri Olsa .check = test__checkevent_numeric, 1406615b8f99SAlexander Yarygin .id = 3, 1407945aea22SJiri Olsa }, 1408615b8f99SAlexander Yarygin { 1409945aea22SJiri Olsa .name = "instructions", 1410945aea22SJiri Olsa .check = test__checkevent_symbolic_name, 1411615b8f99SAlexander Yarygin .id = 4, 1412945aea22SJiri Olsa }, 1413615b8f99SAlexander Yarygin { 1414945aea22SJiri Olsa .name = "cycles/period=100000,config2/", 1415945aea22SJiri Olsa .check = test__checkevent_symbolic_name_config, 1416615b8f99SAlexander Yarygin .id = 5, 1417945aea22SJiri Olsa }, 1418615b8f99SAlexander Yarygin { 1419945aea22SJiri Olsa .name = "faults", 1420945aea22SJiri Olsa .check = test__checkevent_symbolic_alias, 1421615b8f99SAlexander Yarygin .id = 6, 1422945aea22SJiri Olsa }, 1423615b8f99SAlexander Yarygin { 1424945aea22SJiri Olsa .name = "L1-dcache-load-miss", 1425945aea22SJiri Olsa .check = test__checkevent_genhw, 1426615b8f99SAlexander Yarygin .id = 7, 1427945aea22SJiri Olsa }, 1428615b8f99SAlexander Yarygin { 1429945aea22SJiri Olsa .name = "mem:0", 1430945aea22SJiri Olsa .check = test__checkevent_breakpoint, 1431615b8f99SAlexander Yarygin .id = 8, 1432945aea22SJiri Olsa }, 1433615b8f99SAlexander Yarygin { 1434945aea22SJiri Olsa .name = "mem:0:x", 1435945aea22SJiri Olsa .check = test__checkevent_breakpoint_x, 1436615b8f99SAlexander Yarygin .id = 9, 1437945aea22SJiri Olsa }, 1438615b8f99SAlexander Yarygin { 1439945aea22SJiri Olsa .name = "mem:0:r", 1440945aea22SJiri Olsa .check = test__checkevent_breakpoint_r, 1441615b8f99SAlexander Yarygin .id = 10, 1442945aea22SJiri Olsa }, 1443615b8f99SAlexander Yarygin { 1444945aea22SJiri Olsa .name = "mem:0:w", 1445945aea22SJiri Olsa .check = test__checkevent_breakpoint_w, 1446615b8f99SAlexander Yarygin .id = 11, 1447945aea22SJiri Olsa }, 1448615b8f99SAlexander Yarygin { 144943f322b4SRiku Voipio .name = "syscalls:sys_enter_openat:k", 1450945aea22SJiri Olsa .check = test__checkevent_tracepoint_modifier, 1451615b8f99SAlexander Yarygin .id = 12, 1452945aea22SJiri Olsa }, 1453615b8f99SAlexander Yarygin { 1454945aea22SJiri Olsa .name = "syscalls:*:u", 1455945aea22SJiri Olsa .check = test__checkevent_tracepoint_multi_modifier, 1456615b8f99SAlexander Yarygin .id = 13, 1457945aea22SJiri Olsa }, 1458615b8f99SAlexander Yarygin { 1459945aea22SJiri Olsa .name = "r1a:kp", 1460945aea22SJiri Olsa .check = test__checkevent_raw_modifier, 1461615b8f99SAlexander Yarygin .id = 14, 1462945aea22SJiri Olsa }, 1463615b8f99SAlexander Yarygin { 1464945aea22SJiri Olsa .name = "1:1:hp", 1465945aea22SJiri Olsa .check = test__checkevent_numeric_modifier, 1466615b8f99SAlexander Yarygin .id = 15, 1467945aea22SJiri Olsa }, 1468615b8f99SAlexander Yarygin { 1469945aea22SJiri Olsa .name = "instructions:h", 1470945aea22SJiri Olsa .check = test__checkevent_symbolic_name_modifier, 1471615b8f99SAlexander Yarygin .id = 16, 1472945aea22SJiri Olsa }, 1473615b8f99SAlexander Yarygin { 1474945aea22SJiri Olsa .name = "faults:u", 1475945aea22SJiri Olsa .check = test__checkevent_symbolic_alias_modifier, 1476615b8f99SAlexander Yarygin .id = 17, 1477945aea22SJiri Olsa }, 1478615b8f99SAlexander Yarygin { 1479945aea22SJiri Olsa .name = "L1-dcache-load-miss:kp", 1480945aea22SJiri Olsa .check = test__checkevent_genhw_modifier, 1481615b8f99SAlexander Yarygin .id = 18, 1482945aea22SJiri Olsa }, 1483615b8f99SAlexander Yarygin { 1484945aea22SJiri Olsa .name = "mem:0:u", 1485945aea22SJiri Olsa .check = test__checkevent_breakpoint_modifier, 1486615b8f99SAlexander Yarygin .id = 19, 1487945aea22SJiri Olsa }, 1488615b8f99SAlexander Yarygin { 1489945aea22SJiri Olsa .name = "mem:0:x:k", 1490945aea22SJiri Olsa .check = test__checkevent_breakpoint_x_modifier, 1491615b8f99SAlexander Yarygin .id = 20, 1492945aea22SJiri Olsa }, 1493615b8f99SAlexander Yarygin { 1494945aea22SJiri Olsa .name = "mem:0:r:hp", 1495945aea22SJiri Olsa .check = test__checkevent_breakpoint_r_modifier, 1496615b8f99SAlexander Yarygin .id = 21, 1497945aea22SJiri Olsa }, 1498615b8f99SAlexander Yarygin { 1499945aea22SJiri Olsa .name = "mem:0:w:up", 1500945aea22SJiri Olsa .check = test__checkevent_breakpoint_w_modifier, 1501615b8f99SAlexander Yarygin .id = 22, 1502945aea22SJiri Olsa }, 1503615b8f99SAlexander Yarygin { 150443f322b4SRiku Voipio .name = "r1,syscalls:sys_enter_openat:k,1:1:hp", 1505945aea22SJiri Olsa .check = test__checkevent_list, 1506615b8f99SAlexander Yarygin .id = 23, 1507945aea22SJiri Olsa }, 1508615b8f99SAlexander Yarygin { 1509945aea22SJiri Olsa .name = "instructions:G", 1510945aea22SJiri Olsa .check = test__checkevent_exclude_host_modifier, 1511615b8f99SAlexander Yarygin .id = 24, 1512945aea22SJiri Olsa }, 1513615b8f99SAlexander Yarygin { 1514945aea22SJiri Olsa .name = "instructions:H", 1515945aea22SJiri Olsa .check = test__checkevent_exclude_guest_modifier, 1516615b8f99SAlexander Yarygin .id = 25, 1517945aea22SJiri Olsa }, 1518615b8f99SAlexander Yarygin { 1519945aea22SJiri Olsa .name = "mem:0:rw", 1520945aea22SJiri Olsa .check = test__checkevent_breakpoint_rw, 1521615b8f99SAlexander Yarygin .id = 26, 1522945aea22SJiri Olsa }, 1523615b8f99SAlexander Yarygin { 1524945aea22SJiri Olsa .name = "mem:0:rw:kp", 1525945aea22SJiri Olsa .check = test__checkevent_breakpoint_rw_modifier, 1526615b8f99SAlexander Yarygin .id = 27, 1527945aea22SJiri Olsa }, 1528615b8f99SAlexander Yarygin { 1529945aea22SJiri Olsa .name = "{instructions:k,cycles:upp}", 1530945aea22SJiri Olsa .check = test__group1, 1531615b8f99SAlexander Yarygin .id = 28, 1532945aea22SJiri Olsa }, 1533615b8f99SAlexander Yarygin { 1534945aea22SJiri Olsa .name = "{faults:k,cache-references}:u,cycles:k", 1535945aea22SJiri Olsa .check = test__group2, 1536615b8f99SAlexander Yarygin .id = 29, 1537945aea22SJiri Olsa }, 1538615b8f99SAlexander Yarygin { 153943f322b4SRiku Voipio .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", 1540945aea22SJiri Olsa .check = test__group3, 1541615b8f99SAlexander Yarygin .id = 30, 1542945aea22SJiri Olsa }, 1543615b8f99SAlexander Yarygin { 1544945aea22SJiri Olsa .name = "{cycles:u,instructions:kp}:p", 1545945aea22SJiri Olsa .check = test__group4, 1546615b8f99SAlexander Yarygin .id = 31, 1547945aea22SJiri Olsa }, 1548615b8f99SAlexander Yarygin { 1549945aea22SJiri Olsa .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", 1550945aea22SJiri Olsa .check = test__group5, 1551615b8f99SAlexander Yarygin .id = 32, 1552945aea22SJiri Olsa }, 1553615b8f99SAlexander Yarygin { 155482ce75d9SJiri Olsa .name = "*:*", 155582ce75d9SJiri Olsa .check = test__all_tracepoints, 1556615b8f99SAlexander Yarygin .id = 33, 155782ce75d9SJiri Olsa }, 1558615b8f99SAlexander Yarygin { 15595a30a99fSJiri Olsa .name = "{cycles,cache-misses:G}:H", 15605a30a99fSJiri Olsa .check = test__group_gh1, 1561615b8f99SAlexander Yarygin .id = 34, 15625a30a99fSJiri Olsa }, 1563615b8f99SAlexander Yarygin { 15645a30a99fSJiri Olsa .name = "{cycles,cache-misses:H}:G", 15655a30a99fSJiri Olsa .check = test__group_gh2, 1566615b8f99SAlexander Yarygin .id = 35, 15675a30a99fSJiri Olsa }, 1568615b8f99SAlexander Yarygin { 15695a30a99fSJiri Olsa .name = "{cycles:G,cache-misses:H}:u", 15705a30a99fSJiri Olsa .check = test__group_gh3, 1571615b8f99SAlexander Yarygin .id = 36, 15725a30a99fSJiri Olsa }, 1573615b8f99SAlexander Yarygin { 15745a30a99fSJiri Olsa .name = "{cycles:G,cache-misses:H}:uG", 15755a30a99fSJiri Olsa .check = test__group_gh4, 1576615b8f99SAlexander Yarygin .id = 37, 15775a30a99fSJiri Olsa }, 1578615b8f99SAlexander Yarygin { 1579a9f93f97SJiri Olsa .name = "{cycles,cache-misses,branch-misses}:S", 1580a9f93f97SJiri Olsa .check = test__leader_sample1, 1581615b8f99SAlexander Yarygin .id = 38, 1582a9f93f97SJiri Olsa }, 1583615b8f99SAlexander Yarygin { 1584a9f93f97SJiri Olsa .name = "{instructions,branch-misses}:Su", 1585a9f93f97SJiri Olsa .check = test__leader_sample2, 1586615b8f99SAlexander Yarygin .id = 39, 1587a9f93f97SJiri Olsa }, 1588615b8f99SAlexander Yarygin { 1589c9ee780fSMichael Ellerman .name = "instructions:uDp", 1590c9ee780fSMichael Ellerman .check = test__checkevent_pinned_modifier, 1591615b8f99SAlexander Yarygin .id = 40, 1592c9ee780fSMichael Ellerman }, 1593615b8f99SAlexander Yarygin { 1594c9ee780fSMichael Ellerman .name = "{cycles,cache-misses,branch-misses}:D", 1595c9ee780fSMichael Ellerman .check = test__pinned_group, 1596615b8f99SAlexander Yarygin .id = 41, 1597c9ee780fSMichael Ellerman }, 1598ec32398cSJacob Shin { 1599ec32398cSJacob Shin .name = "mem:0/1", 1600ec32398cSJacob Shin .check = test__checkevent_breakpoint_len, 1601ec32398cSJacob Shin .id = 42, 1602ec32398cSJacob Shin }, 1603ec32398cSJacob Shin { 1604ec32398cSJacob Shin .name = "mem:0/2:w", 1605ec32398cSJacob Shin .check = test__checkevent_breakpoint_len_w, 1606ec32398cSJacob Shin .id = 43, 1607ec32398cSJacob Shin }, 1608ec32398cSJacob Shin { 1609ec32398cSJacob Shin .name = "mem:0/4:rw:u", 1610ec32398cSJacob Shin .check = test__checkevent_breakpoint_len_rw_modifier, 1611ec32398cSJacob Shin .id = 44 1612ec32398cSJacob Shin }, 1613c0bc8c6dSAlexander Yarygin #if defined(__s390x__) 1614c0bc8c6dSAlexander Yarygin { 1615c0bc8c6dSAlexander Yarygin .name = "kvm-s390:kvm_s390_create_vm", 1616c0bc8c6dSAlexander Yarygin .check = test__checkevent_tracepoint, 1617c0bc8c6dSAlexander Yarygin .id = 100, 1618c0bc8c6dSAlexander Yarygin }, 1619c0bc8c6dSAlexander Yarygin #endif 1620a1e12da4SJiri Olsa { 1621a1e12da4SJiri Olsa .name = "instructions:I", 1622a1e12da4SJiri Olsa .check = test__checkevent_exclude_idle_modifier, 1623a1e12da4SJiri Olsa .id = 45, 1624a1e12da4SJiri Olsa }, 1625a1e12da4SJiri Olsa { 1626a1e12da4SJiri Olsa .name = "instructions:kIG", 1627a1e12da4SJiri Olsa .check = test__checkevent_exclude_idle_modifier_1, 1628a1e12da4SJiri Olsa .id = 46, 1629a1e12da4SJiri Olsa }, 1630ddd83c97SJiri Olsa { 1631ddd83c97SJiri Olsa .name = "task-clock:P,cycles", 1632ddd83c97SJiri Olsa .check = test__checkevent_precise_max_modifier, 1633ddd83c97SJiri Olsa .id = 47, 1634ddd83c97SJiri Olsa }, 163510bf358aSWang Nan { 163610bf358aSWang Nan .name = "instructions/name=insn/", 163710bf358aSWang Nan .check = test__checkevent_config_symbol, 163810bf358aSWang Nan .id = 48, 163910bf358aSWang Nan }, 164010bf358aSWang Nan { 164110bf358aSWang Nan .name = "r1234/name=rawpmu/", 164210bf358aSWang Nan .check = test__checkevent_config_raw, 164310bf358aSWang Nan .id = 49, 164410bf358aSWang Nan }, 164510bf358aSWang Nan { 164610bf358aSWang Nan .name = "4:0x6530160/name=numpmu/", 164710bf358aSWang Nan .check = test__checkevent_config_num, 164810bf358aSWang Nan .id = 50, 164910bf358aSWang Nan }, 165043d0b978SWang Nan { 165143d0b978SWang Nan .name = "L1-dcache-misses/name=cachepmu/", 165243d0b978SWang Nan .check = test__checkevent_config_cache, 165343d0b978SWang Nan .id = 51, 165443d0b978SWang Nan }, 1655b3f58c8dSArnaldo Carvalho de Melo { 1656b3f58c8dSArnaldo Carvalho de Melo .name = "intel_pt//u", 1657*16ddcfbfSJiri Olsa .valid = test__intel_pt_valid, 1658b3f58c8dSArnaldo Carvalho de Melo .check = test__intel_pt, 1659b3f58c8dSArnaldo Carvalho de Melo .id = 52, 1660b3f58c8dSArnaldo Carvalho de Melo }, 1661945aea22SJiri Olsa }; 1662945aea22SJiri Olsa 166323b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events_pmu[] = { 1664615b8f99SAlexander Yarygin { 1665945aea22SJiri Olsa .name = "cpu/config=10,config1,config2=3,period=1000/u", 1666945aea22SJiri Olsa .check = test__checkevent_pmu, 1667615b8f99SAlexander Yarygin .id = 0, 1668945aea22SJiri Olsa }, 1669615b8f99SAlexander Yarygin { 1670945aea22SJiri Olsa .name = "cpu/config=1,name=krava/u,cpu/config=2/u", 1671945aea22SJiri Olsa .check = test__checkevent_pmu_name, 1672615b8f99SAlexander Yarygin .id = 1, 1673945aea22SJiri Olsa }, 167471ef150eSKan Liang { 167571ef150eSKan Liang .name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/", 167671ef150eSKan Liang .check = test__checkevent_pmu_partial_time_callgraph, 167771ef150eSKan Liang .id = 2, 167871ef150eSKan Liang }, 1679945aea22SJiri Olsa }; 1680945aea22SJiri Olsa 168123b6339bSArnaldo Carvalho de Melo struct terms_test { 1682945aea22SJiri Olsa const char *str; 1683945aea22SJiri Olsa __u32 type; 1684945aea22SJiri Olsa int (*check)(struct list_head *terms); 1685945aea22SJiri Olsa }; 1686945aea22SJiri Olsa 168723b6339bSArnaldo Carvalho de Melo static struct terms_test test__terms[] = { 1688945aea22SJiri Olsa [0] = { 1689945aea22SJiri Olsa .str = "config=10,config1,config2=3,umask=1", 1690945aea22SJiri Olsa .check = test__checkterms_simple, 1691945aea22SJiri Olsa }, 1692945aea22SJiri Olsa }; 1693945aea22SJiri Olsa 169423b6339bSArnaldo Carvalho de Melo static int test_event(struct evlist_test *e) 1695945aea22SJiri Olsa { 1696933ccf20SJiri Olsa struct parse_events_error err = { .idx = 0, }; 1697945aea22SJiri Olsa struct perf_evlist *evlist; 1698945aea22SJiri Olsa int ret; 1699945aea22SJiri Olsa 1700*16ddcfbfSJiri Olsa if (e->valid && !e->valid()) { 1701*16ddcfbfSJiri Olsa pr_debug("... SKIP"); 1702*16ddcfbfSJiri Olsa return 0; 1703*16ddcfbfSJiri Olsa } 1704*16ddcfbfSJiri Olsa 1705334fe7a3SNamhyung Kim evlist = perf_evlist__new(); 1706945aea22SJiri Olsa if (evlist == NULL) 1707945aea22SJiri Olsa return -ENOMEM; 1708945aea22SJiri Olsa 1709933ccf20SJiri Olsa ret = parse_events(evlist, e->name, &err); 1710945aea22SJiri Olsa if (ret) { 1711933ccf20SJiri Olsa pr_debug("failed to parse event '%s', err %d, str '%s'\n", 1712933ccf20SJiri Olsa e->name, ret, err.str); 1713933ccf20SJiri Olsa parse_events_print_error(&err, e->name); 17142d4352c0SArnaldo Carvalho de Melo } else { 17152d4352c0SArnaldo Carvalho de Melo ret = e->check(evlist); 1716945aea22SJiri Olsa } 1717945aea22SJiri Olsa 1718945aea22SJiri Olsa perf_evlist__delete(evlist); 1719945aea22SJiri Olsa 1720945aea22SJiri Olsa return ret; 1721945aea22SJiri Olsa } 1722945aea22SJiri Olsa 172323b6339bSArnaldo Carvalho de Melo static int test_events(struct evlist_test *events, unsigned cnt) 1724945aea22SJiri Olsa { 1725945aea22SJiri Olsa int ret1, ret2 = 0; 1726945aea22SJiri Olsa unsigned i; 1727945aea22SJiri Olsa 1728945aea22SJiri Olsa for (i = 0; i < cnt; i++) { 172923b6339bSArnaldo Carvalho de Melo struct evlist_test *e = &events[i]; 1730945aea22SJiri Olsa 1731*16ddcfbfSJiri Olsa pr_debug("running test %d '%s'", e->id, e->name); 1732945aea22SJiri Olsa ret1 = test_event(e); 1733945aea22SJiri Olsa if (ret1) 1734945aea22SJiri Olsa ret2 = ret1; 1735*16ddcfbfSJiri Olsa pr_debug("\n"); 1736945aea22SJiri Olsa } 1737945aea22SJiri Olsa 1738945aea22SJiri Olsa return ret2; 1739945aea22SJiri Olsa } 1740945aea22SJiri Olsa 174123b6339bSArnaldo Carvalho de Melo static int test_term(struct terms_test *t) 1742945aea22SJiri Olsa { 1743c549aca5SDavid Ahern struct list_head terms; 1744945aea22SJiri Olsa int ret; 1745945aea22SJiri Olsa 1746c549aca5SDavid Ahern INIT_LIST_HEAD(&terms); 1747945aea22SJiri Olsa 1748c549aca5SDavid Ahern ret = parse_events_terms(&terms, t->str); 1749945aea22SJiri Olsa if (ret) { 1750945aea22SJiri Olsa pr_debug("failed to parse terms '%s', err %d\n", 1751945aea22SJiri Olsa t->str , ret); 1752945aea22SJiri Olsa return ret; 1753945aea22SJiri Olsa } 1754945aea22SJiri Olsa 1755c549aca5SDavid Ahern ret = t->check(&terms); 1756682dc24cSArnaldo Carvalho de Melo parse_events_terms__purge(&terms); 1757945aea22SJiri Olsa 1758945aea22SJiri Olsa return ret; 1759945aea22SJiri Olsa } 1760945aea22SJiri Olsa 176123b6339bSArnaldo Carvalho de Melo static int test_terms(struct terms_test *terms, unsigned cnt) 1762945aea22SJiri Olsa { 1763945aea22SJiri Olsa int ret = 0; 1764945aea22SJiri Olsa unsigned i; 1765945aea22SJiri Olsa 1766945aea22SJiri Olsa for (i = 0; i < cnt; i++) { 176723b6339bSArnaldo Carvalho de Melo struct terms_test *t = &terms[i]; 1768945aea22SJiri Olsa 1769945aea22SJiri Olsa pr_debug("running test %d '%s'\n", i, t->str); 1770945aea22SJiri Olsa ret = test_term(t); 1771945aea22SJiri Olsa if (ret) 1772945aea22SJiri Olsa break; 1773945aea22SJiri Olsa } 1774945aea22SJiri Olsa 1775945aea22SJiri Olsa return ret; 1776945aea22SJiri Olsa } 1777945aea22SJiri Olsa 1778945aea22SJiri Olsa static int test_pmu(void) 1779945aea22SJiri Olsa { 1780945aea22SJiri Olsa struct stat st; 1781945aea22SJiri Olsa char path[PATH_MAX]; 1782945aea22SJiri Olsa int ret; 1783945aea22SJiri Olsa 1784945aea22SJiri Olsa snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", 1785cf38fadaSArnaldo Carvalho de Melo sysfs__mountpoint()); 1786945aea22SJiri Olsa 1787945aea22SJiri Olsa ret = stat(path, &st); 1788945aea22SJiri Olsa if (ret) 1789945aea22SJiri Olsa pr_debug("omitting PMU cpu tests\n"); 1790945aea22SJiri Olsa return !ret; 1791945aea22SJiri Olsa } 1792945aea22SJiri Olsa 1793945aea22SJiri Olsa static int test_pmu_events(void) 1794945aea22SJiri Olsa { 1795945aea22SJiri Olsa struct stat st; 1796945aea22SJiri Olsa char path[PATH_MAX]; 1797945aea22SJiri Olsa struct dirent *ent; 1798945aea22SJiri Olsa DIR *dir; 1799945aea22SJiri Olsa int ret; 1800945aea22SJiri Olsa 1801945aea22SJiri Olsa snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", 1802cf38fadaSArnaldo Carvalho de Melo sysfs__mountpoint()); 1803945aea22SJiri Olsa 1804945aea22SJiri Olsa ret = stat(path, &st); 1805945aea22SJiri Olsa if (ret) { 1806a895d57dSMasanari Iida pr_debug("omitting PMU cpu events tests\n"); 1807945aea22SJiri Olsa return 0; 1808945aea22SJiri Olsa } 1809945aea22SJiri Olsa 1810945aea22SJiri Olsa dir = opendir(path); 1811945aea22SJiri Olsa if (!dir) { 1812945aea22SJiri Olsa pr_debug("can't open pmu event dir"); 1813945aea22SJiri Olsa return -1; 1814945aea22SJiri Olsa } 1815945aea22SJiri Olsa 1816945aea22SJiri Olsa while (!ret && (ent = readdir(dir))) { 1817*16ddcfbfSJiri Olsa struct evlist_test e = { .id = 0, }; 18182e2bbc03SArnaldo Carvalho de Melo char name[2 * NAME_MAX + 1 + 12 + 3]; 1819945aea22SJiri Olsa 182017a2634bSAndi Kleen /* Names containing . are special and cannot be used directly */ 182117a2634bSAndi Kleen if (strchr(ent->d_name, '.')) 1822945aea22SJiri Olsa continue; 1823945aea22SJiri Olsa 18242e2bbc03SArnaldo Carvalho de Melo snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name); 1825945aea22SJiri Olsa 1826945aea22SJiri Olsa e.name = name; 1827945aea22SJiri Olsa e.check = test__checkevent_pmu_events; 1828945aea22SJiri Olsa 1829945aea22SJiri Olsa ret = test_event(&e); 1830ffe59788SKan Liang if (ret) 1831ffe59788SKan Liang break; 18322e2bbc03SArnaldo Carvalho de Melo snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name); 1833ffe59788SKan Liang e.name = name; 1834ffe59788SKan Liang e.check = test__checkevent_pmu_events_mix; 1835ffe59788SKan Liang ret = test_event(&e); 1836945aea22SJiri Olsa } 1837945aea22SJiri Olsa 1838945aea22SJiri Olsa closedir(dir); 1839945aea22SJiri Olsa return ret; 1840945aea22SJiri Olsa } 1841945aea22SJiri Olsa 184281f17c90SArnaldo Carvalho de Melo int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused) 1843945aea22SJiri Olsa { 1844945aea22SJiri Olsa int ret1, ret2 = 0; 1845945aea22SJiri Olsa 1846945aea22SJiri Olsa #define TEST_EVENTS(tests) \ 1847945aea22SJiri Olsa do { \ 1848945aea22SJiri Olsa ret1 = test_events(tests, ARRAY_SIZE(tests)); \ 1849945aea22SJiri Olsa if (!ret2) \ 1850945aea22SJiri Olsa ret2 = ret1; \ 1851945aea22SJiri Olsa } while (0) 1852945aea22SJiri Olsa 1853945aea22SJiri Olsa TEST_EVENTS(test__events); 1854945aea22SJiri Olsa 1855945aea22SJiri Olsa if (test_pmu()) 1856945aea22SJiri Olsa TEST_EVENTS(test__events_pmu); 1857945aea22SJiri Olsa 1858945aea22SJiri Olsa if (test_pmu()) { 1859945aea22SJiri Olsa int ret = test_pmu_events(); 1860945aea22SJiri Olsa if (ret) 1861945aea22SJiri Olsa return ret; 1862945aea22SJiri Olsa } 1863945aea22SJiri Olsa 1864945aea22SJiri Olsa ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); 1865945aea22SJiri Olsa if (!ret2) 1866945aea22SJiri Olsa ret2 = ret1; 1867945aea22SJiri Olsa 1868945aea22SJiri Olsa return ret2; 1869945aea22SJiri Olsa } 1870