From e9ae64908cb116174d2d18be3d727d988e96108b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 15 Oct 2021 18:43:21 +0200 Subject: init: only run tests when prompted from the shell --- src/init/main.c | 2 -- src/init/shell.c | 3 +++ src/init/tests/main.c | 5 +++++ src/init/tests/main.h | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/init/main.c b/src/init/main.c index c922a99..73df25b 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -26,8 +26,6 @@ int main(void) { _syscall_exit(1); fs_prep(); - test_fs(); - test_await(); shell_loop(); _syscall_exit(0); diff --git a/src/init/shell.c b/src/init/shell.c index 9510e0d..53ad995 100644 --- a/src/init/shell.c +++ b/src/init/shell.c @@ -1,5 +1,6 @@ #include #include +#include #include static char *split(char *base) { @@ -76,6 +77,8 @@ void shell_loop(void) { if (_syscall_fork()) _syscall_await(); else level++; + } else if (!strcmp(cmd, "run_tests")) { + test_all(); } else { printf("unknown command :(\n"); } diff --git a/src/init/tests/main.c b/src/init/tests/main.c index ed02e5f..3b2d2ce 100644 --- a/src/init/tests/main.c +++ b/src/init/tests/main.c @@ -22,6 +22,11 @@ static void read_file(const char *path, size_t len) { _syscall_close(fd); } +void test_all(void) { + test_fs(); + test_await(); +} + void test_fs(void) { if (!_syscall_fork()) { /* run the "test" in a child process to not affect the fs view of the diff --git a/src/init/tests/main.h b/src/init/tests/main.h index 0c24e03..5525c64 100644 --- a/src/init/tests/main.h +++ b/src/init/tests/main.h @@ -1,4 +1,6 @@ #pragma once +void test_all(void); + void test_fs(void); void test_await(void); -- cgit v1.2.3