Loading...
1// SPDX-License-Identifier: GPL-2.0
2#include "tests.h"
3#include "c++/clang-c.h"
4#include <linux/kernel.h>
5
6static 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 },
15 {
16 .func = test__clang_to_obj,
17 .desc = "builtin clang compile C source to ELF object",
18 },
19#endif
20};
21
22int test__clang_subtest_get_nr(void)
23{
24 return (int)ARRAY_SIZE(clang_testcase_table);
25}
26
27const 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
35int test__clang(struct test *test __maybe_unused, int i __maybe_unused)
36{
37 return TEST_SKIP;
38}
39#else
40int test__clang(struct test *test __maybe_unused, int i)
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
1// SPDX-License-Identifier: GPL-2.0
2#include "tests.h"
3#include "c++/clang-c.h"
4#include <linux/kernel.h>
5
6#ifndef HAVE_LIBCLANGLLVM_SUPPORT
7static int test__clang_to_IR(struct test_suite *test __maybe_unused,
8 int subtest __maybe_unused)
9{
10 return TEST_SKIP;
11}
12
13static int test__clang_to_obj(struct test_suite *test __maybe_unused,
14 int subtest __maybe_unused)
15{
16 return TEST_SKIP;
17}
18#endif
19
20static struct test_case clang_tests[] = {
21 TEST_CASE_REASON("builtin clang compile C source to IR", clang_to_IR,
22 "not compiled in"),
23 TEST_CASE_REASON("builtin clang compile C source to ELF object",
24 clang_to_obj,
25 "not compiled in"),
26 { .name = NULL, }
27};
28
29struct test_suite suite__clang = {
30 .desc = "builtin clang support",
31 .test_cases = clang_tests,
32};