summaryrefslogtreecommitdiff
path: root/src/user/app
diff options
context:
space:
mode:
authordzwdz2022-07-26 23:23:50 +0200
committerdzwdz2022-07-26 23:23:50 +0200
commitc8b55b3fd4924abcdf919458b0d8adb0ec00b0f2 (patch)
tree4afc9ef487f435b79a7eb42cb8bc616c164e64c0 /src/user/app
parent57152f6a03d857118fa82e0a28657d869f4c7110 (diff)
user: break out the shell and tests into separate binaries
Diffstat (limited to 'src/user/app')
-rw-r--r--src/user/app/init/init.c (renamed from src/user/app/init/main.c)13
-rw-r--r--src/user/app/init/shell.h3
-rw-r--r--src/user/app/shell/shell.c (renamed from src/user/app/init/shell.c)13
-rw-r--r--src/user/app/tests/pipe.c (renamed from src/user/app/init/tests/pipe.c)0
-rw-r--r--src/user/app/tests/semaphore.c (renamed from src/user/app/init/tests/semaphore.c)0
-rw-r--r--src/user/app/tests/stress.c (renamed from src/user/app/init/tests/stress.c)0
-rw-r--r--src/user/app/tests/tests.c (renamed from src/user/app/init/tests/main.c)3
-rw-r--r--src/user/app/tests/tests.h (renamed from src/user/app/init/tests/tests.h)0
8 files changed, 8 insertions, 24 deletions
diff --git a/src/user/app/init/main.c b/src/user/app/init/init.c
index 4637703..0e90d1f 100644
--- a/src/user/app/init/main.c
+++ b/src/user/app/init/init.c
@@ -1,19 +1,14 @@
#include "driver/driver.h"
-#include "shell.h"
#include <camellia/flags.h>
#include <camellia/syscalls.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
-#include <user/lib/elfload.h>
#include <user/lib/fs/misc.h>
-__attribute__((visibility("hidden")))
-extern char _image_base[];
-
int main(void) {
freopen("/kdev/com1", "a+", stdout);
- printf("in init (stage 2), loaded at 0x%x\n", &_image_base);
+ printf("in init (stage 2), main at 0x%x\n", &main);
MOUNT("/tmp/", tmpfs_drv());
MOUNT("/keyboard", ps2_drv());
@@ -47,8 +42,7 @@ int main(void) {
exit(1);
}
termcook();
-
- shell_loop();
+ execv("/bin/shell", NULL);
exit(1);
}
@@ -62,8 +56,7 @@ int main(void) {
exit(1);
}
termcook();
-
- shell_loop();
+ execv("/bin/shell", NULL);
exit(1);
}
diff --git a/src/user/app/init/shell.h b/src/user/app/init/shell.h
deleted file mode 100644
index fb27410..0000000
--- a/src/user/app/init/shell.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-void shell_loop(void);
diff --git a/src/user/app/init/shell.c b/src/user/app/shell/shell.c
index a6b9965..9c51aeb 100644
--- a/src/user/app/init/shell.c
+++ b/src/user/app/shell/shell.c
@@ -1,5 +1,3 @@
-#include "shell.h"
-#include "tests/tests.h"
#include <camellia/syscalls.h>
#include <errno.h>
#include <stdbool.h>
@@ -127,7 +125,7 @@ static void cmd_touch(const char *args) {
close(fd);
}
-void shell_loop(void) {
+int main(void) {
static char buf[256];
int level = 0;
char *cmd, *args, *redir;
@@ -137,7 +135,7 @@ void shell_loop(void) {
readline(buf, 256);
if (feof(stdin))
- exit(0);
+ return 0;
cmd = strtrim(buf);
if (!*cmd) continue;
@@ -151,8 +149,7 @@ void shell_loop(void) {
_syscall_mount(-1, args, strlen(args));
continue;
} else if (!strcmp(cmd, "exit")) {
- exit(0);
- continue;
+ return 0;
} else if (!strcmp(cmd, "fork")) {
if (!fork()) level++;
else _syscall_await();
@@ -185,10 +182,6 @@ void shell_loop(void) {
}
} else if (!strcmp(cmd, "touch")) {
cmd_touch(args);
- } else if (!strcmp(cmd, "run_tests")) {
- test_all();
- } else if (!strcmp(cmd, "stress")) {
- stress_all();
} else {
char *binname = cmd;
if (*cmd != '/') {
diff --git a/src/user/app/init/tests/pipe.c b/src/user/app/tests/pipe.c
index d6e954a..d6e954a 100644
--- a/src/user/app/init/tests/pipe.c
+++ b/src/user/app/tests/pipe.c
diff --git a/src/user/app/init/tests/semaphore.c b/src/user/app/tests/semaphore.c
index e05f2f9..e05f2f9 100644
--- a/src/user/app/init/tests/semaphore.c
+++ b/src/user/app/tests/semaphore.c
diff --git a/src/user/app/init/tests/stress.c b/src/user/app/tests/stress.c
index 9be88d7..9be88d7 100644
--- a/src/user/app/init/tests/stress.c
+++ b/src/user/app/tests/stress.c
diff --git a/src/user/app/init/tests/main.c b/src/user/app/tests/tests.c
index 7036965..458f748 100644
--- a/src/user/app/init/tests/main.c
+++ b/src/user/app/tests/tests.c
@@ -242,7 +242,7 @@ static void test_misc(void) {
}
-void test_all(void) {
+int main(void) {
run_forked(test_await);
run_forked(test_faults);
run_forked(test_interrupted_fs);
@@ -255,4 +255,5 @@ void test_all(void) {
run_forked(test_efault);
run_forked(test_execbuf);
run_forked(test_misc);
+ return 1;
}
diff --git a/src/user/app/init/tests/tests.h b/src/user/app/tests/tests.h
index 39294eb..39294eb 100644
--- a/src/user/app/init/tests/tests.h
+++ b/src/user/app/tests/tests.h