diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-11-26 08:03:34 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-12-05 19:51:43 +0100 |
commit | 00b86691c77c6576861b82a3cfe4d609800758fe (patch) | |
tree | 50161d349254c75fb8707c370c96cd8a205f3e9c /tools/perf/tests | |
parent | perf build: Add clang and llvm compile and linking support (diff) | |
download | linux-00b86691c77c6576861b82a3cfe4d609800758fe.tar.xz linux-00b86691c77c6576861b82a3cfe4d609800758fe.zip |
perf clang: Add builtin clang support ant test case
Add basic clang support in clang.cpp and test__clang() testcase. The
first testcase checks if builtin clang is able to generate LLVM IR.
tests/clang.c is a proxy. Real testcase resides in
utils/c++/clang-test.cpp in c++ and exports C interface to perf test
subsystem.
Test result:
$ perf test -v clang
51: builtin clang support :
51.1: Test builtin clang compile C source to IR :
--- start ---
test child forked, pid 13215
test child finished with 0
---- end ----
Test builtin clang support subtest 0: Ok
Committer note:
Make sure you've enabled CLANG and LLVM builtin support by setting
the LIBCLANGLLVM variable on the make command line, e.g.:
make LIBCLANGLLVM=1 O=/tmp/build/perf -C tools/perf install-bin
Otherwise you'll get this when trying to do the 'perf test' call above:
# perf test clang
51: builtin clang support : Skip (not compiled in)
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Stringer <joe@ovn.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/20161126070354.141764-11-wangnan0@huawei.com
[ Removed "Test" from descriptions, redundant and already removed from all the other entries ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/Build | 1 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 9 | ||||
-rw-r--r-- | tools/perf/tests/clang.c | 42 | ||||
-rw-r--r-- | tools/perf/tests/tests.h | 3 |
4 files changed, 55 insertions, 0 deletions
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index af3ec94869aa..6676c2dd6dcb 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -43,6 +43,7 @@ perf-y += sdt.o perf-y += is_printable_array.o perf-y += bitmap.o perf-y += perf-hooks.o +perf-y += clang.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index d1bec0444be7..23605202d4a1 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -234,6 +234,15 @@ static struct test generic_tests[] = { .func = test__perf_hooks, }, { + .desc = "builtin clang support", + .func = test__clang, + .subtest = { + .skip_if_fail = true, + .get_nr = test__clang_subtest_get_nr, + .get_desc = test__clang_subtest_get_desc, + } + }, + { .func = NULL, }, }; diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c new file mode 100644 index 000000000000..636d6d0e9037 --- /dev/null +++ b/tools/perf/tests/clang.c @@ -0,0 +1,42 @@ +#include "tests.h" +#include "debug.h" +#include "util.h" +#include "c++/clang-c.h" + +static struct { + int (*func)(void); + const char *desc; +} clang_testcase_table[] = { +#ifdef HAVE_LIBCLANGLLVM_SUPPORT + { + .func = test__clang_to_IR, + .desc = "builtin clang compile C source to IR", + }, +#endif +}; + +int test__clang_subtest_get_nr(void) +{ + return (int)ARRAY_SIZE(clang_testcase_table); +} + +const char *test__clang_subtest_get_desc(int i) +{ + if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) + return NULL; + return clang_testcase_table[i].desc; +} + +#ifndef HAVE_LIBCLANGLLVM_SUPPORT +int test__clang(int i __maybe_unused) +{ + return TEST_SKIP; +} +#else +int test__clang(int i __maybe_unused) +{ + if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) + return TEST_FAIL; + return clang_testcase_table[i].func(); +} +#endif diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 3a1f98f291ba..0d7b251305af 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -92,6 +92,9 @@ int test__sdt_event(int subtest); int test__is_printable_array(int subtest); int test__bitmap_print(int subtest); int test__perf_hooks(int subtest); +int test__clang(int subtest); +const char *test__clang_subtest_get_desc(int subtest); +int test__clang_subtest_get_nr(void); #if defined(__arm__) || defined(__aarch64__) #ifdef HAVE_DWARF_UNWIND_SUPPORT |