Merge pull request #610 from ddiss/minor_test_changes

lkl: tests: minor fn parameter and kasan parsing changes
This commit is contained in:
Octavian Purdila
2025-07-03 14:53:53 -07:00
committed by GitHub
6 changed files with 21 additions and 17 deletions

View File

@@ -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)) > $@

View File

@@ -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

View File

@@ -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

View File

@@ -555,7 +555,7 @@ 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* "
@@ -563,22 +563,26 @@ 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
@@ -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),

View File

@@ -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();

View File

@@ -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