Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/lkl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ core-y += arch/lkl/drivers/
configh-y = printf "/* this header is autogenerated */\n"
configh-$(CONFIG_64BIT) += && printf '\#define LKL_CONFIG_64BIT 1\n'
configh-$(CONFIG_CPU_BIG_ENDIAN) += && printf '\#define LKL_CONFIG_CPU_BIG_ENDIAN 1\n'
configh-$(CONFIG_KASAN_KUNIT_TEST) += && printf '\#define LKL_CONFIG_KASAN_KUNIT_TEST 1\n'

quiet_cmd_gen_configh = GEN $@
cmd_gen_configh = mkdir -p $(dir $@); ($(configh-y)) > $@
Expand Down
2 changes: 0 additions & 2 deletions tools/lkl/Makefile.autoconf
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ define nt_host
endef

define kasan_test_enable
$(call set_autoconf_var,KASAN_TEST,y)
$(call set_kernel_config,KUNIT,y)
$(call set_kernel_config,BUILTIN_CMDLINE,\"kunit.filter_glob=\")
$(call set_kernel_config,KASAN_KUNIT_TEST,y)
endef

define kasan_enable
$(call set_autoconf_var,KASAN,y)
$(call set_kernel_config,KASAN,y)
$(if $(filter yes,$(kasan_test)), $(call kasan_test_enable))
endef
Expand Down
3 changes: 3 additions & 0 deletions tools/lkl/lib/hijack/Build
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ liblkl-zpoline-y += hijack.o
liblkl-zpoline-y += init.o
liblkl-zpoline-y += xlate.o
liblkl-zpoline-y += dbg_handler.o

# -std=gnu23/c23 fails due to HOST_CALL (*host_##name)()
CFLAGS_hijack.o += -std=gnu11
22 changes: 13 additions & 9 deletions tools/lkl/tests/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,30 +555,34 @@ static int lkl_test_join(void)

static const char *boot_log;

#ifdef LKL_HOST_CONFIG_KASAN_TEST
#ifdef LKL_CONFIG_KASAN_KUNIT_TEST

#define KASAN_CMD_LINE "kunit.filter_glob=kasan* "

static int lkl_test_kasan(void)
{
char *log = strdup(boot_log);
char *line = NULL;
char c, d;
int p, f, s, t;
int num_lines, result = TEST_FAILURE;

line = strtok(log, "\n");
while (line) {
if (sscanf(line, "[ %*f] ok %*d kasa%c%c", &c, &d) == 1 &&
c == 'n') {
for (num_lines = 0; line; num_lines++) {
if (sscanf(line,
"[ %*f] # kasan: pass:%d fail:%d skip:%d total:%d",
&p, &f, &s, &t) == 4) {
lkl_test_logf("%s", line);
return TEST_SUCCESS;
result = (f == 0 ? TEST_SUCCESS : TEST_FAILURE);
goto out;
}

line = strtok(NULL, "\n");
}

lkl_test_logf("no kasan test output in %d log lines\n", num_lines);
out:
free(log);

return TEST_FAILURE;
return result;
}
#else
#define KASAN_CMD_LINE
Expand Down Expand Up @@ -707,7 +711,7 @@ struct lkl_test tests[] = {
LKL_TEST(semaphore),
LKL_TEST(join),
LKL_TEST(start_kernel),
#ifdef LKL_HOST_CONFIG_KASAN_TEST
#ifdef LKL_CONFIG_KASAN_KUNIT_TEST
LKL_TEST(kasan),
#endif
LKL_TEST(getpid),
Expand Down
2 changes: 1 addition & 1 deletion tools/lkl/tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int lkl_test_run(const struct lkl_test *tests, int nr, const char *fmt, ...)

start = clock();

ret = t->fn(t->arg1, t->arg2, t->arg3);
ret = t->fn();

stop = clock();

Expand Down
8 changes: 3 additions & 5 deletions tools/lkl/tests/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@

struct lkl_test {
const char *name;
int (*fn)();
void *arg1, *arg2, *arg3;
int (*fn)(void);
};

/**
* Simple wrapper to initialize a test entry.
* @name - test name, it assume test function is named test_@name
* @vargs - arguments to be passed to the function
* @name - test name; assume existing test function named lkl_test_@name
*/
#define LKL_TEST(name, ...) { #name, lkl_test_##name, __VA_ARGS__ }
#define LKL_TEST(name) { #name, lkl_test_##name }

/**
* lkl_test_run - run a test suite
Expand Down
Loading