aboutsummaryrefslogtreecommitdiff
path: root/kernel/test/proctest.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/test/proctest.c')
-rw-r--r--kernel/test/proctest.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/test/proctest.c b/kernel/test/proctest.c
index 9ab4c65..f49da72 100644
--- a/kernel/test/proctest.c
+++ b/kernel/test/proctest.c
@@ -274,6 +274,28 @@ void test_out_of_order_termination()
}
+/*
+ Test threads' cancellation fields.
+*/
+void test_cancellation()
+{
+ proc_t *new_proc1 = proc_create("proc test 1");
+ kthread_t *new_kthread1 = kthread_create(new_proc1, test_func, new_proc1->p_pid, new_proc1);
+ test_assert(new_kthread1->kt_cancelled == 0, "Thread should not be cancelled");
+ sched_make_runnable(new_kthread1);
+
+ proc_kill(new_proc1, 1);
+
+ test_assert(new_kthread1->kt_cancelled == 1, "Thread should be cancelled");
+
+ // wait for the thread to finish
+ int status;
+ int ret = do_waitpid(new_proc1->p_pid, &status, 0);
+ test_assert(ret != -ECHILD, "Should have found the process");
+ test_assert(status == 1, "Returned status not set correctly");
+}
+
+
long proctest_main(long arg1, void *arg2)
{
dbg(DBG_TEST, "\nStarting Procs tests\n");
@@ -290,6 +312,8 @@ long proctest_main(long arg1, void *arg2)
test_proc_kill_all();
dbg(DBG_TEST, "\nStarting test_out_of_order_termination\n");
test_out_of_order_termination();
+ dbg(DBG_TEST, "\nStarting test_cancellation\n");
+ test_cancellation();
test_fini();
return 0;