From 75c8828d804f45cf8f44af73bfe87e0f3eaf9a9e Mon Sep 17 00:00:00 2001 From: nodist Date: Wed, 11 Nov 2026 14:05:59 -0500 Subject: run a task test --- test/task.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/task.c (limited to 'test') diff --git a/test/task.c b/test/task.c new file mode 100644 index 0000000..8374989 --- /dev/null +++ b/test/task.c @@ -0,0 +1,24 @@ + +#include "kpl_test.h" + +static int32_t run_task_value = 0; + +#define KPL_RUN_TASK_SET_VALUE 1234567 + +void run_task_set_value(kpl_thread *thread, kpl_object_task *object_task) { + run_task_value = KPL_RUN_TASK_SET_VALUE; + kpl_object_task_done(thread, object_task); +} + +KPL_TEST(run_task) { + kpl_env env = {}; + kpl_env_config(&env, -1, NULL); + env.thread_count = 1; + env.io_uring_queue_size_pow2 = KPL_IO_URING_QUEUE_SIZE_POW2_MIN; + env.flags |= KPL_ENV_FLAG_RUN_FUNCTION; + env.kpl_fn_entry = run_task_set_value; + KPL_ASSERT(kpl_env_init(&env) == KPL_EXIT_CODE_SUCCESS, "env should init"); + KPL_ASSERT(kpl_env_run(&env) == KPL_EXIT_CODE_SUCCESS, "env should run"); + kpl_env_free(&env); + KPL_ASSERT(run_task_value == KPL_RUN_TASK_SET_VALUE, "task should have set value"); +} -- cgit v1.2.3