aboutsummaryrefslogtreecommitdiff
path: root/tests/fork/init.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-22 15:14:59 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-22 15:14:59 +0300
commita9d61501eb0200576bb08ba4b287f66177253ad9 (patch)
treea903b99b629ee676740c0daef0178651b8cb940f /tests/fork/init.c
parentc3ea570bae8f7daeac8e0614a958e983fcf9940e (diff)
downloadkmi-a9d61501eb0200576bb08ba4b287f66177253ad9.tar.gz
kmi-a9d61501eb0200576bb08ba4b287f66177253ad9.zip
add fork test
Diffstat (limited to 'tests/fork/init.c')
-rw-r--r--tests/fork/init.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/fork/init.c b/tests/fork/init.c
new file mode 100644
index 0000000..c64af93
--- /dev/null
+++ b/tests/fork/init.c
@@ -0,0 +1,27 @@
+#include <common/test.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ UNUSED(pid);
+ UNUSED(tid);
+ UNUSED(d0);
+ UNUSED(d1);
+ UNUSED(d2);
+ UNUSED(d3);
+
+ /** @todo fork until we run out of memory? */
+ check(pid == 0, "illegal pid for init\n");
+ id_t our_id = 0;
+ printf("forking\n");
+ id_t new_id = sys_fork(&our_id);
+ check(new_id >= 0, "error from fork\n");
+
+ if (new_id == 0) {
+ printf("hello from child with pid %ld\n", (long int)our_id);
+ ok();
+ }
+
+ printf("hello from parent\n");
+ sys_swap(new_id);
+ check(0, "failed swapping to child\n");
+}