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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/test/proctest.c b/kernel/test/proctest.c
index f49da72..ab69512 100644
--- a/kernel/test/proctest.c
+++ b/kernel/test/proctest.c
@@ -277,10 +277,17 @@ void test_out_of_order_termination()
/*
Test threads' cancellation fields.
*/
+void *did_run_func(long arg1, void *arg2)
+{
+ // arg2 is a boolean flag that indicated this ran
+ *(int *)arg2 = 1;
+ return NULL;
+}
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);
+ int did_run = 0;
+ kthread_t *new_kthread1 = kthread_create(new_proc1, did_run_func, new_proc1->p_pid, (void *)&did_run);
test_assert(new_kthread1->kt_cancelled == 0, "Thread should not be cancelled");
sched_make_runnable(new_kthread1);
@@ -293,6 +300,7 @@ void test_cancellation()
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");
+ test_assert(did_run == 0, "Thread should not have run if it was cancelled");
}