summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cts/task/cts.testlist5
-rw-r--r--cts/task/dut.c34
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)