summaryrefslogtreecommitdiff
path: root/src/user/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app')
-rw-r--r--src/user/app/ext2fs/main.c1
-rw-r--r--src/user/app/init/init.c1
-rw-r--r--src/user/app/tests/kernel/fs.c40
3 files changed, 40 insertions, 2 deletions
diff --git a/src/user/app/ext2fs/main.c b/src/user/app/ext2fs/main.c
index b4a4702..f6d65cc 100644
--- a/src/user/app/ext2fs/main.c
+++ b/src/user/app/ext2fs/main.c
@@ -230,6 +230,7 @@ main(int argc, char **argv)
break;
}
}
+ warnx("cleaning up");
return 1;
}
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c
index 0af0150..350d9a0 100644
--- a/src/user/app/init/init.c
+++ b/src/user/app/init/init.c
@@ -29,6 +29,7 @@ void redirect(const char *exe, const char *out, const char *in) {
exit(1);
}
_syscall_await();
+ _syscall_filicide();
}
}
}
diff --git a/src/user/app/tests/kernel/fs.c b/src/user/app/tests/kernel/fs.c
index ea8a827..6669c41 100644
--- a/src/user/app/tests/kernel/fs.c
+++ b/src/user/app/tests/kernel/fs.c
@@ -1,8 +1,8 @@
-// TODO test it working too...
-
#include "../tests.h"
#include <camellia/flags.h>
#include <camellia/syscalls.h>
+#include <stdbool.h>
+#include <string.h>
static void test_unfinished_req(void) {
handle_t h = -1;
@@ -37,7 +37,43 @@ static void test_orphaned_fs(void) {
}
}
+static void test_fs_cleanup(void) {
+ const char *msg = "success";
+ int msglen = 8;
+ char buf[16];
+ handle_t ends[2];
+ test(_syscall_pipe(ends, 0) >= 0);
+ if (!_syscall_fork(0, NULL)) {
+ handle_t h = -1;
+ if (_syscall_fork(FORK_NEWFS, &h) == 0) {
+ for (;;) {
+ struct ufs_request req;
+ handle_t reqh = _syscall_fs_wait(buf, sizeof buf, &req);
+ if (reqh < 0) break;
+ _syscall_fs_respond(reqh, NULL, 0, 0); /* success */
+ }
+ /* this is the test: does it break out of the loop
+ * when it should cleanup */
+ _syscall_write(ends[1], msg, msglen, -1, 0);
+ exit(0);
+ } else {
+ test(_syscall_mount(h, "/", 1) == 0);
+ h = _syscall_open("/", 1, 0);
+ test(h >= 0);
+ _syscall_close(h);
+ // TODO another test without the delay
+ _syscall_sleep(0);
+ exit(0);
+ }
+ } else {
+ test(_syscall_read(ends[0], buf, sizeof buf, 0) == msglen);
+ test(memcmp(buf, msg, msglen) == 0);
+ }
+}
+
void r_k_fs(void) {
run_test(test_unfinished_req);
run_test(test_orphaned_fs);
+ run_test(test_fs_cleanup);
+ run_test(test_fs_cleanup);
}