summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordzwdz2021-09-21 17:20:25 +0200
committerdzwdz2021-09-21 17:20:25 +0200
commit4e915aabfc68eb43f71010f7856d486e0164ce56 (patch)
treea6b1cec8a5587a98be998861552eeb7dcfcbd108 /src
parentc7cdfb06c96d4db0649a3565873fda8a10d11ac2 (diff)
`init`: add a test for await()
Diffstat (limited to 'src')
-rw-r--r--src/init/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/init/main.c b/src/init/main.c
index 1e2d16f..558fb77 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -14,6 +14,7 @@ int tty_fd;
void read_file(const char *path, size_t len);
void fs_test(void);
+void test_await(void);
__attribute__((section(".text.startup")))
int main(void) {
@@ -25,6 +26,7 @@ int main(void) {
_syscall_exit(argify("couldn't open tty"));
fs_test();
+ test_await();
_syscall_exit(argify("my job here is done."));
}
@@ -74,3 +76,20 @@ void fs_test(void) {
log("\n");
}
+
+void test_await(void) {
+ char buf[16];
+ int len;
+ // the child immediately dies
+ if (!_syscall_fork())
+ _syscall_exit(argify("i'm dead"));
+
+ len = _syscall_await(buf, 16);
+ if (len < 0) {
+ log("await: negative len\n");
+ } else {
+ log("await returned: ");
+ _syscall_write(tty_fd, buf, len, 0);
+ log("\n");
+ }
+}