summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cts/task/cts.testlist9
-rw-r--r--cts/task/dut.c19
2 files changed, 27 insertions, 1 deletions
diff --git a/cts/task/cts.testlist b/cts/task/cts.testlist
index 7c8c5757df..25dbcc313a 100644
--- a/cts/task/cts.testlist
+++ b/cts/task/cts.testlist
@@ -16,4 +16,11 @@ CTS_TEST(test_task_switch)
* 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
+CTS_TEST(test_task_priority)
+
+/*
+ * Test stack overflow. CTS task overflows the stack and it should be detected
+ * when task switch happens. Reboot is expected.
+ * TODO: Verify stack overflow detection and reboot.
+ */
+CTS_TEST(test_stack_overflow) \ No newline at end of file
diff --git a/cts/task/dut.c b/cts/task/dut.c
index ff1407a00b..e34dd0babb 100644
--- a/cts/task/dut.c
+++ b/cts/task/dut.c
@@ -117,8 +117,27 @@ enum cts_rc test_task_priority(void)
return CTS_RC_SUCCESS;
}
+static void recurse(int x)
+{
+ CPRINTS("+%d", x);
+ msleep(1);
+ recurse(x + 1);
+ CPRINTS("-%d", x);
+}
+
+enum cts_rc test_stack_overflow(void);
+
#include "cts_testlist.h"
+enum cts_rc test_stack_overflow(void)
+{
+ /* recurse() is expected to overflow the stack, which leads to reboot.
+ * So, we print output proactively. */
+ CPRINTF("\n%s %d\n", tests[CTS_TEST_ID_COUNT - 1].name, CTS_RC_SUCCESS);
+ recurse(0);
+ return CTS_RC_FAILURE;
+}
+
void cts_task(void)
{
enum cts_rc rc;