18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#include "tests.h"
38c2ecf20Sopenharmony_ci#include "c++/clang-c.h"
48c2ecf20Sopenharmony_ci#include <linux/kernel.h>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_cistatic struct {
78c2ecf20Sopenharmony_ci	int (*func)(void);
88c2ecf20Sopenharmony_ci	const char *desc;
98c2ecf20Sopenharmony_ci} clang_testcase_table[] = {
108c2ecf20Sopenharmony_ci#ifdef HAVE_LIBCLANGLLVM_SUPPORT
118c2ecf20Sopenharmony_ci	{
128c2ecf20Sopenharmony_ci		.func = test__clang_to_IR,
138c2ecf20Sopenharmony_ci		.desc = "builtin clang compile C source to IR",
148c2ecf20Sopenharmony_ci	},
158c2ecf20Sopenharmony_ci	{
168c2ecf20Sopenharmony_ci		.func = test__clang_to_obj,
178c2ecf20Sopenharmony_ci		.desc = "builtin clang compile C source to ELF object",
188c2ecf20Sopenharmony_ci	},
198c2ecf20Sopenharmony_ci#endif
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciint test__clang_subtest_get_nr(void)
238c2ecf20Sopenharmony_ci{
248c2ecf20Sopenharmony_ci	return (int)ARRAY_SIZE(clang_testcase_table);
258c2ecf20Sopenharmony_ci}
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciconst char *test__clang_subtest_get_desc(int i)
288c2ecf20Sopenharmony_ci{
298c2ecf20Sopenharmony_ci	if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
308c2ecf20Sopenharmony_ci		return NULL;
318c2ecf20Sopenharmony_ci	return clang_testcase_table[i].desc;
328c2ecf20Sopenharmony_ci}
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#ifndef HAVE_LIBCLANGLLVM_SUPPORT
358c2ecf20Sopenharmony_ciint test__clang(struct test *test __maybe_unused, int i __maybe_unused)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	return TEST_SKIP;
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci#else
408c2ecf20Sopenharmony_ciint test__clang(struct test *test __maybe_unused, int i)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
438c2ecf20Sopenharmony_ci		return TEST_FAIL;
448c2ecf20Sopenharmony_ci	return clang_testcase_table[i].func();
458c2ecf20Sopenharmony_ci}
468c2ecf20Sopenharmony_ci#endif
47