Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
00b86691 WN |
2 | #include "tests.h" |
3 | #include "debug.h" | |
4 | #include "util.h" | |
5 | #include "c++/clang-c.h" | |
877a7a11 | 6 | #include <linux/kernel.h> |
00b86691 WN |
7 | |
8 | static struct { | |
9 | int (*func)(void); | |
10 | const char *desc; | |
11 | } clang_testcase_table[] = { | |
12 | #ifdef HAVE_LIBCLANGLLVM_SUPPORT | |
13 | { | |
14 | .func = test__clang_to_IR, | |
15 | .desc = "builtin clang compile C source to IR", | |
16 | }, | |
5e08a765 WN |
17 | { |
18 | .func = test__clang_to_obj, | |
19 | .desc = "builtin clang compile C source to ELF object", | |
20 | }, | |
00b86691 WN |
21 | #endif |
22 | }; | |
23 | ||
24 | int test__clang_subtest_get_nr(void) | |
25 | { | |
26 | return (int)ARRAY_SIZE(clang_testcase_table); | |
27 | } | |
28 | ||
29 | const char *test__clang_subtest_get_desc(int i) | |
30 | { | |
31 | if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) | |
32 | return NULL; | |
33 | return clang_testcase_table[i].desc; | |
34 | } | |
35 | ||
36 | #ifndef HAVE_LIBCLANGLLVM_SUPPORT | |
81f17c90 | 37 | int test__clang(struct test *test __maybe_unused, int i __maybe_unused) |
00b86691 WN |
38 | { |
39 | return TEST_SKIP; | |
40 | } | |
41 | #else | |
81f17c90 | 42 | int test__clang(struct test *test __maybe_unused, int i) |
00b86691 WN |
43 | { |
44 | if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) | |
45 | return TEST_FAIL; | |
46 | return clang_testcase_table[i].func(); | |
47 | } | |
48 | #endif |