From c9c74e3dea4365ac99a4d8d76c06f062e302d14b Mon Sep 17 00:00:00 2001 From: Tomasz Michalec Date: Mon, 13 Sep 2021 23:57:41 +0200 Subject: zephyr: Add test runner in shimmed task Some functions requires to call task_wait_event in test task context. Because of that there is needed shimmed_tasks entry for TASK_ID_TEST_RUNNER. BUG=none BRANCH=none TEST=make configure --test zephyr/test/drivers Signed-off-by: Tomasz Michalec Change-Id: I92cd3776a827f9a7f9bb1faee67ed998260e23a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3159528 Tested-by: Tomasz Michalec Tested-by: Abe Levkoy Reviewed-by: Abe Levkoy Reviewed-by: Jeremy Bettis Commit-Queue: Tomasz Michalec --- zephyr/shim/src/tasks.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'zephyr/shim') diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index 9e88b0b452..709af852c0 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -79,15 +79,16 @@ struct task_ctx { #endif /* CONFIG_THREAD_NAME */ #define TASK_TEST(_name, _entry, _parameter, _size) \ CROS_EC_TASK(_name, _entry, _parameter, _size) -static struct task_ctx shimmed_tasks[] = { CROS_EC_TASK_LIST }; +static struct task_ctx shimmed_tasks[] = { + CROS_EC_TASK_LIST +#ifdef TEST_BUILD + [TASK_ID_TEST_RUNNER] = {}, +#endif +}; static int tasks_started; #undef CROS_EC_TASK #undef TASK_TEST -#ifdef TEST_BUILD -static k_tid_t test_runner_tid; -#endif - task_id_t task_get_current(void) { for (size_t i = 0; i < ARRAY_SIZE(shimmed_tasks); ++i) { @@ -103,11 +104,6 @@ task_id_t task_get_current(void) } #endif /* HAS_TASK_HOOKS */ -#ifdef TEST_BUILD - if (k_current_get() == test_runner_tid) { - return TASK_ID_TEST_RUNNER; - } -#endif __ASSERT(false, "Task index out of bound"); return 0; } @@ -269,7 +265,7 @@ void timer_cancel(task_id_t cros_ec_task_id) #ifdef TEST_BUILD void set_test_runner_tid(void) { - test_runner_tid = k_current_get(); + shimmed_tasks[TASK_ID_TEST_RUNNER].zephyr_tid = k_current_get(); } #endif @@ -280,6 +276,13 @@ void start_ec_tasks(void) k_timer_init(&ctx->timer, timer_expire, NULL); +#ifdef TEST_BUILD + /* Do not create thread for test runner; it will be set later */ + if (i == TASK_ID_TEST_RUNNER) { + ctx->zephyr_tid = NULL; + continue; + } +#endif /* * TODO(b/172361873): Add K_FP_REGS for FPU tasks. See * comment in config.h for CONFIG_TASK_LIST for existing flags -- cgit v1.2.1