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