diff options
Diffstat (limited to 'tools/perf/tests/bpf.c')
-rw-r--r-- | tools/perf/tests/bpf.c | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 34c22cdf4d5d..e8399beca62b 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <sys/epoll.h> | 3 | #include <sys/epoll.h> |
4 | #include <sys/types.h> | 4 | #include <sys/types.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #include <fcntl.h> | ||
6 | #include <util/util.h> | 7 | #include <util/util.h> |
7 | #include <util/bpf-loader.h> | 8 | #include <util/bpf-loader.h> |
8 | #include <util/evlist.h> | 9 | #include <util/evlist.h> |
@@ -19,13 +20,13 @@ | |||
19 | 20 | ||
20 | #ifdef HAVE_LIBBPF_SUPPORT | 21 | #ifdef HAVE_LIBBPF_SUPPORT |
21 | 22 | ||
22 | static int epoll_wait_loop(void) | 23 | static int epoll_pwait_loop(void) |
23 | { | 24 | { |
24 | int i; | 25 | int i; |
25 | 26 | ||
26 | /* Should fail NR_ITERS times */ | 27 | /* Should fail NR_ITERS times */ |
27 | for (i = 0; i < NR_ITERS; i++) | 28 | for (i = 0; i < NR_ITERS; i++) |
28 | epoll_wait(-(i + 1), NULL, 0, 0); | 29 | epoll_pwait(-(i + 1), NULL, 0, 0, NULL); |
29 | return 0; | 30 | return 0; |
30 | } | 31 | } |
31 | 32 | ||
@@ -63,46 +64,41 @@ static struct { | |||
63 | bool pin; | 64 | bool pin; |
64 | } bpf_testcase_table[] = { | 65 | } bpf_testcase_table[] = { |
65 | { | 66 | { |
66 | LLVM_TESTCASE_BASE, | 67 | .prog_id = LLVM_TESTCASE_BASE, |
67 | "Basic BPF filtering", | 68 | .desc = "Basic BPF filtering", |
68 | "[basic_bpf_test]", | 69 | .name = "[basic_bpf_test]", |
69 | "fix 'perf test LLVM' first", | 70 | .msg_compile_fail = "fix 'perf test LLVM' first", |
70 | "load bpf object failed", | 71 | .msg_load_fail = "load bpf object failed", |
71 | &epoll_wait_loop, | 72 | .target_func = &epoll_pwait_loop, |
72 | (NR_ITERS + 1) / 2, | 73 | .expect_result = (NR_ITERS + 1) / 2, |
73 | false, | ||
74 | }, | 74 | }, |
75 | { | 75 | { |
76 | LLVM_TESTCASE_BASE, | 76 | .prog_id = LLVM_TESTCASE_BASE, |
77 | "BPF pinning", | 77 | .desc = "BPF pinning", |
78 | "[bpf_pinning]", | 78 | .name = "[bpf_pinning]", |
79 | "fix kbuild first", | 79 | .msg_compile_fail = "fix kbuild first", |
80 | "check your vmlinux setting?", | 80 | .msg_load_fail = "check your vmlinux setting?", |
81 | &epoll_wait_loop, | 81 | .target_func = &epoll_pwait_loop, |
82 | (NR_ITERS + 1) / 2, | 82 | .expect_result = (NR_ITERS + 1) / 2, |
83 | true, | 83 | .pin = true, |
84 | }, | 84 | }, |
85 | #ifdef HAVE_BPF_PROLOGUE | 85 | #ifdef HAVE_BPF_PROLOGUE |
86 | { | 86 | { |
87 | LLVM_TESTCASE_BPF_PROLOGUE, | 87 | .prog_id = LLVM_TESTCASE_BPF_PROLOGUE, |
88 | "BPF prologue generation", | 88 | .desc = "BPF prologue generation", |
89 | "[bpf_prologue_test]", | 89 | .name = "[bpf_prologue_test]", |
90 | "fix kbuild first", | 90 | .msg_compile_fail = "fix kbuild first", |
91 | "check your vmlinux setting?", | 91 | .msg_load_fail = "check your vmlinux setting?", |
92 | &llseek_loop, | 92 | .target_func = &llseek_loop, |
93 | (NR_ITERS + 1) / 4, | 93 | .expect_result = (NR_ITERS + 1) / 4, |
94 | false, | ||
95 | }, | 94 | }, |
96 | #endif | 95 | #endif |
97 | { | 96 | { |
98 | LLVM_TESTCASE_BPF_RELOCATION, | 97 | .prog_id = LLVM_TESTCASE_BPF_RELOCATION, |
99 | "BPF relocation checker", | 98 | .desc = "BPF relocation checker", |
100 | "[bpf_relocation_test]", | 99 | .name = "[bpf_relocation_test]", |
101 | "fix 'perf test LLVM' first", | 100 | .msg_compile_fail = "fix 'perf test LLVM' first", |
102 | "libbpf error when dealing with relocation", | 101 | .msg_load_fail = "libbpf error when dealing with relocation", |
103 | NULL, | ||
104 | 0, | ||
105 | false, | ||
106 | }, | 102 | }, |
107 | }; | 103 | }; |
108 | 104 | ||
@@ -167,7 +163,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void), | |||
167 | goto out_delete_evlist; | 163 | goto out_delete_evlist; |
168 | } | 164 | } |
169 | 165 | ||
170 | err = perf_evlist__mmap(evlist, opts.mmap_pages, false); | 166 | err = perf_evlist__mmap(evlist, opts.mmap_pages); |
171 | if (err < 0) { | 167 | if (err < 0) { |
172 | pr_debug("perf_evlist__mmap: %s\n", | 168 | pr_debug("perf_evlist__mmap: %s\n", |
173 | str_error_r(errno, sbuf, sizeof(sbuf))); | 169 | str_error_r(errno, sbuf, sizeof(sbuf))); |
@@ -190,7 +186,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void), | |||
190 | } | 186 | } |
191 | 187 | ||
192 | if (count != expect) { | 188 | if (count != expect) { |
193 | pr_debug("BPF filter result incorrect\n"); | 189 | pr_debug("BPF filter result incorrect, expected %d, got %d samples\n", expect, count); |
194 | goto out_delete_evlist; | 190 | goto out_delete_evlist; |
195 | } | 191 | } |
196 | 192 | ||