Wang Nan | 00b8669 | 2016-11-26 07:03:34 +0000 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include "debug.h" |
| 3 | #include "util.h" |
| 4 | #include "c++/clang-c.h" |
| 5 | |
| 6 | static struct { |
| 7 | int (*func)(void); |
| 8 | const char *desc; |
| 9 | } clang_testcase_table[] = { |
| 10 | #ifdef HAVE_LIBCLANGLLVM_SUPPORT |
| 11 | { |
| 12 | .func = test__clang_to_IR, |
| 13 | .desc = "builtin clang compile C source to IR", |
| 14 | }, |
Wang Nan | 5e08a76 | 2016-11-26 07:03:38 +0000 | [diff] [blame^] | 15 | { |
| 16 | .func = test__clang_to_obj, |
| 17 | .desc = "builtin clang compile C source to ELF object", |
| 18 | }, |
Wang Nan | 00b8669 | 2016-11-26 07:03:34 +0000 | [diff] [blame] | 19 | #endif |
| 20 | }; |
| 21 | |
| 22 | int test__clang_subtest_get_nr(void) |
| 23 | { |
| 24 | return (int)ARRAY_SIZE(clang_testcase_table); |
| 25 | } |
| 26 | |
| 27 | const char *test__clang_subtest_get_desc(int i) |
| 28 | { |
| 29 | if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) |
| 30 | return NULL; |
| 31 | return clang_testcase_table[i].desc; |
| 32 | } |
| 33 | |
| 34 | #ifndef HAVE_LIBCLANGLLVM_SUPPORT |
| 35 | int test__clang(int i __maybe_unused) |
| 36 | { |
| 37 | return TEST_SKIP; |
| 38 | } |
| 39 | #else |
Wang Nan | 5e08a76 | 2016-11-26 07:03:38 +0000 | [diff] [blame^] | 40 | int test__clang(int i) |
Wang Nan | 00b8669 | 2016-11-26 07:03:34 +0000 | [diff] [blame] | 41 | { |
| 42 | if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) |
| 43 | return TEST_FAIL; |
| 44 | return clang_testcase_table[i].func(); |
| 45 | } |
| 46 | #endif |