diff options
Diffstat (limited to 'test/task.c')
| -rw-r--r-- | test/task.c | 24 |
1 files changed, 24 insertions, 0 deletions
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"); +} |
