Commit 44a8528c authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf test: Convert clang tests to test cases.



Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarSohaib Mohamed <sohaib.amhmd@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: Daniel Latypov <dlatypov@google.com>
Cc: David Gow <davidgow@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20211104064208.3156807-13-irogers@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e47c6eca
Loading
Loading
Loading
Loading
+17 −40
Original line number Original line Diff line number Diff line
@@ -3,54 +3,31 @@
#include "c++/clang-c.h"
#include "c++/clang-c.h"
#include <linux/kernel.h>
#include <linux/kernel.h>


static struct {
	int (*func)(void);
	const char *desc;
} clang_testcase_table[] = {
#ifdef HAVE_LIBCLANGLLVM_SUPPORT
	{
		.func = test__clang_to_IR,
		.desc = "builtin clang compile C source to IR",
	},
	{
		.func = test__clang_to_obj,
		.desc = "builtin clang compile C source to ELF object",
	},
#endif
};

static int test__clang_subtest_get_nr(void)
{
	return (int)ARRAY_SIZE(clang_testcase_table);
}

static const char *test__clang_subtest_get_desc(int i)
{
	if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
		return NULL;
	return clang_testcase_table[i].desc;
}

#ifndef HAVE_LIBCLANGLLVM_SUPPORT
#ifndef HAVE_LIBCLANGLLVM_SUPPORT
static int test__clang(struct test_suite *test __maybe_unused, int i __maybe_unused)
static int test__clang_to_IR(struct test_suite *test __maybe_unused,
			     int subtest __maybe_unused)
{
{
	return TEST_SKIP;
	return TEST_SKIP;
}
}
#else

static int test__clang(struct test_suite *test __maybe_unused, int i)
static int test__clang_to_obj(struct test_suite *test __maybe_unused,
			      int subtest __maybe_unused)
{
{
	if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
	return TEST_SKIP;
		return TEST_FAIL;
	return clang_testcase_table[i].func();
}
}
#endif
#endif


static struct test_case clang_tests[] = {
	TEST_CASE_REASON("builtin clang compile C source to IR", clang_to_IR,
			 "not compiled in"),
	TEST_CASE_REASON("builtin clang compile C source to ELF object",
			 clang_to_obj,
			 "not compiled in"),
	{ .name = NULL, }
};

struct test_suite suite__clang = {
struct test_suite suite__clang = {
	.desc = "builtin clang support",
	.desc = "builtin clang support",
	.func = test__clang,
	.test_cases = clang_tests,
	.subtest = {
	.subtest = { .skip_if_fail = true, },
		.skip_if_fail	= true,
		.get_nr		= test__clang_subtest_get_nr,
		.get_desc	= test__clang_subtest_get_desc,
	}
};
};
+3 −5
Original line number Original line Diff line number Diff line
@@ -12,8 +12,9 @@ extern "C" {
extern void perf_clang__init(void);
extern void perf_clang__init(void);
extern void perf_clang__cleanup(void);
extern void perf_clang__cleanup(void);


extern int test__clang_to_IR(void);
struct test_suite;
extern int test__clang_to_obj(void);
extern int test__clang_to_IR(struct test_suite *test, int subtest);
extern int test__clang_to_obj(struct test_suite *test, int subtest);


extern int perf_clang__compile_bpf(const char *filename,
extern int perf_clang__compile_bpf(const char *filename,
				   void **p_obj_buf,
				   void **p_obj_buf,
@@ -26,9 +27,6 @@ extern int perf_clang__compile_bpf(const char *filename,
static inline void perf_clang__init(void) { }
static inline void perf_clang__init(void) { }
static inline void perf_clang__cleanup(void) { }
static inline void perf_clang__cleanup(void) { }


static inline int test__clang_to_IR(void) { return -1; }
static inline int test__clang_to_obj(void) { return -1;}

static inline int
static inline int
perf_clang__compile_bpf(const char *filename __maybe_unused,
perf_clang__compile_bpf(const char *filename __maybe_unused,
			void **p_obj_buf __maybe_unused,
			void **p_obj_buf __maybe_unused,
+4 −2
Original line number Original line Diff line number Diff line
@@ -35,7 +35,8 @@ __test__clang_to_IR(void)
}
}


extern "C" {
extern "C" {
int test__clang_to_IR(void)
int test__clang_to_IR(struct test_suite *test __maybe_unused,
                      int subtest __maybe_unused)
{
{
	perf_clang_scope _scope;
	perf_clang_scope _scope;


@@ -48,7 +49,8 @@ int test__clang_to_IR(void)
	return -1;
	return -1;
}
}


int test__clang_to_obj(void)
int test__clang_to_obj(struct test_suite *test __maybe_unused,
                       int subtest __maybe_unused)
{
{
	perf_clang_scope _scope;
	perf_clang_scope _scope;