summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Michalec <tm@semihalf.com>2021-09-13 23:57:41 +0200
committerCommit Bot <commit-bot@chromium.org>2021-09-15 09:40:21 +0000
commitc9c74e3dea4365ac99a4d8d76c06f062e302d14b (patch)
treeb450d0ad9e8ce7c15704a5ab6a8560742f493aaf
parentef5de0611422c07f7f15387fb4e2e47b268c13c1 (diff)
downloadchrome-ec-c9c74e3dea4365ac99a4d8d76c06f062e302d14b.tar.gz
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 <tm@semihalf.com> Change-Id: I92cd3776a827f9a7f9bb1faee67ed998260e23a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3159528 Tested-by: Tomasz Michalec <tmichalec@google.com> Tested-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Tomasz Michalec <tmichalec@google.com>
-rw-r--r--zephyr/shim/src/tasks.c25
1 files changed, 14 insertions, 11 deletions
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