summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordzwdz2021-10-15 18:43:21 +0200
committerdzwdz2021-10-15 18:43:21 +0200
commite9ae64908cb116174d2d18be3d727d988e96108b (patch)
treed7064ac13509eae75071653d340c3e5e9bc75c9a /src
parent42bf65918f96d43e9ce8a7287a9508f44fe670d5 (diff)
init: only run tests when prompted from the shell
Diffstat (limited to 'src')
-rw-r--r--src/init/main.c2
-rw-r--r--src/init/shell.c3
-rw-r--r--src/init/tests/main.c5
-rw-r--r--src/init/tests/main.h2
4 files changed, 10 insertions, 2 deletions
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 <init/shell.h>
#include <init/stdlib.h>
+#include <init/tests/main.h>
#include <shared/syscalls.h>
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);