Arnaldo Carvalho de Melo | a43783a | 2017-04-18 10:46:11 -0300 | [diff] [blame] | 1 | #include <errno.h> |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 2 | #include <stdio.h> |
| 3 | #include <sys/epoll.h> |
Arnaldo Carvalho de Melo | 7a8ef4c | 2017-04-19 20:57:47 -0300 | [diff] [blame] | 4 | #include <sys/types.h> |
| 5 | #include <sys/stat.h> |
Arnaldo Carvalho de Melo | bafae98 | 2018-01-22 16:42:16 -0300 | [diff] [blame] | 6 | #include <fcntl.h> |
Wang Nan | 6a7d550 | 2016-01-25 09:55:53 +0000 | [diff] [blame] | 7 | #include <util/util.h> |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 8 | #include <util/bpf-loader.h> |
| 9 | #include <util/evlist.h> |
Wang Nan | 6a7d550 | 2016-01-25 09:55:53 +0000 | [diff] [blame] | 10 | #include <linux/bpf.h> |
| 11 | #include <linux/filter.h> |
Arnaldo Carvalho de Melo | 877a7a1 | 2017-04-17 11:39:06 -0300 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Joe Stringer | a263053 | 2017-01-26 13:20:01 -0800 | [diff] [blame] | 13 | #include <api/fs/fs.h> |
Wang Nan | 6a7d550 | 2016-01-25 09:55:53 +0000 | [diff] [blame] | 14 | #include <bpf/bpf.h> |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 15 | #include "tests.h" |
| 16 | #include "llvm.h" |
| 17 | #include "debug.h" |
| 18 | #define NR_ITERS 111 |
Joe Stringer | a263053 | 2017-01-26 13:20:01 -0800 | [diff] [blame] | 19 | #define PERF_TEST_BPF_PATH "/sys/fs/bpf/perf_test" |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 20 | |
| 21 | #ifdef HAVE_LIBBPF_SUPPORT |
| 22 | |
Arnaldo Carvalho de Melo | e0337f4 | 2018-01-04 12:43:32 -0300 | [diff] [blame] | 23 | static int epoll_pwait_loop(void) |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 24 | { |
| 25 | int i; |
| 26 | |
| 27 | /* Should fail NR_ITERS times */ |
| 28 | for (i = 0; i < NR_ITERS; i++) |
Arnaldo Carvalho de Melo | e0337f4 | 2018-01-04 12:43:32 -0300 | [diff] [blame] | 29 | epoll_pwait(-(i + 1), NULL, 0, 0, NULL); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 30 | return 0; |
| 31 | } |
| 32 | |
Wang Nan | bbb7d49 | 2015-11-16 12:10:14 +0000 | [diff] [blame] | 33 | #ifdef HAVE_BPF_PROLOGUE |
| 34 | |
| 35 | static int llseek_loop(void) |
| 36 | { |
| 37 | int fds[2], i; |
| 38 | |
| 39 | fds[0] = open("/dev/null", O_RDONLY); |
| 40 | fds[1] = open("/dev/null", O_RDWR); |
| 41 | |
| 42 | if (fds[0] < 0 || fds[1] < 0) |
| 43 | return -1; |
| 44 | |
| 45 | for (i = 0; i < NR_ITERS; i++) { |
| 46 | lseek(fds[i % 2], i, (i / 2) % 2 ? SEEK_CUR : SEEK_SET); |
| 47 | lseek(fds[(i + 1) % 2], i, (i / 2) % 2 ? SEEK_CUR : SEEK_SET); |
| 48 | } |
| 49 | close(fds[0]); |
| 50 | close(fds[1]); |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | #endif |
| 55 | |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 56 | static struct { |
| 57 | enum test_llvm__testcase prog_id; |
| 58 | const char *desc; |
| 59 | const char *name; |
| 60 | const char *msg_compile_fail; |
| 61 | const char *msg_load_fail; |
| 62 | int (*target_func)(void); |
| 63 | int expect_result; |
Joe Stringer | a263053 | 2017-01-26 13:20:01 -0800 | [diff] [blame] | 64 | bool pin; |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 65 | } bpf_testcase_table[] = { |
| 66 | { |
Arnaldo Carvalho de Melo | 13cb2d0 | 2018-01-02 15:18:07 -0300 | [diff] [blame] | 67 | .prog_id = LLVM_TESTCASE_BASE, |
| 68 | .desc = "Basic BPF filtering", |
| 69 | .name = "[basic_bpf_test]", |
| 70 | .msg_compile_fail = "fix 'perf test LLVM' first", |
| 71 | .msg_load_fail = "load bpf object failed", |
Arnaldo Carvalho de Melo | e0337f4 | 2018-01-04 12:43:32 -0300 | [diff] [blame] | 72 | .target_func = &epoll_pwait_loop, |
Arnaldo Carvalho de Melo | 13cb2d0 | 2018-01-02 15:18:07 -0300 | [diff] [blame] | 73 | .expect_result = (NR_ITERS + 1) / 2, |
Joe Stringer | a263053 | 2017-01-26 13:20:01 -0800 | [diff] [blame] | 74 | }, |
| 75 | { |
Arnaldo Carvalho de Melo | 13cb2d0 | 2018-01-02 15:18:07 -0300 | [diff] [blame] | 76 | .prog_id = LLVM_TESTCASE_BASE, |
| 77 | .desc = "BPF pinning", |
| 78 | .name = "[bpf_pinning]", |
| 79 | .msg_compile_fail = "fix kbuild first", |
| 80 | .msg_load_fail = "check your vmlinux setting?", |
Arnaldo Carvalho de Melo | e0337f4 | 2018-01-04 12:43:32 -0300 | [diff] [blame] | 81 | .target_func = &epoll_pwait_loop, |
Arnaldo Carvalho de Melo | 13cb2d0 | 2018-01-02 15:18:07 -0300 | [diff] [blame] | 82 | .expect_result = (NR_ITERS + 1) / 2, |
| 83 | .pin = true, |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 84 | }, |
Wang Nan | bbb7d49 | 2015-11-16 12:10:14 +0000 | [diff] [blame] | 85 | #ifdef HAVE_BPF_PROLOGUE |
| 86 | { |
Arnaldo Carvalho de Melo | 13cb2d0 | 2018-01-02 15:18:07 -0300 | [diff] [blame] | 87 | .prog_id = LLVM_TESTCASE_BPF_PROLOGUE, |
| 88 | .desc = "BPF prologue generation", |
| 89 | .name = "[bpf_prologue_test]", |
| 90 | .msg_compile_fail = "fix kbuild first", |
| 91 | .msg_load_fail = "check your vmlinux setting?", |
| 92 | .target_func = &llseek_loop, |
| 93 | .expect_result = (NR_ITERS + 1) / 4, |
Wang Nan | bbb7d49 | 2015-11-16 12:10:14 +0000 | [diff] [blame] | 94 | }, |
| 95 | #endif |
Wang Nan | 7b6982c | 2016-01-25 09:55:48 +0000 | [diff] [blame] | 96 | { |
Arnaldo Carvalho de Melo | 13cb2d0 | 2018-01-02 15:18:07 -0300 | [diff] [blame] | 97 | .prog_id = LLVM_TESTCASE_BPF_RELOCATION, |
| 98 | .desc = "BPF relocation checker", |
| 99 | .name = "[bpf_relocation_test]", |
| 100 | .msg_compile_fail = "fix 'perf test LLVM' first", |
| 101 | .msg_load_fail = "libbpf error when dealing with relocation", |
Wang Nan | 7b6982c | 2016-01-25 09:55:48 +0000 | [diff] [blame] | 102 | }, |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | static int do_test(struct bpf_object *obj, int (*func)(void), |
| 106 | int expect) |
| 107 | { |
| 108 | struct record_opts opts = { |
| 109 | .target = { |
| 110 | .uid = UINT_MAX, |
| 111 | .uses_mmap = true, |
| 112 | }, |
| 113 | .freq = 0, |
| 114 | .mmap_pages = 256, |
| 115 | .default_interval = 1, |
| 116 | }; |
| 117 | |
| 118 | char pid[16]; |
| 119 | char sbuf[STRERR_BUFSIZE]; |
| 120 | struct perf_evlist *evlist; |
| 121 | int i, ret = TEST_FAIL, err = 0, count = 0; |
| 122 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 123 | struct parse_events_state parse_state; |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 124 | struct parse_events_error parse_error; |
| 125 | |
| 126 | bzero(&parse_error, sizeof(parse_error)); |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 127 | bzero(&parse_state, sizeof(parse_state)); |
| 128 | parse_state.error = &parse_error; |
| 129 | INIT_LIST_HEAD(&parse_state.list); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 130 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 131 | err = parse_events_load_bpf_obj(&parse_state, &parse_state.list, obj, NULL); |
| 132 | if (err || list_empty(&parse_state.list)) { |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 133 | pr_debug("Failed to add events selected by BPF\n"); |
Wang Nan | ad0dd7a | 2015-11-17 08:32:46 +0000 | [diff] [blame] | 134 | return TEST_FAIL; |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | snprintf(pid, sizeof(pid), "%d", getpid()); |
| 138 | pid[sizeof(pid) - 1] = '\0'; |
| 139 | opts.target.tid = opts.target.pid = pid; |
| 140 | |
| 141 | /* Instead of perf_evlist__new_default, don't add default events */ |
| 142 | evlist = perf_evlist__new(); |
| 143 | if (!evlist) { |
Alexander Alemayhu | 042cfb5 | 2016-10-13 18:18:11 +0200 | [diff] [blame] | 144 | pr_debug("Not enough memory to create evlist\n"); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 145 | return TEST_FAIL; |
| 146 | } |
| 147 | |
| 148 | err = perf_evlist__create_maps(evlist, &opts.target); |
| 149 | if (err < 0) { |
| 150 | pr_debug("Not enough memory to create thread/cpu maps\n"); |
| 151 | goto out_delete_evlist; |
| 152 | } |
| 153 | |
Arnaldo Carvalho de Melo | 5d9cdc1 | 2017-08-17 16:13:34 -0300 | [diff] [blame] | 154 | perf_evlist__splice_list_tail(evlist, &parse_state.list); |
| 155 | evlist->nr_groups = parse_state.nr_groups; |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 156 | |
Arnaldo Carvalho de Melo | e68ae9c | 2016-04-11 18:15:29 -0300 | [diff] [blame] | 157 | perf_evlist__config(evlist, &opts, NULL); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 158 | |
| 159 | err = perf_evlist__open(evlist); |
| 160 | if (err < 0) { |
| 161 | pr_debug("perf_evlist__open: %s\n", |
Arnaldo Carvalho de Melo | c8b5f2c | 2016-07-06 11:56:20 -0300 | [diff] [blame] | 162 | str_error_r(errno, sbuf, sizeof(sbuf))); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 163 | goto out_delete_evlist; |
| 164 | } |
| 165 | |
Wang Nan | f74b9d3a | 2017-12-03 02:00:37 +0000 | [diff] [blame] | 166 | err = perf_evlist__mmap(evlist, opts.mmap_pages); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 167 | if (err < 0) { |
| 168 | pr_debug("perf_evlist__mmap: %s\n", |
Arnaldo Carvalho de Melo | c8b5f2c | 2016-07-06 11:56:20 -0300 | [diff] [blame] | 169 | str_error_r(errno, sbuf, sizeof(sbuf))); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 170 | goto out_delete_evlist; |
| 171 | } |
| 172 | |
| 173 | perf_evlist__enable(evlist); |
| 174 | (*func)(); |
| 175 | perf_evlist__disable(evlist); |
| 176 | |
| 177 | for (i = 0; i < evlist->nr_mmaps; i++) { |
| 178 | union perf_event *event; |
Kan Liang | 2f54f3a | 2018-03-01 18:09:01 -0500 | [diff] [blame] | 179 | struct perf_mmap *md; |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 180 | |
Kan Liang | 2f54f3a | 2018-03-01 18:09:01 -0500 | [diff] [blame] | 181 | md = &evlist->mmap[i]; |
Kan Liang | b9bae2c | 2018-03-06 10:36:07 -0500 | [diff] [blame] | 182 | if (perf_mmap__read_init(md) < 0) |
Kan Liang | 2f54f3a | 2018-03-01 18:09:01 -0500 | [diff] [blame] | 183 | continue; |
| 184 | |
Kan Liang | 0019dc87 | 2018-03-06 10:36:06 -0500 | [diff] [blame] | 185 | while ((event = perf_mmap__read_event(md)) != NULL) { |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 186 | const u32 type = event->header.type; |
| 187 | |
| 188 | if (type == PERF_RECORD_SAMPLE) |
| 189 | count ++; |
| 190 | } |
Kan Liang | 2f54f3a | 2018-03-01 18:09:01 -0500 | [diff] [blame] | 191 | perf_mmap__read_done(md); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Wang Nan | ad0dd7a | 2015-11-17 08:32:46 +0000 | [diff] [blame] | 194 | if (count != expect) { |
Arnaldo Carvalho de Melo | 6703c97 | 2018-01-02 14:59:21 -0300 | [diff] [blame] | 195 | pr_debug("BPF filter result incorrect, expected %d, got %d samples\n", expect, count); |
Wang Nan | ad0dd7a | 2015-11-17 08:32:46 +0000 | [diff] [blame] | 196 | goto out_delete_evlist; |
| 197 | } |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 198 | |
| 199 | ret = TEST_OK; |
| 200 | |
| 201 | out_delete_evlist: |
| 202 | perf_evlist__delete(evlist); |
| 203 | return ret; |
| 204 | } |
| 205 | |
| 206 | static struct bpf_object * |
| 207 | prepare_bpf(void *obj_buf, size_t obj_buf_sz, const char *name) |
| 208 | { |
| 209 | struct bpf_object *obj; |
| 210 | |
| 211 | obj = bpf__prepare_load_buffer(obj_buf, obj_buf_sz, name); |
| 212 | if (IS_ERR(obj)) { |
| 213 | pr_debug("Compile BPF program failed.\n"); |
| 214 | return NULL; |
| 215 | } |
| 216 | return obj; |
| 217 | } |
| 218 | |
Arnaldo Carvalho de Melo | 916d409 | 2015-11-18 17:38:49 -0300 | [diff] [blame] | 219 | static int __test__bpf(int idx) |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 220 | { |
| 221 | int ret; |
| 222 | void *obj_buf; |
| 223 | size_t obj_buf_sz; |
| 224 | struct bpf_object *obj; |
| 225 | |
| 226 | ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz, |
Arnaldo Carvalho de Melo | 916d409 | 2015-11-18 17:38:49 -0300 | [diff] [blame] | 227 | bpf_testcase_table[idx].prog_id, |
Wang Nan | 7b6982c | 2016-01-25 09:55:48 +0000 | [diff] [blame] | 228 | true, NULL); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 229 | if (ret != TEST_OK || !obj_buf || !obj_buf_sz) { |
| 230 | pr_debug("Unable to get BPF object, %s\n", |
Arnaldo Carvalho de Melo | 916d409 | 2015-11-18 17:38:49 -0300 | [diff] [blame] | 231 | bpf_testcase_table[idx].msg_compile_fail); |
| 232 | if (idx == 0) |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 233 | return TEST_SKIP; |
| 234 | else |
| 235 | return TEST_FAIL; |
| 236 | } |
| 237 | |
| 238 | obj = prepare_bpf(obj_buf, obj_buf_sz, |
Arnaldo Carvalho de Melo | 916d409 | 2015-11-18 17:38:49 -0300 | [diff] [blame] | 239 | bpf_testcase_table[idx].name); |
Wang Nan | 7b6982c | 2016-01-25 09:55:48 +0000 | [diff] [blame] | 240 | if ((!!bpf_testcase_table[idx].target_func) != (!!obj)) { |
| 241 | if (!obj) |
| 242 | pr_debug("Fail to load BPF object: %s\n", |
| 243 | bpf_testcase_table[idx].msg_load_fail); |
| 244 | else |
| 245 | pr_debug("Success unexpectedly: %s\n", |
| 246 | bpf_testcase_table[idx].msg_load_fail); |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 247 | ret = TEST_FAIL; |
| 248 | goto out; |
| 249 | } |
| 250 | |
Joe Stringer | a263053 | 2017-01-26 13:20:01 -0800 | [diff] [blame] | 251 | if (obj) { |
Wang Nan | 7b6982c | 2016-01-25 09:55:48 +0000 | [diff] [blame] | 252 | ret = do_test(obj, |
| 253 | bpf_testcase_table[idx].target_func, |
| 254 | bpf_testcase_table[idx].expect_result); |
Joe Stringer | a263053 | 2017-01-26 13:20:01 -0800 | [diff] [blame] | 255 | if (ret != TEST_OK) |
| 256 | goto out; |
| 257 | if (bpf_testcase_table[idx].pin) { |
| 258 | int err; |
| 259 | |
| 260 | if (!bpf_fs__mount()) { |
| 261 | pr_debug("BPF filesystem not mounted\n"); |
| 262 | ret = TEST_FAIL; |
| 263 | goto out; |
| 264 | } |
| 265 | err = mkdir(PERF_TEST_BPF_PATH, 0777); |
| 266 | if (err && errno != EEXIST) { |
| 267 | pr_debug("Failed to make perf_test dir: %s\n", |
| 268 | strerror(errno)); |
| 269 | ret = TEST_FAIL; |
| 270 | goto out; |
| 271 | } |
| 272 | if (bpf_object__pin(obj, PERF_TEST_BPF_PATH)) |
| 273 | ret = TEST_FAIL; |
| 274 | if (rm_rf(PERF_TEST_BPF_PATH)) |
| 275 | ret = TEST_FAIL; |
| 276 | } |
| 277 | } |
| 278 | |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 279 | out: |
| 280 | bpf__clear(); |
| 281 | return ret; |
| 282 | } |
| 283 | |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 284 | int test__bpf_subtest_get_nr(void) |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 285 | { |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 286 | return (int)ARRAY_SIZE(bpf_testcase_table); |
| 287 | } |
| 288 | |
| 289 | const char *test__bpf_subtest_get_desc(int i) |
| 290 | { |
| 291 | if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table)) |
| 292 | return NULL; |
| 293 | return bpf_testcase_table[i].desc; |
| 294 | } |
| 295 | |
Wang Nan | 6a7d550 | 2016-01-25 09:55:53 +0000 | [diff] [blame] | 296 | static int check_env(void) |
| 297 | { |
| 298 | int err; |
| 299 | unsigned int kver_int; |
| 300 | char license[] = "GPL"; |
| 301 | |
| 302 | struct bpf_insn insns[] = { |
| 303 | BPF_MOV64_IMM(BPF_REG_0, 1), |
| 304 | BPF_EXIT_INSN(), |
| 305 | }; |
| 306 | |
| 307 | err = fetch_kernel_version(&kver_int, NULL, 0); |
| 308 | if (err) { |
| 309 | pr_debug("Unable to get kernel version\n"); |
| 310 | return err; |
| 311 | } |
| 312 | |
| 313 | err = bpf_load_program(BPF_PROG_TYPE_KPROBE, insns, |
| 314 | sizeof(insns) / sizeof(insns[0]), |
| 315 | license, kver_int, NULL, 0); |
| 316 | if (err < 0) { |
| 317 | pr_err("Missing basic BPF support, skip this test: %s\n", |
| 318 | strerror(errno)); |
| 319 | return err; |
| 320 | } |
| 321 | close(err); |
| 322 | |
| 323 | return 0; |
| 324 | } |
| 325 | |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 326 | int test__bpf(struct test *test __maybe_unused, int i) |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 327 | { |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 328 | int err; |
| 329 | |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 330 | if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table)) |
| 331 | return TEST_FAIL; |
| 332 | |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 333 | if (geteuid() != 0) { |
| 334 | pr_debug("Only root can run BPF test\n"); |
| 335 | return TEST_SKIP; |
| 336 | } |
| 337 | |
Wang Nan | 6a7d550 | 2016-01-25 09:55:53 +0000 | [diff] [blame] | 338 | if (check_env()) |
| 339 | return TEST_SKIP; |
| 340 | |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 341 | err = __test__bpf(i); |
| 342 | return err; |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | #else |
Wang Nan | 77a0cf6 | 2015-11-17 08:32:49 +0000 | [diff] [blame] | 346 | int test__bpf_subtest_get_nr(void) |
| 347 | { |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | const char *test__bpf_subtest_get_desc(int i __maybe_unused) |
| 352 | { |
| 353 | return NULL; |
| 354 | } |
| 355 | |
Arnaldo Carvalho de Melo | 81f17c9 | 2017-08-03 15:16:31 -0300 | [diff] [blame] | 356 | int test__bpf(struct test *test __maybe_unused, int i __maybe_unused) |
Wang Nan | ba1fae4 | 2015-11-06 13:49:43 +0000 | [diff] [blame] | 357 | { |
| 358 | pr_debug("Skip BPF test because BPF support is not compiled\n"); |
| 359 | return TEST_SKIP; |
| 360 | } |
| 361 | #endif |