From 6a8208533d80339d20fb36258abac84357811152 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 6 Oct 2022 08:26:47 +0200 Subject: stackchk01: Check CPU_STACK_MINIMUM_SIZE Ensure that the CPU_STACK_MINIMUM_SIZE is suffiently larger than the stack usage in simple applications. --- testsuites/libtests/stackchk01/init.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'testsuites/libtests/stackchk01/init.c') 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 -- cgit v1.2.3