1945aea22SJiri Olsa 2945aea22SJiri Olsa #include "parse-events.h" 3945aea22SJiri Olsa #include "evsel.h" 4945aea22SJiri Olsa #include "evlist.h" 5cd0cfad7SBorislav Petkov #include <api/fs/fs.h> 623773ca1SSteven Rostedt (Red Hat) #include <api/fs/tracefs.h> 7553873e1SBorislav Petkov #include <api/fs/debugfs.h> 8c81251e8SJiri Olsa #include "tests.h" 984f5d36fSJiri Olsa #include "debug.h" 10f0b9abfbSIngo Molnar #include <linux/hw_breakpoint.h> 11945aea22SJiri Olsa 12945aea22SJiri Olsa #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ 13945aea22SJiri Olsa PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) 14945aea22SJiri Olsa 15945aea22SJiri Olsa static int test__checkevent_tracepoint(struct perf_evlist *evlist) 16945aea22SJiri Olsa { 17945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 18945aea22SJiri Olsa 19945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 208d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); 21945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 22945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 23945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 24945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); 25945aea22SJiri Olsa return 0; 26945aea22SJiri Olsa } 27945aea22SJiri Olsa 28945aea22SJiri Olsa static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) 29945aea22SJiri Olsa { 30945aea22SJiri Olsa struct perf_evsel *evsel; 31945aea22SJiri Olsa 32945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); 338d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); 34945aea22SJiri Olsa 350050f7aaSArnaldo Carvalho de Melo evlist__for_each(evlist, evsel) { 36945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 37945aea22SJiri Olsa PERF_TYPE_TRACEPOINT == evsel->attr.type); 38945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 39945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 40945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 41945aea22SJiri Olsa 1 == evsel->attr.sample_period); 42945aea22SJiri Olsa } 43945aea22SJiri Olsa return 0; 44945aea22SJiri Olsa } 45945aea22SJiri Olsa 46945aea22SJiri Olsa static int test__checkevent_raw(struct perf_evlist *evlist) 47945aea22SJiri Olsa { 48945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 49945aea22SJiri Olsa 50945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 51945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 52945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config); 53945aea22SJiri Olsa return 0; 54945aea22SJiri Olsa } 55945aea22SJiri Olsa 56945aea22SJiri Olsa static int test__checkevent_numeric(struct perf_evlist *evlist) 57945aea22SJiri Olsa { 58945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 59945aea22SJiri Olsa 60945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 61945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); 62945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 63945aea22SJiri Olsa return 0; 64945aea22SJiri Olsa } 65945aea22SJiri Olsa 66945aea22SJiri Olsa static int test__checkevent_symbolic_name(struct perf_evlist *evlist) 67945aea22SJiri Olsa { 68945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 69945aea22SJiri Olsa 70945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 71945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 72945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 73945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 74945aea22SJiri Olsa return 0; 75945aea22SJiri Olsa } 76945aea22SJiri Olsa 77945aea22SJiri Olsa static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) 78945aea22SJiri Olsa { 79945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 80945aea22SJiri Olsa 81945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 82945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 83945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 84945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 85945aea22SJiri Olsa TEST_ASSERT_VAL("wrong period", 86945aea22SJiri Olsa 100000 == evsel->attr.sample_period); 87945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config1", 88945aea22SJiri Olsa 0 == evsel->attr.config1); 89945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config2", 90945aea22SJiri Olsa 1 == evsel->attr.config2); 91945aea22SJiri Olsa return 0; 92945aea22SJiri Olsa } 93945aea22SJiri Olsa 94945aea22SJiri Olsa static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) 95945aea22SJiri Olsa { 96945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 97945aea22SJiri Olsa 98945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 99945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); 100945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 101945aea22SJiri Olsa PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); 102945aea22SJiri Olsa return 0; 103945aea22SJiri Olsa } 104945aea22SJiri Olsa 105945aea22SJiri Olsa static int test__checkevent_genhw(struct perf_evlist *evlist) 106945aea22SJiri Olsa { 107945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 108945aea22SJiri Olsa 109945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 110945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); 111945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config); 112945aea22SJiri Olsa return 0; 113945aea22SJiri Olsa } 114945aea22SJiri Olsa 115945aea22SJiri Olsa static int test__checkevent_breakpoint(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_BREAKPOINT == evsel->attr.type); 121945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 122945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == 123945aea22SJiri Olsa evsel->attr.bp_type); 124945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == 125945aea22SJiri Olsa evsel->attr.bp_len); 126945aea22SJiri Olsa return 0; 127945aea22SJiri Olsa } 128945aea22SJiri Olsa 129945aea22SJiri Olsa static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) 130945aea22SJiri Olsa { 131945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 132945aea22SJiri Olsa 133945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 134945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 135945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 136945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 137945aea22SJiri Olsa HW_BREAKPOINT_X == evsel->attr.bp_type); 138945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len); 139945aea22SJiri Olsa return 0; 140945aea22SJiri Olsa } 141945aea22SJiri Olsa 142945aea22SJiri Olsa static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) 143945aea22SJiri Olsa { 144945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 145945aea22SJiri Olsa 146945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 147945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 148945aea22SJiri Olsa PERF_TYPE_BREAKPOINT == evsel->attr.type); 149945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 150945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 151945aea22SJiri Olsa HW_BREAKPOINT_R == evsel->attr.bp_type); 152945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", 153945aea22SJiri Olsa HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); 154945aea22SJiri Olsa return 0; 155945aea22SJiri Olsa } 156945aea22SJiri Olsa 157945aea22SJiri Olsa static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) 158945aea22SJiri Olsa { 159945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 160945aea22SJiri Olsa 161945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 162945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 163945aea22SJiri Olsa PERF_TYPE_BREAKPOINT == evsel->attr.type); 164945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 165945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 166945aea22SJiri Olsa HW_BREAKPOINT_W == evsel->attr.bp_type); 167945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", 168945aea22SJiri Olsa HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); 169945aea22SJiri Olsa return 0; 170945aea22SJiri Olsa } 171945aea22SJiri Olsa 172945aea22SJiri Olsa static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) 173945aea22SJiri Olsa { 174945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 175945aea22SJiri Olsa 176945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 177945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 178945aea22SJiri Olsa PERF_TYPE_BREAKPOINT == evsel->attr.type); 179945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 180945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_type", 181945aea22SJiri Olsa (HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type); 182945aea22SJiri Olsa TEST_ASSERT_VAL("wrong bp_len", 183945aea22SJiri Olsa HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); 184945aea22SJiri Olsa return 0; 185945aea22SJiri Olsa } 186945aea22SJiri Olsa 187945aea22SJiri Olsa static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) 188945aea22SJiri Olsa { 189945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 190945aea22SJiri Olsa 191945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 192945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 193945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 194945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 195945aea22SJiri Olsa 196945aea22SJiri Olsa return test__checkevent_tracepoint(evlist); 197945aea22SJiri Olsa } 198945aea22SJiri Olsa 199945aea22SJiri Olsa static int 200945aea22SJiri Olsa test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) 201945aea22SJiri Olsa { 202945aea22SJiri Olsa struct perf_evsel *evsel; 203945aea22SJiri Olsa 204945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); 205945aea22SJiri Olsa 2060050f7aaSArnaldo Carvalho de Melo evlist__for_each(evlist, evsel) { 207945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", 208945aea22SJiri Olsa !evsel->attr.exclude_user); 209945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", 210945aea22SJiri Olsa evsel->attr.exclude_kernel); 211945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 212945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 213945aea22SJiri Olsa } 214945aea22SJiri Olsa 215945aea22SJiri Olsa return test__checkevent_tracepoint_multi(evlist); 216945aea22SJiri Olsa } 217945aea22SJiri Olsa 218945aea22SJiri Olsa static int test__checkevent_raw_modifier(struct perf_evlist *evlist) 219945aea22SJiri Olsa { 220945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 221945aea22SJiri Olsa 222945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 223945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 224945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 225945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 226945aea22SJiri Olsa 227945aea22SJiri Olsa return test__checkevent_raw(evlist); 228945aea22SJiri Olsa } 229945aea22SJiri Olsa 230945aea22SJiri Olsa static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) 231945aea22SJiri Olsa { 232945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 233945aea22SJiri Olsa 234945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 235945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 236945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 237945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 238945aea22SJiri Olsa 239945aea22SJiri Olsa return test__checkevent_numeric(evlist); 240945aea22SJiri Olsa } 241945aea22SJiri Olsa 242945aea22SJiri Olsa static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) 243945aea22SJiri Olsa { 244945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 245945aea22SJiri Olsa 246945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 247945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 248945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 249945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 250945aea22SJiri Olsa 251945aea22SJiri Olsa return test__checkevent_symbolic_name(evlist); 252945aea22SJiri Olsa } 253945aea22SJiri Olsa 254945aea22SJiri Olsa static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) 255945aea22SJiri Olsa { 256945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 257945aea22SJiri Olsa 258945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 259945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 260945aea22SJiri Olsa 261945aea22SJiri Olsa return test__checkevent_symbolic_name(evlist); 262945aea22SJiri Olsa } 263945aea22SJiri Olsa 264945aea22SJiri Olsa static int test__checkevent_exclude_guest_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_symbolic_alias_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_user", !evsel->attr.exclude_user); 279945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 280945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 281945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 282945aea22SJiri Olsa 283945aea22SJiri Olsa return test__checkevent_symbolic_alias(evlist); 284945aea22SJiri Olsa } 285945aea22SJiri Olsa 286945aea22SJiri Olsa static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) 287945aea22SJiri Olsa { 288945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 289945aea22SJiri Olsa 290945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 291945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 292945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 293945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 294945aea22SJiri Olsa 295945aea22SJiri Olsa return test__checkevent_genhw(evlist); 296945aea22SJiri Olsa } 297945aea22SJiri Olsa 298a1e12da4SJiri Olsa static int test__checkevent_exclude_idle_modifier(struct perf_evlist *evlist) 299a1e12da4SJiri Olsa { 300a1e12da4SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 301a1e12da4SJiri Olsa 302a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); 303a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 304a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 305a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 306a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 307a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 308a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 309a1e12da4SJiri Olsa 310a1e12da4SJiri Olsa return test__checkevent_symbolic_name(evlist); 311a1e12da4SJiri Olsa } 312a1e12da4SJiri Olsa 313a1e12da4SJiri Olsa static int test__checkevent_exclude_idle_modifier_1(struct perf_evlist *evlist) 314a1e12da4SJiri Olsa { 315a1e12da4SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 316a1e12da4SJiri Olsa 317a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle); 318a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 319a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 320a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 321a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 322a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 323a1e12da4SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 324a1e12da4SJiri Olsa 325a1e12da4SJiri Olsa return test__checkevent_symbolic_name(evlist); 326a1e12da4SJiri Olsa } 327a1e12da4SJiri Olsa 328945aea22SJiri Olsa static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) 329945aea22SJiri Olsa { 330945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 331945aea22SJiri Olsa 332945aea22SJiri Olsa 333945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 334945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 335945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 336945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 337945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 338945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:u")); 339945aea22SJiri Olsa 340945aea22SJiri Olsa return test__checkevent_breakpoint(evlist); 341945aea22SJiri Olsa } 342945aea22SJiri Olsa 343945aea22SJiri Olsa static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) 344945aea22SJiri Olsa { 345945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 346945aea22SJiri Olsa 347945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 348945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 349945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 350945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 351945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 352945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:x:k")); 353945aea22SJiri Olsa 354945aea22SJiri Olsa return test__checkevent_breakpoint_x(evlist); 355945aea22SJiri Olsa } 356945aea22SJiri Olsa 357945aea22SJiri Olsa static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) 358945aea22SJiri Olsa { 359945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 360945aea22SJiri Olsa 361945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 362945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 363945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 364945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 365945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 366945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:r:hp")); 367945aea22SJiri Olsa 368945aea22SJiri Olsa return test__checkevent_breakpoint_r(evlist); 369945aea22SJiri Olsa } 370945aea22SJiri Olsa 371945aea22SJiri Olsa static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) 372945aea22SJiri Olsa { 373945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 374945aea22SJiri Olsa 375945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 376945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 377945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 378945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 379945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 380945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:w:up")); 381945aea22SJiri Olsa 382945aea22SJiri Olsa return test__checkevent_breakpoint_w(evlist); 383945aea22SJiri Olsa } 384945aea22SJiri Olsa 385945aea22SJiri Olsa static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) 386945aea22SJiri Olsa { 387945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 388945aea22SJiri Olsa 389945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 390945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 391945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 392945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 393945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 394945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "mem:0:rw:kp")); 395945aea22SJiri Olsa 396945aea22SJiri Olsa return test__checkevent_breakpoint_rw(evlist); 397945aea22SJiri Olsa } 398945aea22SJiri Olsa 399945aea22SJiri Olsa static int test__checkevent_pmu(struct perf_evlist *evlist) 400945aea22SJiri Olsa { 401945aea22SJiri Olsa 402945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 403945aea22SJiri Olsa 404945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 405945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 406945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); 407945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); 408945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); 409945aea22SJiri Olsa TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period); 410945aea22SJiri Olsa 411945aea22SJiri Olsa return 0; 412945aea22SJiri Olsa } 413945aea22SJiri Olsa 414945aea22SJiri Olsa static int test__checkevent_list(struct perf_evlist *evlist) 415945aea22SJiri Olsa { 416945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 417945aea22SJiri Olsa 418945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 419945aea22SJiri Olsa 420945aea22SJiri Olsa /* r1 */ 421945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 422945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 423945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); 424945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2); 425945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 426945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 427945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 428945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 429945aea22SJiri Olsa 430*43f322b4SRiku Voipio /* syscalls:sys_enter_openat:k */ 431945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 432945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 433945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 434945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 435945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); 436945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 437945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 438945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 439945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 440945aea22SJiri Olsa 441945aea22SJiri Olsa /* 1:1:hp */ 442945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 443945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); 444945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 445945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 446945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 447945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 448945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 449945aea22SJiri Olsa 450945aea22SJiri Olsa return 0; 451945aea22SJiri Olsa } 452945aea22SJiri Olsa 453945aea22SJiri Olsa static int test__checkevent_pmu_name(struct perf_evlist *evlist) 454945aea22SJiri Olsa { 455945aea22SJiri Olsa struct perf_evsel *evsel = perf_evlist__first(evlist); 456945aea22SJiri Olsa 457945aea22SJiri Olsa /* cpu/config=1,name=krava/u */ 458945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 459945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 460945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); 461945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); 462945aea22SJiri Olsa 463945aea22SJiri Olsa /* cpu/config=2/u" */ 464945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 465945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 466945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 467945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); 468945aea22SJiri Olsa TEST_ASSERT_VAL("wrong name", 469945aea22SJiri Olsa !strcmp(perf_evsel__name(evsel), "cpu/config=2/u")); 470945aea22SJiri Olsa 471945aea22SJiri Olsa return 0; 472945aea22SJiri Olsa } 473945aea22SJiri Olsa 474945aea22SJiri Olsa static int test__checkevent_pmu_events(struct perf_evlist *evlist) 475945aea22SJiri Olsa { 4769a354cdcSArnaldo Carvalho de Melo struct perf_evsel *evsel = perf_evlist__first(evlist); 477945aea22SJiri Olsa 478945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 479945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 480945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", 481945aea22SJiri Olsa !evsel->attr.exclude_user); 482945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", 483945aea22SJiri Olsa evsel->attr.exclude_kernel); 484945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 485945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 486c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 487945aea22SJiri Olsa 488945aea22SJiri Olsa return 0; 489945aea22SJiri Olsa } 490945aea22SJiri Olsa 491ffe59788SKan Liang 492ffe59788SKan Liang static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist) 493ffe59788SKan Liang { 494ffe59788SKan Liang struct perf_evsel *evsel = perf_evlist__first(evlist); 495ffe59788SKan Liang 496ffe59788SKan Liang /* pmu-event:u */ 497ffe59788SKan Liang TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 498ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_user", 499ffe59788SKan Liang !evsel->attr.exclude_user); 500ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_kernel", 501ffe59788SKan Liang evsel->attr.exclude_kernel); 502ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 503ffe59788SKan Liang TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 504ffe59788SKan Liang TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 505ffe59788SKan Liang 506ffe59788SKan Liang /* cpu/pmu-event/u*/ 507ffe59788SKan Liang evsel = perf_evsel__next(evsel); 508ffe59788SKan Liang TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 509ffe59788SKan Liang TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); 510ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_user", 511ffe59788SKan Liang !evsel->attr.exclude_user); 512ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_kernel", 513ffe59788SKan Liang evsel->attr.exclude_kernel); 514ffe59788SKan Liang TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 515ffe59788SKan Liang TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 516ffe59788SKan Liang TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 517ffe59788SKan Liang 518ffe59788SKan Liang return 0; 519ffe59788SKan Liang } 520ffe59788SKan Liang 521945aea22SJiri Olsa static int test__checkterms_simple(struct list_head *terms) 522945aea22SJiri Olsa { 5236cee6cd3SArnaldo Carvalho de Melo struct parse_events_term *term; 524945aea22SJiri Olsa 525945aea22SJiri Olsa /* config=10 */ 5266cee6cd3SArnaldo Carvalho de Melo term = list_entry(terms->next, struct parse_events_term, list); 527945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 528945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); 529945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 530945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 531945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 10); 532945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !term->config); 533945aea22SJiri Olsa 534945aea22SJiri Olsa /* config1 */ 5356cee6cd3SArnaldo Carvalho de Melo term = list_entry(term->list.next, struct parse_events_term, list); 536945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 537945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); 538945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 539945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 540945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 1); 541945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !term->config); 542945aea22SJiri Olsa 543945aea22SJiri Olsa /* config2=3 */ 5446cee6cd3SArnaldo Carvalho de Melo term = list_entry(term->list.next, struct parse_events_term, list); 545945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 546945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); 547945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 548945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 549945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 3); 550945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !term->config); 551945aea22SJiri Olsa 552945aea22SJiri Olsa /* umask=1*/ 5536cee6cd3SArnaldo Carvalho de Melo term = list_entry(term->list.next, struct parse_events_term, list); 554945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type term", 555945aea22SJiri Olsa term->type_term == PARSE_EVENTS__TERM_TYPE_USER); 556945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type val", 557945aea22SJiri Olsa term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); 558945aea22SJiri Olsa TEST_ASSERT_VAL("wrong val", term->val.num == 1); 559945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); 560945aea22SJiri Olsa 561945aea22SJiri Olsa return 0; 562945aea22SJiri Olsa } 563945aea22SJiri Olsa 564945aea22SJiri Olsa static int test__group1(struct perf_evlist *evlist) 565945aea22SJiri Olsa { 566945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 567945aea22SJiri Olsa 568945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 5698d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 570945aea22SJiri Olsa 571945aea22SJiri Olsa /* instructions:k */ 572945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 573945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 574945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 575945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 576945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 577945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 578945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 579945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 580945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 581945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 582823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 5838d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 5848d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 585a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 586945aea22SJiri Olsa 587945aea22SJiri Olsa /* cycles:upp */ 588945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 589945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 590945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 591945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 592945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 593945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 594945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 595945aea22SJiri Olsa /* use of precise requires exclude_guest */ 596945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 597945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 598945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); 599945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 6008d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 601a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 602945aea22SJiri Olsa 603945aea22SJiri Olsa return 0; 604945aea22SJiri Olsa } 605945aea22SJiri Olsa 606945aea22SJiri Olsa static int test__group2(struct perf_evlist *evlist) 607945aea22SJiri Olsa { 608945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 609945aea22SJiri Olsa 610945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 6118d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 612945aea22SJiri Olsa 613945aea22SJiri Olsa /* faults + :ku modifier */ 614945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 615945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); 616945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 617945aea22SJiri Olsa PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); 618945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 619945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 620945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 621945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 622945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 623945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 624823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 6258d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 6268d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 627a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 628945aea22SJiri Olsa 629945aea22SJiri Olsa /* cache-references + :u modifier */ 630945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 631945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 632945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 633945aea22SJiri Olsa PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); 634945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 635945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 636945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 6375a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 638945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 639945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 640945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 6418d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 642a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 643945aea22SJiri Olsa 644945aea22SJiri Olsa /* cycles:k */ 645945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 646945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 647945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 648945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 649945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 650945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 651945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 652945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 653945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 654945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 655823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 656a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 657945aea22SJiri Olsa 658945aea22SJiri Olsa return 0; 659945aea22SJiri Olsa } 660945aea22SJiri Olsa 661945aea22SJiri Olsa static int test__group3(struct perf_evlist *evlist __maybe_unused) 662945aea22SJiri Olsa { 663945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 664945aea22SJiri Olsa 665945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); 6668d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); 667945aea22SJiri Olsa 668*43f322b4SRiku Voipio /* group1 syscalls:sys_enter_openat:H */ 669945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 670945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); 671945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_type", 672945aea22SJiri Olsa PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); 673945aea22SJiri Olsa TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); 674945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 675945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 676945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 677945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 678945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 679945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 680823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 681945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", 682945aea22SJiri Olsa !strcmp(leader->group_name, "group1")); 6838d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 6848d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 685a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 686945aea22SJiri Olsa 687945aea22SJiri Olsa /* group1 cycles:kppp */ 688945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 689945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 690945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 691945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 692945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 693945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 694945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 695945aea22SJiri Olsa /* use of precise requires exclude_guest */ 696945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 697945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 698945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); 699945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 700945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 7018d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 702a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 703945aea22SJiri Olsa 704945aea22SJiri Olsa /* group2 cycles + G modifier */ 705945aea22SJiri Olsa evsel = leader = perf_evsel__next(evsel); 706945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 707945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 708945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 709945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 710945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 711945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 712945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 713945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 714945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 715823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 716945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", 717945aea22SJiri Olsa !strcmp(leader->group_name, "group2")); 7188d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 7198d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 720a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 721945aea22SJiri Olsa 722945aea22SJiri Olsa /* group2 1:3 + G modifier */ 723945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 724945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); 725945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); 726945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 727945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 728945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 729945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 730945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 731945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 732945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 7338d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 734a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 735945aea22SJiri Olsa 736945aea22SJiri Olsa /* instructions:u */ 737945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 738945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 739945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 740945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 741945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 742945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 743945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 744945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 745945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 746945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 747823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 748a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 749945aea22SJiri Olsa 750945aea22SJiri Olsa return 0; 751945aea22SJiri Olsa } 752945aea22SJiri Olsa 753945aea22SJiri Olsa static int test__group4(struct perf_evlist *evlist __maybe_unused) 754945aea22SJiri Olsa { 755945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 756945aea22SJiri Olsa 757945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 7588d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 759945aea22SJiri Olsa 760945aea22SJiri Olsa /* cycles:u + p */ 761945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 762945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 763945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 764945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 765945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 766945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 767945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 768945aea22SJiri Olsa /* use of precise requires exclude_guest */ 769945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 770945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 771945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); 772945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 773823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 7748d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 7758d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 776a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 777945aea22SJiri Olsa 778945aea22SJiri Olsa /* instructions:kp + p */ 779945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 780945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 781945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 782945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 783945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 784945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 785945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 786945aea22SJiri Olsa /* use of precise requires exclude_guest */ 787945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 788945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 789945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); 790945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 7918d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 792a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 793945aea22SJiri Olsa 794945aea22SJiri Olsa return 0; 795945aea22SJiri Olsa } 796945aea22SJiri Olsa 797945aea22SJiri Olsa static int test__group5(struct perf_evlist *evlist __maybe_unused) 798945aea22SJiri Olsa { 799945aea22SJiri Olsa struct perf_evsel *evsel, *leader; 800945aea22SJiri Olsa 801945aea22SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); 8028d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); 803945aea22SJiri Olsa 804945aea22SJiri Olsa /* cycles + G */ 805945aea22SJiri Olsa evsel = leader = perf_evlist__first(evlist); 806945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 807945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 808945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 809945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 810945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 811945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 812945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 813945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 814945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 815945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 816823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 8178d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 8188d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 819a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 820945aea22SJiri Olsa 821945aea22SJiri Olsa /* instructions + G */ 822945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 823945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 824945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 825945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 826945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 827945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 828945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 829945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 830945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 831945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 832945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 8338d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 834a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 835945aea22SJiri Olsa 836945aea22SJiri Olsa /* cycles:G */ 837945aea22SJiri Olsa evsel = leader = perf_evsel__next(evsel); 838945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 839945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 840945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 841945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 842945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 843945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 844945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 845945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 846945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 847945aea22SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 848823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 8498d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 8508d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 851a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); 852945aea22SJiri Olsa 853945aea22SJiri Olsa /* instructions:G */ 854945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 855945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 856945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 857945aea22SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 858945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 859945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 860945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 861945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 862945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 863945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 864945aea22SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 8658d7d8474SNamhyung Kim TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 866945aea22SJiri Olsa 867945aea22SJiri Olsa /* cycles */ 868945aea22SJiri Olsa evsel = perf_evsel__next(evsel); 869945aea22SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 870945aea22SJiri Olsa TEST_ASSERT_VAL("wrong config", 871945aea22SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 872945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 873945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 874945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 875945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 876945aea22SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 877945aea22SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 878823254edSNamhyung Kim TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 879945aea22SJiri Olsa 880945aea22SJiri Olsa return 0; 881945aea22SJiri Olsa } 882945aea22SJiri Olsa 8835a30a99fSJiri Olsa static int test__group_gh1(struct perf_evlist *evlist) 8845a30a99fSJiri Olsa { 8855a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 8865a30a99fSJiri Olsa 8875a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 8885a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 8895a30a99fSJiri Olsa 8905a30a99fSJiri Olsa /* cycles + :H group modifier */ 8915a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 8925a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 8935a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 8945a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 8955a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 8965a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 8975a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 8985a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 8995a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 9005a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9015a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 9025a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 9035a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 9045a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 9055a30a99fSJiri Olsa 9065a30a99fSJiri Olsa /* cache-misses:G + :H group modifier */ 9075a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 9085a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9095a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9105a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 9115a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9125a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 9135a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 9145a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 9155a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 9165a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9175a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 9185a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 9195a30a99fSJiri Olsa 9205a30a99fSJiri Olsa return 0; 9215a30a99fSJiri Olsa } 9225a30a99fSJiri Olsa 9235a30a99fSJiri Olsa static int test__group_gh2(struct perf_evlist *evlist) 9245a30a99fSJiri Olsa { 9255a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 9265a30a99fSJiri Olsa 9275a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 9285a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 9295a30a99fSJiri Olsa 9305a30a99fSJiri Olsa /* cycles + :G group modifier */ 9315a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 9325a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9335a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9345a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 9355a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9365a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 9375a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 9385a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 9395a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 9405a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9415a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 9425a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 9435a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 9445a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 9455a30a99fSJiri Olsa 9465a30a99fSJiri Olsa /* cache-misses:H + :G group modifier */ 9475a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 9485a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9495a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9505a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 9515a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9525a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 9535a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 9545a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 9555a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 9565a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9575a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 9585a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 9595a30a99fSJiri Olsa 9605a30a99fSJiri Olsa return 0; 9615a30a99fSJiri Olsa } 9625a30a99fSJiri Olsa 9635a30a99fSJiri Olsa static int test__group_gh3(struct perf_evlist *evlist) 9645a30a99fSJiri Olsa { 9655a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 9665a30a99fSJiri Olsa 9675a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 9685a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 9695a30a99fSJiri Olsa 9705a30a99fSJiri Olsa /* cycles:G + :u group modifier */ 9715a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 9725a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9735a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9745a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 9755a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9765a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 9775a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 9785a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 9795a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 9805a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9815a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 9825a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 9835a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 9845a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 9855a30a99fSJiri Olsa 9865a30a99fSJiri Olsa /* cache-misses:H + :u group modifier */ 9875a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 9885a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 9895a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 9905a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 9915a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 9925a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 9935a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 9945a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 9955a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 9965a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 9975a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 9985a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 9995a30a99fSJiri Olsa 10005a30a99fSJiri Olsa return 0; 10015a30a99fSJiri Olsa } 10025a30a99fSJiri Olsa 10035a30a99fSJiri Olsa static int test__group_gh4(struct perf_evlist *evlist) 10045a30a99fSJiri Olsa { 10055a30a99fSJiri Olsa struct perf_evsel *evsel, *leader; 10065a30a99fSJiri Olsa 10075a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 10085a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); 10095a30a99fSJiri Olsa 10105a30a99fSJiri Olsa /* cycles:G + :uG group modifier */ 10115a30a99fSJiri Olsa evsel = leader = perf_evlist__first(evlist); 10125a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 10135a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 10145a30a99fSJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 10155a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 10165a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 10175a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 10185a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 10195a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); 10205a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10215a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 10225a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); 10235a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); 10245a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); 10255a30a99fSJiri Olsa 10265a30a99fSJiri Olsa /* cache-misses:H + :uG group modifier */ 10275a30a99fSJiri Olsa evsel = perf_evsel__next(evsel); 10285a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 10295a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong config", 10305a30a99fSJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 10315a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 10325a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 10335a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 10345a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 10355a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 10365a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 10375a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 10385a30a99fSJiri Olsa TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); 10395a30a99fSJiri Olsa 10405a30a99fSJiri Olsa return 0; 10415a30a99fSJiri Olsa } 10425a30a99fSJiri Olsa 1043a9f93f97SJiri Olsa static int test__leader_sample1(struct perf_evlist *evlist) 1044a9f93f97SJiri Olsa { 1045a9f93f97SJiri Olsa struct perf_evsel *evsel, *leader; 1046a9f93f97SJiri Olsa 1047a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 1048a9f93f97SJiri Olsa 1049a9f93f97SJiri Olsa /* cycles - sampling group leader */ 1050a9f93f97SJiri Olsa evsel = leader = perf_evlist__first(evlist); 1051a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1052a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1053a9f93f97SJiri Olsa PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 1054a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1055a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 1056a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 1057a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1058a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1059a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1060a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1061a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1062a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1063a9f93f97SJiri Olsa 1064a9f93f97SJiri Olsa /* cache-misses - not sampling */ 1065a9f93f97SJiri Olsa evsel = perf_evsel__next(evsel); 1066a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1067a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1068a9f93f97SJiri Olsa PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 1069a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1070a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 1071a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 1072a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1073a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1074a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1075a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1076a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1077a9f93f97SJiri Olsa 1078a9f93f97SJiri Olsa /* branch-misses - not sampling */ 1079a9f93f97SJiri Olsa evsel = perf_evsel__next(evsel); 1080a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1081a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1082a9f93f97SJiri Olsa PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1083a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1084a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 1085a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); 1086a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1087a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1088a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1089a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1090a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1091a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1092a9f93f97SJiri Olsa 1093a9f93f97SJiri Olsa return 0; 1094a9f93f97SJiri Olsa } 1095a9f93f97SJiri Olsa 1096a9f93f97SJiri Olsa static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused) 1097a9f93f97SJiri Olsa { 1098a9f93f97SJiri Olsa struct perf_evsel *evsel, *leader; 1099a9f93f97SJiri Olsa 1100a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); 1101a9f93f97SJiri Olsa 1102a9f93f97SJiri Olsa /* instructions - sampling group leader */ 1103a9f93f97SJiri Olsa evsel = leader = perf_evlist__first(evlist); 1104a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1105a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1106a9f93f97SJiri Olsa PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); 1107a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1108a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1109a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1110a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1111a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1112a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1113a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1114a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1115a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1116a9f93f97SJiri Olsa 1117a9f93f97SJiri Olsa /* branch-misses - not sampling */ 1118a9f93f97SJiri Olsa evsel = perf_evsel__next(evsel); 1119a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1120a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong config", 1121a9f93f97SJiri Olsa PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1122a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1123a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1124a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1125a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); 1126a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 1127a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1128a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1129a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1130a9f93f97SJiri Olsa TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); 1131a9f93f97SJiri Olsa 1132a9f93f97SJiri Olsa return 0; 1133a9f93f97SJiri Olsa } 1134a9f93f97SJiri Olsa 1135c9ee780fSMichael Ellerman static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) 1136c9ee780fSMichael Ellerman { 1137c9ee780fSMichael Ellerman struct perf_evsel *evsel = perf_evlist__first(evlist); 1138c9ee780fSMichael Ellerman 1139c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1140c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1141c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1142c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip); 1143c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); 1144c9ee780fSMichael Ellerman 1145c9ee780fSMichael Ellerman return test__checkevent_symbolic_name(evlist); 1146c9ee780fSMichael Ellerman } 1147c9ee780fSMichael Ellerman 1148c9ee780fSMichael Ellerman static int test__pinned_group(struct perf_evlist *evlist) 1149c9ee780fSMichael Ellerman { 1150c9ee780fSMichael Ellerman struct perf_evsel *evsel, *leader; 1151c9ee780fSMichael Ellerman 1152c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); 1153c9ee780fSMichael Ellerman 1154c9ee780fSMichael Ellerman /* cycles - group leader */ 1155c9ee780fSMichael Ellerman evsel = leader = perf_evlist__first(evlist); 1156c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1157c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong config", 1158c9ee780fSMichael Ellerman PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 1159c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 1160c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 1161c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); 1162c9ee780fSMichael Ellerman 1163c9ee780fSMichael Ellerman /* cache-misses - can not be pinned, but will go on with the leader */ 1164c9ee780fSMichael Ellerman evsel = perf_evsel__next(evsel); 1165c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 1166c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong config", 1167c9ee780fSMichael Ellerman PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); 1168c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 1169c9ee780fSMichael Ellerman 1170c9ee780fSMichael Ellerman /* branch-misses - ditto */ 1171c9ee780fSMichael Ellerman evsel = perf_evsel__next(evsel); 1172c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong config", 1173c9ee780fSMichael Ellerman PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); 1174c9ee780fSMichael Ellerman TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); 1175c9ee780fSMichael Ellerman 1176c9ee780fSMichael Ellerman return 0; 1177c9ee780fSMichael Ellerman } 1178c9ee780fSMichael Ellerman 1179ec32398cSJacob Shin static int test__checkevent_breakpoint_len(struct perf_evlist *evlist) 1180ec32398cSJacob Shin { 1181ec32398cSJacob Shin struct perf_evsel *evsel = perf_evlist__first(evlist); 1182ec32398cSJacob Shin 1183ec32398cSJacob Shin TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 1184ec32398cSJacob Shin TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 1185ec32398cSJacob Shin TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 1186ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == 1187ec32398cSJacob Shin evsel->attr.bp_type); 1188ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 == 1189ec32398cSJacob Shin evsel->attr.bp_len); 1190ec32398cSJacob Shin 1191ec32398cSJacob Shin return 0; 1192ec32398cSJacob Shin } 1193ec32398cSJacob Shin 1194ec32398cSJacob Shin static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist) 1195ec32398cSJacob Shin { 1196ec32398cSJacob Shin struct perf_evsel *evsel = perf_evlist__first(evlist); 1197ec32398cSJacob Shin 1198ec32398cSJacob Shin TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); 1199ec32398cSJacob Shin TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); 1200ec32398cSJacob Shin TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); 1201ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W == 1202ec32398cSJacob Shin evsel->attr.bp_type); 1203ec32398cSJacob Shin TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 == 1204ec32398cSJacob Shin evsel->attr.bp_len); 1205ec32398cSJacob Shin 1206ec32398cSJacob Shin return 0; 1207ec32398cSJacob Shin } 1208ec32398cSJacob Shin 1209ec32398cSJacob Shin static int 1210ec32398cSJacob Shin test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist) 1211ec32398cSJacob Shin { 1212ec32398cSJacob Shin struct perf_evsel *evsel = perf_evlist__first(evlist); 1213ec32398cSJacob Shin 1214ec32398cSJacob Shin TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 1215ec32398cSJacob Shin TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 1216ec32398cSJacob Shin TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 1217ec32398cSJacob Shin TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); 1218ec32398cSJacob Shin 1219ec32398cSJacob Shin return test__checkevent_breakpoint_rw(evlist); 1220ec32398cSJacob Shin } 1221ec32398cSJacob Shin 122282ce75d9SJiri Olsa static int count_tracepoints(void) 122382ce75d9SJiri Olsa { 122482ce75d9SJiri Olsa char events_path[PATH_MAX]; 122582ce75d9SJiri Olsa struct dirent *events_ent; 122623773ca1SSteven Rostedt (Red Hat) const char *mountpoint; 122782ce75d9SJiri Olsa DIR *events_dir; 122882ce75d9SJiri Olsa int cnt = 0; 122982ce75d9SJiri Olsa 123023773ca1SSteven Rostedt (Red Hat) mountpoint = tracefs_find_mountpoint(); 123123773ca1SSteven Rostedt (Red Hat) if (mountpoint) { 123223773ca1SSteven Rostedt (Red Hat) scnprintf(events_path, PATH_MAX, "%s/events", 123323773ca1SSteven Rostedt (Red Hat) mountpoint); 123423773ca1SSteven Rostedt (Red Hat) } else { 123523773ca1SSteven Rostedt (Red Hat) mountpoint = debugfs_find_mountpoint(); 123682ce75d9SJiri Olsa scnprintf(events_path, PATH_MAX, "%s/tracing/events", 123723773ca1SSteven Rostedt (Red Hat) mountpoint); 123823773ca1SSteven Rostedt (Red Hat) } 123982ce75d9SJiri Olsa 124082ce75d9SJiri Olsa events_dir = opendir(events_path); 124182ce75d9SJiri Olsa 124282ce75d9SJiri Olsa TEST_ASSERT_VAL("Can't open events dir", events_dir); 124382ce75d9SJiri Olsa 124482ce75d9SJiri Olsa while ((events_ent = readdir(events_dir))) { 124582ce75d9SJiri Olsa char sys_path[PATH_MAX]; 124682ce75d9SJiri Olsa struct dirent *sys_ent; 124782ce75d9SJiri Olsa DIR *sys_dir; 124882ce75d9SJiri Olsa 124982ce75d9SJiri Olsa if (!strcmp(events_ent->d_name, ".") 125082ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "..") 125182ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "enable") 125282ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "header_event") 125382ce75d9SJiri Olsa || !strcmp(events_ent->d_name, "header_page")) 125482ce75d9SJiri Olsa continue; 125582ce75d9SJiri Olsa 125682ce75d9SJiri Olsa scnprintf(sys_path, PATH_MAX, "%s/%s", 125782ce75d9SJiri Olsa events_path, events_ent->d_name); 125882ce75d9SJiri Olsa 125982ce75d9SJiri Olsa sys_dir = opendir(sys_path); 126082ce75d9SJiri Olsa TEST_ASSERT_VAL("Can't open sys dir", sys_dir); 126182ce75d9SJiri Olsa 126282ce75d9SJiri Olsa while ((sys_ent = readdir(sys_dir))) { 126382ce75d9SJiri Olsa if (!strcmp(sys_ent->d_name, ".") 126482ce75d9SJiri Olsa || !strcmp(sys_ent->d_name, "..") 126582ce75d9SJiri Olsa || !strcmp(sys_ent->d_name, "enable") 126682ce75d9SJiri Olsa || !strcmp(sys_ent->d_name, "filter")) 126782ce75d9SJiri Olsa continue; 126882ce75d9SJiri Olsa 126982ce75d9SJiri Olsa cnt++; 127082ce75d9SJiri Olsa } 127182ce75d9SJiri Olsa 127282ce75d9SJiri Olsa closedir(sys_dir); 127382ce75d9SJiri Olsa } 127482ce75d9SJiri Olsa 127582ce75d9SJiri Olsa closedir(events_dir); 127682ce75d9SJiri Olsa return cnt; 127782ce75d9SJiri Olsa } 127882ce75d9SJiri Olsa 127982ce75d9SJiri Olsa static int test__all_tracepoints(struct perf_evlist *evlist) 128082ce75d9SJiri Olsa { 128182ce75d9SJiri Olsa TEST_ASSERT_VAL("wrong events count", 128282ce75d9SJiri Olsa count_tracepoints() == evlist->nr_entries); 128382ce75d9SJiri Olsa 128482ce75d9SJiri Olsa return test__checkevent_tracepoint_multi(evlist); 128582ce75d9SJiri Olsa } 128682ce75d9SJiri Olsa 128723b6339bSArnaldo Carvalho de Melo struct evlist_test { 1288945aea22SJiri Olsa const char *name; 1289945aea22SJiri Olsa __u32 type; 1290615b8f99SAlexander Yarygin const int id; 1291945aea22SJiri Olsa int (*check)(struct perf_evlist *evlist); 1292945aea22SJiri Olsa }; 1293945aea22SJiri Olsa 129423b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events[] = { 1295615b8f99SAlexander Yarygin { 1296*43f322b4SRiku Voipio .name = "syscalls:sys_enter_openat", 1297945aea22SJiri Olsa .check = test__checkevent_tracepoint, 1298615b8f99SAlexander Yarygin .id = 0, 1299945aea22SJiri Olsa }, 1300615b8f99SAlexander Yarygin { 1301945aea22SJiri Olsa .name = "syscalls:*", 1302945aea22SJiri Olsa .check = test__checkevent_tracepoint_multi, 1303615b8f99SAlexander Yarygin .id = 1, 1304945aea22SJiri Olsa }, 1305615b8f99SAlexander Yarygin { 1306945aea22SJiri Olsa .name = "r1a", 1307945aea22SJiri Olsa .check = test__checkevent_raw, 1308615b8f99SAlexander Yarygin .id = 2, 1309945aea22SJiri Olsa }, 1310615b8f99SAlexander Yarygin { 1311945aea22SJiri Olsa .name = "1:1", 1312945aea22SJiri Olsa .check = test__checkevent_numeric, 1313615b8f99SAlexander Yarygin .id = 3, 1314945aea22SJiri Olsa }, 1315615b8f99SAlexander Yarygin { 1316945aea22SJiri Olsa .name = "instructions", 1317945aea22SJiri Olsa .check = test__checkevent_symbolic_name, 1318615b8f99SAlexander Yarygin .id = 4, 1319945aea22SJiri Olsa }, 1320615b8f99SAlexander Yarygin { 1321945aea22SJiri Olsa .name = "cycles/period=100000,config2/", 1322945aea22SJiri Olsa .check = test__checkevent_symbolic_name_config, 1323615b8f99SAlexander Yarygin .id = 5, 1324945aea22SJiri Olsa }, 1325615b8f99SAlexander Yarygin { 1326945aea22SJiri Olsa .name = "faults", 1327945aea22SJiri Olsa .check = test__checkevent_symbolic_alias, 1328615b8f99SAlexander Yarygin .id = 6, 1329945aea22SJiri Olsa }, 1330615b8f99SAlexander Yarygin { 1331945aea22SJiri Olsa .name = "L1-dcache-load-miss", 1332945aea22SJiri Olsa .check = test__checkevent_genhw, 1333615b8f99SAlexander Yarygin .id = 7, 1334945aea22SJiri Olsa }, 1335615b8f99SAlexander Yarygin { 1336945aea22SJiri Olsa .name = "mem:0", 1337945aea22SJiri Olsa .check = test__checkevent_breakpoint, 1338615b8f99SAlexander Yarygin .id = 8, 1339945aea22SJiri Olsa }, 1340615b8f99SAlexander Yarygin { 1341945aea22SJiri Olsa .name = "mem:0:x", 1342945aea22SJiri Olsa .check = test__checkevent_breakpoint_x, 1343615b8f99SAlexander Yarygin .id = 9, 1344945aea22SJiri Olsa }, 1345615b8f99SAlexander Yarygin { 1346945aea22SJiri Olsa .name = "mem:0:r", 1347945aea22SJiri Olsa .check = test__checkevent_breakpoint_r, 1348615b8f99SAlexander Yarygin .id = 10, 1349945aea22SJiri Olsa }, 1350615b8f99SAlexander Yarygin { 1351945aea22SJiri Olsa .name = "mem:0:w", 1352945aea22SJiri Olsa .check = test__checkevent_breakpoint_w, 1353615b8f99SAlexander Yarygin .id = 11, 1354945aea22SJiri Olsa }, 1355615b8f99SAlexander Yarygin { 1356*43f322b4SRiku Voipio .name = "syscalls:sys_enter_openat:k", 1357945aea22SJiri Olsa .check = test__checkevent_tracepoint_modifier, 1358615b8f99SAlexander Yarygin .id = 12, 1359945aea22SJiri Olsa }, 1360615b8f99SAlexander Yarygin { 1361945aea22SJiri Olsa .name = "syscalls:*:u", 1362945aea22SJiri Olsa .check = test__checkevent_tracepoint_multi_modifier, 1363615b8f99SAlexander Yarygin .id = 13, 1364945aea22SJiri Olsa }, 1365615b8f99SAlexander Yarygin { 1366945aea22SJiri Olsa .name = "r1a:kp", 1367945aea22SJiri Olsa .check = test__checkevent_raw_modifier, 1368615b8f99SAlexander Yarygin .id = 14, 1369945aea22SJiri Olsa }, 1370615b8f99SAlexander Yarygin { 1371945aea22SJiri Olsa .name = "1:1:hp", 1372945aea22SJiri Olsa .check = test__checkevent_numeric_modifier, 1373615b8f99SAlexander Yarygin .id = 15, 1374945aea22SJiri Olsa }, 1375615b8f99SAlexander Yarygin { 1376945aea22SJiri Olsa .name = "instructions:h", 1377945aea22SJiri Olsa .check = test__checkevent_symbolic_name_modifier, 1378615b8f99SAlexander Yarygin .id = 16, 1379945aea22SJiri Olsa }, 1380615b8f99SAlexander Yarygin { 1381945aea22SJiri Olsa .name = "faults:u", 1382945aea22SJiri Olsa .check = test__checkevent_symbolic_alias_modifier, 1383615b8f99SAlexander Yarygin .id = 17, 1384945aea22SJiri Olsa }, 1385615b8f99SAlexander Yarygin { 1386945aea22SJiri Olsa .name = "L1-dcache-load-miss:kp", 1387945aea22SJiri Olsa .check = test__checkevent_genhw_modifier, 1388615b8f99SAlexander Yarygin .id = 18, 1389945aea22SJiri Olsa }, 1390615b8f99SAlexander Yarygin { 1391945aea22SJiri Olsa .name = "mem:0:u", 1392945aea22SJiri Olsa .check = test__checkevent_breakpoint_modifier, 1393615b8f99SAlexander Yarygin .id = 19, 1394945aea22SJiri Olsa }, 1395615b8f99SAlexander Yarygin { 1396945aea22SJiri Olsa .name = "mem:0:x:k", 1397945aea22SJiri Olsa .check = test__checkevent_breakpoint_x_modifier, 1398615b8f99SAlexander Yarygin .id = 20, 1399945aea22SJiri Olsa }, 1400615b8f99SAlexander Yarygin { 1401945aea22SJiri Olsa .name = "mem:0:r:hp", 1402945aea22SJiri Olsa .check = test__checkevent_breakpoint_r_modifier, 1403615b8f99SAlexander Yarygin .id = 21, 1404945aea22SJiri Olsa }, 1405615b8f99SAlexander Yarygin { 1406945aea22SJiri Olsa .name = "mem:0:w:up", 1407945aea22SJiri Olsa .check = test__checkevent_breakpoint_w_modifier, 1408615b8f99SAlexander Yarygin .id = 22, 1409945aea22SJiri Olsa }, 1410615b8f99SAlexander Yarygin { 1411*43f322b4SRiku Voipio .name = "r1,syscalls:sys_enter_openat:k,1:1:hp", 1412945aea22SJiri Olsa .check = test__checkevent_list, 1413615b8f99SAlexander Yarygin .id = 23, 1414945aea22SJiri Olsa }, 1415615b8f99SAlexander Yarygin { 1416945aea22SJiri Olsa .name = "instructions:G", 1417945aea22SJiri Olsa .check = test__checkevent_exclude_host_modifier, 1418615b8f99SAlexander Yarygin .id = 24, 1419945aea22SJiri Olsa }, 1420615b8f99SAlexander Yarygin { 1421945aea22SJiri Olsa .name = "instructions:H", 1422945aea22SJiri Olsa .check = test__checkevent_exclude_guest_modifier, 1423615b8f99SAlexander Yarygin .id = 25, 1424945aea22SJiri Olsa }, 1425615b8f99SAlexander Yarygin { 1426945aea22SJiri Olsa .name = "mem:0:rw", 1427945aea22SJiri Olsa .check = test__checkevent_breakpoint_rw, 1428615b8f99SAlexander Yarygin .id = 26, 1429945aea22SJiri Olsa }, 1430615b8f99SAlexander Yarygin { 1431945aea22SJiri Olsa .name = "mem:0:rw:kp", 1432945aea22SJiri Olsa .check = test__checkevent_breakpoint_rw_modifier, 1433615b8f99SAlexander Yarygin .id = 27, 1434945aea22SJiri Olsa }, 1435615b8f99SAlexander Yarygin { 1436945aea22SJiri Olsa .name = "{instructions:k,cycles:upp}", 1437945aea22SJiri Olsa .check = test__group1, 1438615b8f99SAlexander Yarygin .id = 28, 1439945aea22SJiri Olsa }, 1440615b8f99SAlexander Yarygin { 1441945aea22SJiri Olsa .name = "{faults:k,cache-references}:u,cycles:k", 1442945aea22SJiri Olsa .check = test__group2, 1443615b8f99SAlexander Yarygin .id = 29, 1444945aea22SJiri Olsa }, 1445615b8f99SAlexander Yarygin { 1446*43f322b4SRiku Voipio .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", 1447945aea22SJiri Olsa .check = test__group3, 1448615b8f99SAlexander Yarygin .id = 30, 1449945aea22SJiri Olsa }, 1450615b8f99SAlexander Yarygin { 1451945aea22SJiri Olsa .name = "{cycles:u,instructions:kp}:p", 1452945aea22SJiri Olsa .check = test__group4, 1453615b8f99SAlexander Yarygin .id = 31, 1454945aea22SJiri Olsa }, 1455615b8f99SAlexander Yarygin { 1456945aea22SJiri Olsa .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", 1457945aea22SJiri Olsa .check = test__group5, 1458615b8f99SAlexander Yarygin .id = 32, 1459945aea22SJiri Olsa }, 1460615b8f99SAlexander Yarygin { 146182ce75d9SJiri Olsa .name = "*:*", 146282ce75d9SJiri Olsa .check = test__all_tracepoints, 1463615b8f99SAlexander Yarygin .id = 33, 146482ce75d9SJiri Olsa }, 1465615b8f99SAlexander Yarygin { 14665a30a99fSJiri Olsa .name = "{cycles,cache-misses:G}:H", 14675a30a99fSJiri Olsa .check = test__group_gh1, 1468615b8f99SAlexander Yarygin .id = 34, 14695a30a99fSJiri Olsa }, 1470615b8f99SAlexander Yarygin { 14715a30a99fSJiri Olsa .name = "{cycles,cache-misses:H}:G", 14725a30a99fSJiri Olsa .check = test__group_gh2, 1473615b8f99SAlexander Yarygin .id = 35, 14745a30a99fSJiri Olsa }, 1475615b8f99SAlexander Yarygin { 14765a30a99fSJiri Olsa .name = "{cycles:G,cache-misses:H}:u", 14775a30a99fSJiri Olsa .check = test__group_gh3, 1478615b8f99SAlexander Yarygin .id = 36, 14795a30a99fSJiri Olsa }, 1480615b8f99SAlexander Yarygin { 14815a30a99fSJiri Olsa .name = "{cycles:G,cache-misses:H}:uG", 14825a30a99fSJiri Olsa .check = test__group_gh4, 1483615b8f99SAlexander Yarygin .id = 37, 14845a30a99fSJiri Olsa }, 1485615b8f99SAlexander Yarygin { 1486a9f93f97SJiri Olsa .name = "{cycles,cache-misses,branch-misses}:S", 1487a9f93f97SJiri Olsa .check = test__leader_sample1, 1488615b8f99SAlexander Yarygin .id = 38, 1489a9f93f97SJiri Olsa }, 1490615b8f99SAlexander Yarygin { 1491a9f93f97SJiri Olsa .name = "{instructions,branch-misses}:Su", 1492a9f93f97SJiri Olsa .check = test__leader_sample2, 1493615b8f99SAlexander Yarygin .id = 39, 1494a9f93f97SJiri Olsa }, 1495615b8f99SAlexander Yarygin { 1496c9ee780fSMichael Ellerman .name = "instructions:uDp", 1497c9ee780fSMichael Ellerman .check = test__checkevent_pinned_modifier, 1498615b8f99SAlexander Yarygin .id = 40, 1499c9ee780fSMichael Ellerman }, 1500615b8f99SAlexander Yarygin { 1501c9ee780fSMichael Ellerman .name = "{cycles,cache-misses,branch-misses}:D", 1502c9ee780fSMichael Ellerman .check = test__pinned_group, 1503615b8f99SAlexander Yarygin .id = 41, 1504c9ee780fSMichael Ellerman }, 1505ec32398cSJacob Shin { 1506ec32398cSJacob Shin .name = "mem:0/1", 1507ec32398cSJacob Shin .check = test__checkevent_breakpoint_len, 1508ec32398cSJacob Shin .id = 42, 1509ec32398cSJacob Shin }, 1510ec32398cSJacob Shin { 1511ec32398cSJacob Shin .name = "mem:0/2:w", 1512ec32398cSJacob Shin .check = test__checkevent_breakpoint_len_w, 1513ec32398cSJacob Shin .id = 43, 1514ec32398cSJacob Shin }, 1515ec32398cSJacob Shin { 1516ec32398cSJacob Shin .name = "mem:0/4:rw:u", 1517ec32398cSJacob Shin .check = test__checkevent_breakpoint_len_rw_modifier, 1518ec32398cSJacob Shin .id = 44 1519ec32398cSJacob Shin }, 1520c0bc8c6dSAlexander Yarygin #if defined(__s390x__) 1521c0bc8c6dSAlexander Yarygin { 1522c0bc8c6dSAlexander Yarygin .name = "kvm-s390:kvm_s390_create_vm", 1523c0bc8c6dSAlexander Yarygin .check = test__checkevent_tracepoint, 1524c0bc8c6dSAlexander Yarygin .id = 100, 1525c0bc8c6dSAlexander Yarygin }, 1526c0bc8c6dSAlexander Yarygin #endif 1527a1e12da4SJiri Olsa { 1528a1e12da4SJiri Olsa .name = "instructions:I", 1529a1e12da4SJiri Olsa .check = test__checkevent_exclude_idle_modifier, 1530a1e12da4SJiri Olsa .id = 45, 1531a1e12da4SJiri Olsa }, 1532a1e12da4SJiri Olsa { 1533a1e12da4SJiri Olsa .name = "instructions:kIG", 1534a1e12da4SJiri Olsa .check = test__checkevent_exclude_idle_modifier_1, 1535a1e12da4SJiri Olsa .id = 46, 1536a1e12da4SJiri Olsa }, 1537945aea22SJiri Olsa }; 1538945aea22SJiri Olsa 153923b6339bSArnaldo Carvalho de Melo static struct evlist_test test__events_pmu[] = { 1540615b8f99SAlexander Yarygin { 1541945aea22SJiri Olsa .name = "cpu/config=10,config1,config2=3,period=1000/u", 1542945aea22SJiri Olsa .check = test__checkevent_pmu, 1543615b8f99SAlexander Yarygin .id = 0, 1544945aea22SJiri Olsa }, 1545615b8f99SAlexander Yarygin { 1546945aea22SJiri Olsa .name = "cpu/config=1,name=krava/u,cpu/config=2/u", 1547945aea22SJiri Olsa .check = test__checkevent_pmu_name, 1548615b8f99SAlexander Yarygin .id = 1, 1549945aea22SJiri Olsa }, 1550945aea22SJiri Olsa }; 1551945aea22SJiri Olsa 155223b6339bSArnaldo Carvalho de Melo struct terms_test { 1553945aea22SJiri Olsa const char *str; 1554945aea22SJiri Olsa __u32 type; 1555945aea22SJiri Olsa int (*check)(struct list_head *terms); 1556945aea22SJiri Olsa }; 1557945aea22SJiri Olsa 155823b6339bSArnaldo Carvalho de Melo static struct terms_test test__terms[] = { 1559945aea22SJiri Olsa [0] = { 1560945aea22SJiri Olsa .str = "config=10,config1,config2=3,umask=1", 1561945aea22SJiri Olsa .check = test__checkterms_simple, 1562945aea22SJiri Olsa }, 1563945aea22SJiri Olsa }; 1564945aea22SJiri Olsa 156523b6339bSArnaldo Carvalho de Melo static int test_event(struct evlist_test *e) 1566945aea22SJiri Olsa { 1567945aea22SJiri Olsa struct perf_evlist *evlist; 1568945aea22SJiri Olsa int ret; 1569945aea22SJiri Olsa 1570334fe7a3SNamhyung Kim evlist = perf_evlist__new(); 1571945aea22SJiri Olsa if (evlist == NULL) 1572945aea22SJiri Olsa return -ENOMEM; 1573945aea22SJiri Olsa 1574b39b8393SJiri Olsa ret = parse_events(evlist, e->name, NULL); 1575945aea22SJiri Olsa if (ret) { 1576945aea22SJiri Olsa pr_debug("failed to parse event '%s', err %d\n", 1577945aea22SJiri Olsa e->name, ret); 15782d4352c0SArnaldo Carvalho de Melo } else { 15792d4352c0SArnaldo Carvalho de Melo ret = e->check(evlist); 1580945aea22SJiri Olsa } 1581945aea22SJiri Olsa 1582945aea22SJiri Olsa perf_evlist__delete(evlist); 1583945aea22SJiri Olsa 1584945aea22SJiri Olsa return ret; 1585945aea22SJiri Olsa } 1586945aea22SJiri Olsa 158723b6339bSArnaldo Carvalho de Melo static int test_events(struct evlist_test *events, unsigned cnt) 1588945aea22SJiri Olsa { 1589945aea22SJiri Olsa int ret1, ret2 = 0; 1590945aea22SJiri Olsa unsigned i; 1591945aea22SJiri Olsa 1592945aea22SJiri Olsa for (i = 0; i < cnt; i++) { 159323b6339bSArnaldo Carvalho de Melo struct evlist_test *e = &events[i]; 1594945aea22SJiri Olsa 1595615b8f99SAlexander Yarygin pr_debug("running test %d '%s'\n", e->id, e->name); 1596945aea22SJiri Olsa ret1 = test_event(e); 1597945aea22SJiri Olsa if (ret1) 1598945aea22SJiri Olsa ret2 = ret1; 1599945aea22SJiri Olsa } 1600945aea22SJiri Olsa 1601945aea22SJiri Olsa return ret2; 1602945aea22SJiri Olsa } 1603945aea22SJiri Olsa 160423b6339bSArnaldo Carvalho de Melo static int test_term(struct terms_test *t) 1605945aea22SJiri Olsa { 1606c549aca5SDavid Ahern struct list_head terms; 1607945aea22SJiri Olsa int ret; 1608945aea22SJiri Olsa 1609c549aca5SDavid Ahern INIT_LIST_HEAD(&terms); 1610945aea22SJiri Olsa 1611c549aca5SDavid Ahern ret = parse_events_terms(&terms, t->str); 1612945aea22SJiri Olsa if (ret) { 1613945aea22SJiri Olsa pr_debug("failed to parse terms '%s', err %d\n", 1614945aea22SJiri Olsa t->str , ret); 1615945aea22SJiri Olsa return ret; 1616945aea22SJiri Olsa } 1617945aea22SJiri Olsa 1618c549aca5SDavid Ahern ret = t->check(&terms); 1619c549aca5SDavid Ahern parse_events__free_terms(&terms); 1620945aea22SJiri Olsa 1621945aea22SJiri Olsa return ret; 1622945aea22SJiri Olsa } 1623945aea22SJiri Olsa 162423b6339bSArnaldo Carvalho de Melo static int test_terms(struct terms_test *terms, unsigned cnt) 1625945aea22SJiri Olsa { 1626945aea22SJiri Olsa int ret = 0; 1627945aea22SJiri Olsa unsigned i; 1628945aea22SJiri Olsa 1629945aea22SJiri Olsa for (i = 0; i < cnt; i++) { 163023b6339bSArnaldo Carvalho de Melo struct terms_test *t = &terms[i]; 1631945aea22SJiri Olsa 1632945aea22SJiri Olsa pr_debug("running test %d '%s'\n", i, t->str); 1633945aea22SJiri Olsa ret = test_term(t); 1634945aea22SJiri Olsa if (ret) 1635945aea22SJiri Olsa break; 1636945aea22SJiri Olsa } 1637945aea22SJiri Olsa 1638945aea22SJiri Olsa return ret; 1639945aea22SJiri Olsa } 1640945aea22SJiri Olsa 1641945aea22SJiri Olsa static int test_pmu(void) 1642945aea22SJiri Olsa { 1643945aea22SJiri Olsa struct stat st; 1644945aea22SJiri Olsa char path[PATH_MAX]; 1645945aea22SJiri Olsa int ret; 1646945aea22SJiri Olsa 1647945aea22SJiri Olsa snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", 1648cf38fadaSArnaldo Carvalho de Melo sysfs__mountpoint()); 1649945aea22SJiri Olsa 1650945aea22SJiri Olsa ret = stat(path, &st); 1651945aea22SJiri Olsa if (ret) 1652945aea22SJiri Olsa pr_debug("omitting PMU cpu tests\n"); 1653945aea22SJiri Olsa return !ret; 1654945aea22SJiri Olsa } 1655945aea22SJiri Olsa 1656945aea22SJiri Olsa static int test_pmu_events(void) 1657945aea22SJiri Olsa { 1658945aea22SJiri Olsa struct stat st; 1659945aea22SJiri Olsa char path[PATH_MAX]; 1660945aea22SJiri Olsa struct dirent *ent; 1661945aea22SJiri Olsa DIR *dir; 1662945aea22SJiri Olsa int ret; 1663945aea22SJiri Olsa 1664945aea22SJiri Olsa snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", 1665cf38fadaSArnaldo Carvalho de Melo sysfs__mountpoint()); 1666945aea22SJiri Olsa 1667945aea22SJiri Olsa ret = stat(path, &st); 1668945aea22SJiri Olsa if (ret) { 1669a895d57dSMasanari Iida pr_debug("omitting PMU cpu events tests\n"); 1670945aea22SJiri Olsa return 0; 1671945aea22SJiri Olsa } 1672945aea22SJiri Olsa 1673945aea22SJiri Olsa dir = opendir(path); 1674945aea22SJiri Olsa if (!dir) { 1675945aea22SJiri Olsa pr_debug("can't open pmu event dir"); 1676945aea22SJiri Olsa return -1; 1677945aea22SJiri Olsa } 1678945aea22SJiri Olsa 1679945aea22SJiri Olsa while (!ret && (ent = readdir(dir))) { 1680945aea22SJiri Olsa #define MAX_NAME 100 168123b6339bSArnaldo Carvalho de Melo struct evlist_test e; 1682945aea22SJiri Olsa char name[MAX_NAME]; 1683945aea22SJiri Olsa 1684945aea22SJiri Olsa if (!strcmp(ent->d_name, ".") || 1685945aea22SJiri Olsa !strcmp(ent->d_name, "..")) 1686945aea22SJiri Olsa continue; 1687945aea22SJiri Olsa 1688945aea22SJiri Olsa snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name); 1689945aea22SJiri Olsa 1690945aea22SJiri Olsa e.name = name; 1691945aea22SJiri Olsa e.check = test__checkevent_pmu_events; 1692945aea22SJiri Olsa 1693945aea22SJiri Olsa ret = test_event(&e); 1694ffe59788SKan Liang if (ret) 1695ffe59788SKan Liang break; 1696ffe59788SKan Liang snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name); 1697ffe59788SKan Liang e.name = name; 1698ffe59788SKan Liang e.check = test__checkevent_pmu_events_mix; 1699ffe59788SKan Liang ret = test_event(&e); 1700945aea22SJiri Olsa #undef MAX_NAME 1701945aea22SJiri Olsa } 1702945aea22SJiri Olsa 1703945aea22SJiri Olsa closedir(dir); 1704945aea22SJiri Olsa return ret; 1705945aea22SJiri Olsa } 1706945aea22SJiri Olsa 1707c81251e8SJiri Olsa int test__parse_events(void) 1708945aea22SJiri Olsa { 1709945aea22SJiri Olsa int ret1, ret2 = 0; 1710945aea22SJiri Olsa 1711945aea22SJiri Olsa #define TEST_EVENTS(tests) \ 1712945aea22SJiri Olsa do { \ 1713945aea22SJiri Olsa ret1 = test_events(tests, ARRAY_SIZE(tests)); \ 1714945aea22SJiri Olsa if (!ret2) \ 1715945aea22SJiri Olsa ret2 = ret1; \ 1716945aea22SJiri Olsa } while (0) 1717945aea22SJiri Olsa 1718945aea22SJiri Olsa TEST_EVENTS(test__events); 1719945aea22SJiri Olsa 1720945aea22SJiri Olsa if (test_pmu()) 1721945aea22SJiri Olsa TEST_EVENTS(test__events_pmu); 1722945aea22SJiri Olsa 1723945aea22SJiri Olsa if (test_pmu()) { 1724945aea22SJiri Olsa int ret = test_pmu_events(); 1725945aea22SJiri Olsa if (ret) 1726945aea22SJiri Olsa return ret; 1727945aea22SJiri Olsa } 1728945aea22SJiri Olsa 1729945aea22SJiri Olsa ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); 1730945aea22SJiri Olsa if (!ret2) 1731945aea22SJiri Olsa ret2 = ret1; 1732945aea22SJiri Olsa 1733945aea22SJiri Olsa return ret2; 1734945aea22SJiri Olsa } 1735