diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-11-06 08:49:42 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-06 15:49:50 -0500 |
commit | 7af3f3d55b80cce40ad94b6b8e173dccedaf25e6 (patch) | |
tree | 07c5b8794f085dd6e1dd230604de6d2f327753f7 | |
parent | b31de018a6284a25e0fdfeb028e724f8417ec3b1 (diff) |
perf test: Enhance the LLVM tests: add kbuild test
This patch adds a kbuild testcase to check whether kernel headers can be
correctly found.
For example:
# mv /lib/modules/4.3.0-rc5{,.bak}
# perf test LLVM
38: Test LLVM searching and compiling : Skip
# perf test -v LLVM
...
<stdin>:11:10: fatal error: 'uapi/linux/fs.h' file not found
#include <uapi/linux/fs.h>
^
1 error generated.
ERROR: unable to compile -
Hint: Check error message shown above.
Hint: You can also pre-compile it into .o using:
clang -target bpf -O2 -c -
with proper -I and -D options.
Failed to compile test case: 'Test kbuild searching'
test child finished with -2
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1446817783-86722-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/tests/Build | 9 | ||||
-rw-r--r-- | tools/perf/tests/bpf-script-test-kbuild.c | 21 | ||||
-rw-r--r-- | tools/perf/tests/llvm.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/llvm.h | 2 |
4 files changed, 35 insertions, 1 deletions
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 6c095b3d92a9..a47b21193fb2 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build | |||
@@ -31,7 +31,7 @@ perf-y += sample-parsing.o | |||
31 | perf-y += parse-no-sample-id-all.o | 31 | perf-y += parse-no-sample-id-all.o |
32 | perf-y += kmod-path.o | 32 | perf-y += kmod-path.o |
33 | perf-y += thread-map.o | 33 | perf-y += thread-map.o |
34 | perf-y += llvm.o llvm-src-base.o | 34 | perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o |
35 | perf-y += topology.o | 35 | perf-y += topology.o |
36 | 36 | ||
37 | $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c | 37 | $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c |
@@ -41,6 +41,13 @@ $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c | |||
41 | $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@ | 41 | $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@ |
42 | $(Q)echo ';' >> $@ | 42 | $(Q)echo ';' >> $@ |
43 | 43 | ||
44 | $(OUTPUT)tests/llvm-src-kbuild.c: tests/bpf-script-test-kbuild.c | ||
45 | $(call rule_mkdir) | ||
46 | $(Q)echo '#include <tests/llvm.h>' > $@ | ||
47 | $(Q)echo 'const char test_llvm__bpf_test_kbuild_prog[] =' >> $@ | ||
48 | $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@ | ||
49 | $(Q)echo ';' >> $@ | ||
50 | |||
44 | ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64)) | 51 | ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64)) |
45 | perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o | 52 | perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o |
46 | endif | 53 | endif |
diff --git a/tools/perf/tests/bpf-script-test-kbuild.c b/tools/perf/tests/bpf-script-test-kbuild.c new file mode 100644 index 000000000000..3626924740d8 --- /dev/null +++ b/tools/perf/tests/bpf-script-test-kbuild.c | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * bpf-script-test-kbuild.c | ||
3 | * Test include from kernel header | ||
4 | */ | ||
5 | #ifndef LINUX_VERSION_CODE | ||
6 | # error Need LINUX_VERSION_CODE | ||
7 | # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig' | ||
8 | #endif | ||
9 | #define SEC(NAME) __attribute__((section(NAME), used)) | ||
10 | |||
11 | #include <uapi/linux/fs.h> | ||
12 | #include <uapi/asm/ptrace.h> | ||
13 | |||
14 | SEC("func=vfs_llseek") | ||
15 | int bpf_func__vfs_llseek(void *ctx) | ||
16 | { | ||
17 | return 0; | ||
18 | } | ||
19 | |||
20 | char _license[] SEC("license") = "GPL"; | ||
21 | int _version SEC("version") = LINUX_VERSION_CODE; | ||
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c index 05683c5f183e..bc4cf507cde5 100644 --- a/tools/perf/tests/llvm.c +++ b/tools/perf/tests/llvm.c | |||
@@ -40,6 +40,10 @@ static struct { | |||
40 | .source = test_llvm__bpf_base_prog, | 40 | .source = test_llvm__bpf_base_prog, |
41 | .desc = "Basic BPF llvm compiling test", | 41 | .desc = "Basic BPF llvm compiling test", |
42 | }, | 42 | }, |
43 | [LLVM_TESTCASE_KBUILD] = { | ||
44 | .source = test_llvm__bpf_test_kbuild_prog, | ||
45 | .desc = "Test kbuild searching", | ||
46 | }, | ||
43 | }; | 47 | }; |
44 | 48 | ||
45 | 49 | ||
diff --git a/tools/perf/tests/llvm.h b/tools/perf/tests/llvm.h index bd63cee687b5..d91d8f44efee 100644 --- a/tools/perf/tests/llvm.h +++ b/tools/perf/tests/llvm.h | |||
@@ -5,9 +5,11 @@ | |||
5 | #include <stdbool.h> /* for bool */ | 5 | #include <stdbool.h> /* for bool */ |
6 | 6 | ||
7 | extern const char test_llvm__bpf_base_prog[]; | 7 | extern const char test_llvm__bpf_base_prog[]; |
8 | extern const char test_llvm__bpf_test_kbuild_prog[]; | ||
8 | 9 | ||
9 | enum test_llvm__testcase { | 10 | enum test_llvm__testcase { |
10 | LLVM_TESTCASE_BASE, | 11 | LLVM_TESTCASE_BASE, |
12 | LLVM_TESTCASE_KBUILD, | ||
11 | __LLVM_TESTCASE_MAX, | 13 | __LLVM_TESTCASE_MAX, |
12 | }; | 14 | }; |
13 | 15 | ||