summaryrefslogtreecommitdiff
path: root/include/task.h
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2021-10-07 21:17:11 -0600
committerCommit Bot <commit-bot@chromium.org>2021-10-08 18:10:37 +0000
commit43a1421d9bacefe4c6c86387793393a0cd0006ce (patch)
tree1ad89204b525f298b9befd673e6dbf91ecc920ae /include/task.h
parent7c4b49722df9edc6e7eb6008d20bcbdddf0507d7 (diff)
downloadchrome-ec-43a1421d9bacefe4c6c86387793393a0cd0006ce.tar.gz
zephyr: test: usb_mux: Disable PD task during testing
A bug that was uncovered during crrev/c/3197935/8 where an extra sleep was needed in an unrelated test would cause usb_mux test to fail if removed. ROOT CAUSE: The PD task would make a call to (struct usb_mux_driver)::set as a result to some stimulous. Normally during the test's run, this didn't coincide with the usb_mux test suite so it didn't matter. The addition of another test forced the threading overlap. When set() was called, the assert would fail since the specific test wasn't expecting the call. FIX: Add logic to task.h to get the Zephyr TID from a given cros TASK_ID_*. This function is used in the ztest setup/teardown methods of the usb_mux test suite to turn on/off the PD tasks so that this race condition is avoided. BRANCH=none BUG=none TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I25adf0663fb89cd52a8677192e720932f0253626 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3213616 Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Tomasz Michalec <tmichalec@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'include/task.h')
-rw-r--r--include/task.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/task.h b/include/task.h
index d67cfc310c..9eb5a23b33 100644
--- a/include/task.h
+++ b/include/task.h
@@ -440,4 +440,16 @@ struct irq_def {
#endif /* CONFIG_COMMON_RUNTIME */
#endif /* !CONFIG_ZEPHYR */
+#if defined(CONFIG_ZEPHYR) && defined(TEST_BUILD)
+#include <kernel.h>
+
+/**
+ * @brief Get the Zephyr thread ID for the given task
+ *
+ * @param cros_tid A valid cros TASK_ID_* entry
+ * @return The Zephyr thread ID
+ */
+k_tid_t task_get_zephyr_tid(size_t cros_tid);
+#endif /* CONFIG_ZEPHYR && TEST_BUILD */
+
#endif /* __CROS_EC_TASK_H */