diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2016-11-09 15:29:24 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-11-10 21:28:33 -0800 |
commit | 2ae311c901602f0be553d4d3e2bf91e435ce5bd0 (patch) | |
tree | 7d923953e4e293d96b275a5e0e159abc201da023 /cts | |
parent | 0874f1a197349c464f8e1002096bda8c33598cf4 (diff) | |
download | chrome-ec-2ae311c901602f0be553d4d3e2bf91e435ce5bd0.tar.gz |
eCTS: Test task priority
CTS task wakes up A and C then goes to sleep:
CTS -> A, C -> A -> B -> C
Since C has a higher priority, C should run first. This should result
in C running one more time than A (or B).
BUG=chromium:663873
BRANCH=none
TEST=cts.py -m task
Change-Id: I89c733ba3aab09b293edf8583d6ed73791531e59
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/409535
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'cts')
-rw-r--r-- | cts/task/cts.testlist | 5 | ||||
-rw-r--r-- | cts/task/dut.c | 34 |
2 files changed, 39 insertions, 0 deletions
diff --git a/cts/task/cts.testlist b/cts/task/cts.testlist index c06c4b4163..7c8c5757df 100644 --- a/cts/task/cts.testlist +++ b/cts/task/cts.testlist @@ -11,4 +11,9 @@ */ CTS_TEST(test_task_switch) +/* + * Test task priority. CTS task wakes up A and C then goes to sleep. Since C + * has a higher priority, C should run first. This should result in C running + * one more time than A (or B). + */ CTS_TEST(test_task_priority)
\ No newline at end of file diff --git a/cts/task/dut.c b/cts/task/dut.c index c3a820b7ce..ff1407a00b 100644 --- a/cts/task/dut.c +++ b/cts/task/dut.c @@ -83,6 +83,40 @@ enum cts_rc test_task_switch(void) return CTS_RC_SUCCESS; } +enum cts_rc test_task_priority(void) +{ + uint32_t event; + + repeat_count = 2; + + task_wake(TASK_ID_A); + task_wake(TASK_ID_C); + + event = task_wait_event(5 * SECOND); + + if (event != TASK_EVENT_WAKE) { + CPRINTS("Woken up by unexpected event: 0x%08x", event); + return CTS_RC_FAILURE; + } + + if (wake_count[0] != repeat_count - 1 + || wake_count[1] != repeat_count - 1) { + CPRINTS("Unexpected counter values: %d %d %d", + wake_count[0], wake_count[1], wake_count[2]); + return CTS_RC_FAILURE; + } + + /* TODO: Verify no tasks are ready, no events are pending. */ + if (*task_get_event_bitmap(TASK_ID_A) + || *task_get_event_bitmap(TASK_ID_B) + || *task_get_event_bitmap(TASK_ID_C)) { + CPRINTS("Events are pending"); + return CTS_RC_FAILURE; + } + + return CTS_RC_SUCCESS; +} + #include "cts_testlist.h" void cts_task(void) |