summaryrefslogtreecommitdiff
path: root/zephyr/test
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test')
-rw-r--r--zephyr/test/tasks/CMakeLists.txt5
-rw-r--r--zephyr/test/tasks/extra_tasks.c58
-rw-r--r--zephyr/test/tasks/prj.conf5
-rw-r--r--zephyr/test/tasks/testcase.yaml10
4 files changed, 74 insertions, 4 deletions
diff --git a/zephyr/test/tasks/CMakeLists.txt b/zephyr/test/tasks/CMakeLists.txt
index b0b59e7c99..52e6723652 100644
--- a/zephyr/test/tasks/CMakeLists.txt
+++ b/zephyr/test/tasks/CMakeLists.txt
@@ -9,6 +9,9 @@ project(tasks)
# Include the local test directory for shimmed_test_tasks.h
zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
-target_sources(app PRIVATE
+target_sources_ifdef(CONFIG_HAS_TEST_TASKS app PRIVATE
main.c
"${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c")
+
+target_sources_ifdef(CONFIG_SHIMMED_TASKS app PRIVATE
+ extra_tasks.c)
diff --git a/zephyr/test/tasks/extra_tasks.c b/zephyr/test/tasks/extra_tasks.c
new file mode 100644
index 0000000000..c302437c20
--- /dev/null
+++ b/zephyr/test/tasks/extra_tasks.c
@@ -0,0 +1,58 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr/kernel.h>
+#include <zephyr/kernel/thread.h>
+#include <zephyr/ztest.h>
+
+/* Utility functions for finding a Zephyr thread by name */
+static k_tid_t found_thread;
+static void find_thread_by_name_cb(const struct k_thread *thread,
+ void *user_data)
+{
+ const char *name = (const char *)user_data;
+
+ if (strcmp(k_thread_name_get((k_tid_t)thread), name) == 0)
+ found_thread = (k_tid_t)thread;
+}
+
+static k_tid_t find_thread_by_name(const char *name)
+{
+ found_thread = NULL;
+ k_thread_foreach_unlocked(find_thread_by_name_cb, (void *)name);
+ return found_thread;
+}
+
+ZTEST_USER(extra_tasks, test_main_thread_mapping)
+{
+ k_tid_t hostcmd_thread;
+ k_tid_t main_thread;
+
+ hostcmd_thread = find_thread_by_name("HOSTCMD");
+ zassert_not_null(hostcmd_thread);
+
+ main_thread = find_thread_by_name("main");
+ zassert_not_null(main_thread);
+ /* Not equal when CONFIG_TASK_HOSTCMD_THREAD_DEDICATED is set */
+ zassert_not_equal(main_thread, hostcmd_thread);
+}
+
+ZTEST_USER(extra_tasks, test_sysworkq_thread_mapping)
+{
+ k_tid_t sysworkq_thread;
+
+ sysworkq_thread = find_thread_by_name("sysworkq");
+ zassert_not_null(sysworkq_thread);
+}
+
+ZTEST_USER(extra_tasks, test_idle_thread_mapping)
+{
+ k_tid_t idle_thread;
+
+ idle_thread = find_thread_by_name("idle");
+ zassert_not_null(idle_thread);
+}
+
+ZTEST_SUITE(extra_tasks, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/tasks/prj.conf b/zephyr/test/tasks/prj.conf
index 6c8e2fbc90..deb8253bde 100644
--- a/zephyr/test/tasks/prj.conf
+++ b/zephyr/test/tasks/prj.conf
@@ -3,7 +3,8 @@
# found in the LICENSE file.
CONFIG_ZTEST=y
-CONFIG_HAS_TEST_TASKS=y
CONFIG_PLATFORM_EC=y
CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC_HOOKS=n
+CONFIG_PLATFORM_EC_VBOOT_HASH=n
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
+CONFIG_PLATFORM_EC_SWITCH=n
diff --git a/zephyr/test/tasks/testcase.yaml b/zephyr/test/tasks/testcase.yaml
index a72199a14a..4604e966e9 100644
--- a/zephyr/test/tasks/testcase.yaml
+++ b/zephyr/test/tasks/testcase.yaml
@@ -5,4 +5,12 @@
common:
platform_allow: native_posix
tests:
- tasks.default: {}
+ tasks.default:
+ extra_configs:
+ - CONFIG_HAS_TEST_TASKS=y
+ tasks.extra_tasks:
+ extra_configs:
+ - CONFIG_ZTEST_NEW_API=y
+ - CONFIG_SHIMMED_TASKS=y
+ - CONFIG_PLATFORM_EC_HOSTCMD=y
+ - CONFIG_TASK_HOSTCMD_THREAD_DEDICATED=y