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>
This commit is contained in:
Daisuke Nojiri 2016-11-09 15:29:24 -08:00 committed by chrome-bot
parent 0874f1a197
commit 2ae311c901
2 changed files with 39 additions and 0 deletions

View File

@ -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)

View File

@ -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)