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