From 2ae311c901602f0be553d4d3e2bf91e435ce5bd0 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Wed, 9 Nov 2016 15:29:24 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/409535 Reviewed-by: Randall Spangler --- cts/task/dut.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'cts/task/dut.c') 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) -- cgit v1.2.1