aboutsummaryrefslogtreecommitdiff
path: root/tests/create
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-26 19:54:48 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-26 19:54:48 +0300
commit1b5a553194f47066d60bb1c9475af1f413af8f4a (patch)
tree05991354207a634d8f48d72a4756a26f40483e33 /tests/create
parentf81cad34c0e29384a393bf3aa25dbce3d5962c53 (diff)
downloadkmi-1b5a553194f47066d60bb1c9475af1f413af8f4a.tar.gz
kmi-1b5a553194f47066d60bb1c9475af1f413af8f4a.zip
make sys_create() better + test
Diffstat (limited to 'tests/create')
-rw-r--r--tests/create/init.c41
-rw-r--r--tests/create/source.mk2
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/create/init.c b/tests/create/init.c
new file mode 100644
index 0000000..ca38c22
--- /dev/null
+++ b/tests/create/init.c
@@ -0,0 +1,41 @@
+#include <common/test.h>
+
+static int data = 0;
+
+void callback(id_t tid, int d0, int d1, int d2, int d3)
+{
+ UNUSED(tid);
+ printf("hello from new thread\n");
+ check(d0 == 1, "wrong d0\n");
+ check(d1 == 2, "wrond d1\n");
+ check(d2 == 3, "wrong d2\n");
+ check(d3 == 4, "wrong d3\n");
+ check(data == 16, "wrong data\n");
+
+ printf("returning to old thread\n");
+ sys_swap(1);
+ check(0, "swap to old thread failed\n");
+}
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ UNUSED(pid);
+ UNUSED(tid);
+ UNUSED(d0);
+ UNUSED(d1);
+ UNUSED(d2);
+ UNUSED(d3);
+
+ printf("setting data to non-zero value\n");
+ data = 16;
+
+ printf("creating new thread\n");
+ id_t new_thread = sys_create((uintptr_t)callback, 1, 2, 3, 4);
+ check(new_thread > 0, "create failed\n");
+
+ printf("swapping to new thread\n");
+ enum sys_status r = sys_swap(new_thread);
+ check(r == OK, "swap to new thread failed\n");
+
+ ok();
+}
diff --git a/tests/create/source.mk b/tests/create/source.mk
new file mode 100644
index 0000000..b9f8efe
--- /dev/null
+++ b/tests/create/source.mk
@@ -0,0 +1,2 @@
+DO != ./scripts/gen-prog -n create -p init init.c
+DO != ./scripts/gen-simple -n create -p init