diff options
author | Jett Rink <jettrink@chromium.org> | 2020-07-09 14:45:56 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-10 22:21:55 +0000 |
commit | 0f713b36be38449cddea2196d1a135d7bdcfb82a (patch) | |
tree | 039710aee8c2d3c2b6108e26e8b54da36243592c /common/usbc/usbc_task.c | |
parent | 3b05afd87d249c1318989fda9d0e341ab0d69f91 (diff) | |
download | chrome-ec-0f713b36be38449cddea2196d1a135d7bdcfb82a.tar.gz |
tests: reset the PD task before every test case
In order to isolate each test and make each test run from a
clean state, reuse the TASK_RESET_DONE event to signal to
the test code that we should just jump back to the beginning
of the PD task
BRANCH=none
BUG=none
TEST=see that tests are reset in child CLs
Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: I3c0408ab0dbc3ad3a26f17aadbda1577ffc7d32f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290650
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'common/usbc/usbc_task.c')
-rw-r--r-- | common/usbc/usbc_task.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c index 841ee029f9..7bd0cdddd8 100644 --- a/common/usbc/usbc_task.c +++ b/common/usbc/usbc_task.c @@ -152,6 +152,8 @@ void pd_task(void *u) { int port = TASK_ID_TO_PD_PORT(task_get_current()); +test_only_restart: + if (IS_ENABLED(CONFIG_USB_TYPEC_SM)) tc_state_init(port); @@ -185,6 +187,12 @@ void pd_task(void *u) ? -1 : USBC_EVENT_TIMEOUT); + /* + * Re-use TASK_EVENT_RESET_DONE in tests to restart the USB task + */ + if (IS_ENABLED(TEST_BUILD) && (evt & TASK_EVENT_RESET_DONE)) + goto test_only_restart; + /* handle events that affect the state machine as a whole */ if (IS_ENABLED(CONFIG_USB_TYPEC_SM)) tc_event_check(port, evt); |