diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-11-17 03:32:49 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-19 11:19:16 -0500 |
commit | 77a0cf682f7979554e10a6c605a1fef4f4197654 (patch) | |
tree | 296e26d114caa80dc218db855b575b6edb7da17a /tools | |
parent | e8c6d500447c577e669c24ec04cd4173fe9f9afb (diff) |
perf test: Print result for each BPF subtest
This patch prints each sub-tests results for BPF testcases.
Before:
# ./perf test BPF
37: Test BPF filter : Ok
After:
# ./perf test BPF
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation : Ok
When a failure happens:
# cat ~/.perfconfig
[llvm]
clang-path = "/bin/false"
# ./perf test BPF
37: Test BPF filter :
37.1: Test basic BPF filtering : Skip
37.2: Test BPF prologue generation : Skip
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447749170-175898-5-git-send-email-wangnan0@huawei.com
[ Fixed up not to use .func in an anonymous union ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/tests/bpf.c | 38 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 5 | ||||
-rw-r--r-- | tools/perf/tests/tests.h | 2 |
3 files changed, 35 insertions, 10 deletions
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 4efdc1607754..33689a0cf821 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c | |||
@@ -215,28 +215,46 @@ out: | |||
215 | return ret; | 215 | return ret; |
216 | } | 216 | } |
217 | 217 | ||
218 | int test__bpf(int subtest __maybe_unused) | 218 | int test__bpf_subtest_get_nr(void) |
219 | { | ||
220 | return (int)ARRAY_SIZE(bpf_testcase_table); | ||
221 | } | ||
222 | |||
223 | const char *test__bpf_subtest_get_desc(int i) | ||
224 | { | ||
225 | if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table)) | ||
226 | return NULL; | ||
227 | return bpf_testcase_table[i].desc; | ||
228 | } | ||
229 | |||
230 | int test__bpf(int i) | ||
219 | { | 231 | { |
220 | unsigned int i; | ||
221 | int err; | 232 | int err; |
222 | 233 | ||
234 | if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table)) | ||
235 | return TEST_FAIL; | ||
236 | |||
223 | if (geteuid() != 0) { | 237 | if (geteuid() != 0) { |
224 | pr_debug("Only root can run BPF test\n"); | 238 | pr_debug("Only root can run BPF test\n"); |
225 | return TEST_SKIP; | 239 | return TEST_SKIP; |
226 | } | 240 | } |
227 | 241 | ||
228 | for (i = 0; i < ARRAY_SIZE(bpf_testcase_table); i++) { | 242 | err = __test__bpf(i); |
229 | err = __test__bpf(i); | 243 | return err; |
244 | } | ||
230 | 245 | ||
231 | if (err != TEST_OK) | 246 | #else |
232 | return err; | 247 | int test__bpf_subtest_get_nr(void) |
233 | } | 248 | { |
249 | return 0; | ||
250 | } | ||
234 | 251 | ||
235 | return TEST_OK; | 252 | const char *test__bpf_subtest_get_desc(int i __maybe_unused) |
253 | { | ||
254 | return NULL; | ||
236 | } | 255 | } |
237 | 256 | ||
238 | #else | 257 | int test__bpf(int i __maybe_unused) |
239 | int test__bpf(void) | ||
240 | { | 258 | { |
241 | pr_debug("Skip BPF test because BPF support is not compiled\n"); | 259 | pr_debug("Skip BPF test because BPF support is not compiled\n"); |
242 | return TEST_SKIP; | 260 | return TEST_SKIP; |
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 813660976217..146ae9821c00 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -173,6 +173,11 @@ static struct test generic_tests[] = { | |||
173 | { | 173 | { |
174 | .desc = "Test BPF filter", | 174 | .desc = "Test BPF filter", |
175 | .func = test__bpf, | 175 | .func = test__bpf, |
176 | .subtest = { | ||
177 | .skip_if_fail = true, | ||
178 | .get_nr = test__bpf_subtest_get_nr, | ||
179 | .get_desc = test__bpf_subtest_get_desc, | ||
180 | }, | ||
176 | }, | 181 | }, |
177 | { | 182 | { |
178 | .func = NULL, | 183 | .func = NULL, |
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index f92af527f080..a0733aaad081 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h | |||
@@ -76,6 +76,8 @@ int test__llvm(int subtest); | |||
76 | const char *test__llvm_subtest_get_desc(int subtest); | 76 | const char *test__llvm_subtest_get_desc(int subtest); |
77 | int test__llvm_subtest_get_nr(void); | 77 | int test__llvm_subtest_get_nr(void); |
78 | int test__bpf(int subtest); | 78 | int test__bpf(int subtest); |
79 | const char *test__bpf_subtest_get_desc(int subtest); | ||
80 | int test__bpf_subtest_get_nr(void); | ||
79 | int test_session_topology(int subtest); | 81 | int test_session_topology(int subtest); |
80 | 82 | ||
81 | #if defined(__arm__) || defined(__aarch64__) | 83 | #if defined(__arm__) || defined(__aarch64__) |