[PATCH v2 11/13] stackchk01: Check CPU_STACK_MINIMUM_SIZE

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Oct 6 08:23:30 UTC 2022


Ensure that the CPU_STACK_MINIMUM_SIZE is suffiently larger than the stack
usage in simple applications.
---
 testsuites/libtests/stackchk01/init.c         | 30 ++++++++++++++-----
 testsuites/libtests/stackchk01/stackchk01.doc | 12 ++++++--
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/testsuites/libtests/stackchk01/init.c b/testsuites/libtests/stackchk01/init.c
index 9e58409b17..b87b6baa2d 100644
--- a/testsuites/libtests/stackchk01/init.c
+++ b/testsuites/libtests/stackchk01/init.c
@@ -35,14 +35,18 @@
 
 const char rtems_test_name[] = "STACKCHK 1";
 
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
+static void stack_visitor( const rtems_stack_checker_info *info, void *arg )
+{
+  if ( rtems_object_id_get_api( info->id ) == 1 ) {
+    *(uintptr_t *) arg = info->used;
+  }
+}
 
-rtems_task Init(
-  rtems_task_argument argument
-)
+static rtems_task Init( rtems_task_argument argument )
 {
-  bool              blown;
+  bool      blown;
+  uintptr_t used;
+  uintptr_t limit;
 
   TEST_BEGIN();
 
@@ -50,14 +54,26 @@ rtems_task Init(
   blown = rtems_stack_checker_is_blown();
   rtems_test_assert(!blown);
 
+  rtems_task_wake_after( 2 );
+  used = 0;
+  rtems_stack_checker_iterate( stack_visitor, &used );
+  limit = CPU_STACK_MINIMUM_SIZE / 4;
+  printf(
+    "check used IDLE stack size: 0 < %" PRIuPTR " <= %" PRIuPTR "\n",
+    used,
+    limit
+  );
+  rtems_test_assert( used > 0 );
+  rtems_test_assert( used <= limit );
+
   TEST_END();
   rtems_test_exit(0);
 }
 
 /* configuration information */
 
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
-#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
 
 #define CONFIGURE_MAXIMUM_TASKS 1
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
diff --git a/testsuites/libtests/stackchk01/stackchk01.doc b/testsuites/libtests/stackchk01/stackchk01.doc
index 5b3d9c894b..cbb9fb62f9 100644
--- a/testsuites/libtests/stackchk01/stackchk01.doc
+++ b/testsuites/libtests/stackchk01/stackchk01.doc
@@ -30,9 +30,17 @@ This file describes the directives and concepts tested by this test set.
 test set name:  stackchk01
 
 directives:
-  rtems_stack_checker_is_blown
+
+* CPU_STACK_MINIMUM_SIZE
+
+* rtems_stack_checker_is_blown
+
+* rtems_stack_checker_iterate
 
 concepts:
 
-+ ensure that dynamic checks for a blown stack work both when the stack
+* Ensure that dynamic checks for a blown stack work both when the stack
   is not blown and when it is.
+
+* Ensure that the CPU_STACK_MINIMUM_SIZE is suffiently larger than the stack
+  usage in simple applications.
-- 
2.35.3



More information about the devel mailing list