Skip to content

Commit 46f599b

Browse files
authored
Merge pull request #610 from ddiss/minor_test_changes
lkl: tests: minor fn parameter and kasan parsing changes
2 parents ac5cde6 + bd30a15 commit 46f599b

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

arch/lkl/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ core-y += arch/lkl/drivers/
6868
configh-y = printf "/* this header is autogenerated */\n"
6969
configh-$(CONFIG_64BIT) += && printf '\#define LKL_CONFIG_64BIT 1\n'
7070
configh-$(CONFIG_CPU_BIG_ENDIAN) += && printf '\#define LKL_CONFIG_CPU_BIG_ENDIAN 1\n'
71+
configh-$(CONFIG_KASAN_KUNIT_TEST) += && printf '\#define LKL_CONFIG_KASAN_KUNIT_TEST 1\n'
7172

7273
quiet_cmd_gen_configh = GEN $@
7374
cmd_gen_configh = mkdir -p $(dir $@); ($(configh-y)) > $@

tools/lkl/Makefile.autoconf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,12 @@ define nt_host
111111
endef
112112

113113
define kasan_test_enable
114-
$(call set_autoconf_var,KASAN_TEST,y)
115114
$(call set_kernel_config,KUNIT,y)
116115
$(call set_kernel_config,BUILTIN_CMDLINE,\"kunit.filter_glob=\")
117116
$(call set_kernel_config,KASAN_KUNIT_TEST,y)
118117
endef
119118

120119
define kasan_enable
121-
$(call set_autoconf_var,KASAN,y)
122120
$(call set_kernel_config,KASAN,y)
123121
$(if $(filter yes,$(kasan_test)), $(call kasan_test_enable))
124122
endef

tools/lkl/lib/hijack/Build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ liblkl-zpoline-y += hijack.o
99
liblkl-zpoline-y += init.o
1010
liblkl-zpoline-y += xlate.o
1111
liblkl-zpoline-y += dbg_handler.o
12+
13+
# -std=gnu23/c23 fails due to HOST_CALL (*host_##name)()
14+
CFLAGS_hijack.o += -std=gnu11

tools/lkl/tests/boot.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -555,30 +555,34 @@ static int lkl_test_join(void)
555555

556556
static const char *boot_log;
557557

558-
#ifdef LKL_HOST_CONFIG_KASAN_TEST
558+
#ifdef LKL_CONFIG_KASAN_KUNIT_TEST
559559

560560
#define KASAN_CMD_LINE "kunit.filter_glob=kasan* "
561561

562562
static int lkl_test_kasan(void)
563563
{
564564
char *log = strdup(boot_log);
565565
char *line = NULL;
566-
char c, d;
566+
int p, f, s, t;
567+
int num_lines, result = TEST_FAILURE;
567568

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

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

582+
lkl_test_logf("no kasan test output in %d log lines\n", num_lines);
583+
out:
579584
free(log);
580-
581-
return TEST_FAILURE;
585+
return result;
582586
}
583587
#else
584588
#define KASAN_CMD_LINE
@@ -707,7 +711,7 @@ struct lkl_test tests[] = {
707711
LKL_TEST(semaphore),
708712
LKL_TEST(join),
709713
LKL_TEST(start_kernel),
710-
#ifdef LKL_HOST_CONFIG_KASAN_TEST
714+
#ifdef LKL_CONFIG_KASAN_KUNIT_TEST
711715
LKL_TEST(kasan),
712716
#endif
713717
LKL_TEST(getpid),

tools/lkl/tests/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int lkl_test_run(const struct lkl_test *tests, int nr, const char *fmt, ...)
9090

9191
start = clock();
9292

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

9595
stop = clock();
9696

tools/lkl/tests/test.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99

1010
struct lkl_test {
1111
const char *name;
12-
int (*fn)();
13-
void *arg1, *arg2, *arg3;
12+
int (*fn)(void);
1413
};
1514

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

2321
/**
2422
* lkl_test_run - run a test suite

0 commit comments

Comments
 (0)