aboutsummaryrefslogtreecommitdiff
path: root/test/task.c
blob: 83749894af71c73c60a2d0ee678f6d3c07ce3846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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");
}