summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-09-30 08:06:18 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-10-14 10:48:23 +0200
commit45ee958552ca35b6834985718ecd59b27fc52f86 (patch)
tree5d66e79cf20491f0f1b8f32b292a5a398d386ce4 /testsuites
parentstackchk01: Check CPU_STACK_MINIMUM_SIZE (diff)
downloadrtems-45ee958552ca35b6834985718ecd59b27fc52f86.tar.bz2
config: Add CONFIGURE_IDLE_TASK_STORAGE_SIZE
By default, allocate the IDLE task storage areas from the RTEMS Workspace. This avoids having to estimate the thread-local storage size in the default configuration. Add the application configuration option CONFIGURE_IDLE_TASK_STORAGE_SIZE to request a static allocation of the task storage area for IDLE tasks. Update #3835. Update #4524.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/sptests/spfatal36/init.c63
-rw-r--r--testsuites/sptests/spfatal36/spfatal36.doc11
-rw-r--r--testsuites/sptests/spinternalerror02/init.c2
-rw-r--r--testsuites/sptests/spstkalloc02/init.c13
-rw-r--r--testsuites/sptests/sptls02/init.cc8
-rw-r--r--testsuites/validation/ts-default.h5
-rw-r--r--testsuites/validation/ts-fatal-sysinit.h2
-rw-r--r--testsuites/validation/ts-idle.h4
-rw-r--r--testsuites/validation/ts-validation-acfg-0.c2
-rw-r--r--testsuites/validation/ts-validation-acfg-1.c2
-rw-r--r--testsuites/validation/ts-validation-io-kernel.c2
-rw-r--r--testsuites/validation/ts-validation-tls-1.c3
12 files changed, 111 insertions, 6 deletions
diff --git a/testsuites/sptests/spfatal36/init.c b/testsuites/sptests/spfatal36/init.c
new file mode 100644
index 0000000000..f2a076724a
--- /dev/null
+++ b/testsuites/sptests/spfatal36/init.c
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2022 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "../spfatal_support/spfatal.h"
+
+#include <rtems/sysinit.h>
+#include <rtems/score/heapimpl.h>
+#include <rtems/score/wkspace.h>
+
+#define FATAL_ERROR_TEST_NAME "36"
+
+#define FATAL_ERROR_DESCRIPTION "failure in idle task storage allocation"
+
+#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE
+
+#define FATAL_ERROR_EXPECTED_ERROR \
+ INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE
+
+static void force_error( void )
+{
+ RTEMS_UNREACHABLE();
+}
+
+static void empty_workspace( void )
+{
+ (void) _Heap_Greedy_allocate( &_Workspace_Area, NULL, 0 );
+}
+
+RTEMS_SYSINIT_ITEM(
+ empty_workspace,
+ RTEMS_SYSINIT_IDLE_THREADS,
+ RTEMS_SYSINIT_ORDER_FIRST
+);
+
+#include "../spfatal_support/spfatalimpl.h"
diff --git a/testsuites/sptests/spfatal36/spfatal36.doc b/testsuites/sptests/spfatal36/spfatal36.doc
new file mode 100644
index 0000000000..0719e8e01c
--- /dev/null
+++ b/testsuites/sptests/spfatal36/spfatal36.doc
@@ -0,0 +1,11 @@
+This file describes the concepts tested by this test set.
+
+test set name: spfatal36
+
+directives:
+
+ - _Stack_Allocator_allocate_for_idle_workspace()
+
+concepts:
+
+ - Provoke a memory allocation failure in the directive.
diff --git a/testsuites/sptests/spinternalerror02/init.c b/testsuites/sptests/spinternalerror02/init.c
index f94759a99b..475e31e085 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -49,7 +49,7 @@ static void test_internal_error_text(void)
} while ( text != text_last );
rtems_test_assert(
- error - 3 == INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED
+ error - 3 == INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE
);
}
diff --git a/testsuites/sptests/spstkalloc02/init.c b/testsuites/sptests/spstkalloc02/init.c
index 3613a6a563..7fee4615ad 100644
--- a/testsuites/sptests/spstkalloc02/init.c
+++ b/testsuites/sptests/spstkalloc02/init.c
@@ -44,6 +44,7 @@ const char rtems_test_name[] = "SPSTKALLOC 2";
#include <stdio.h>
#include <inttypes.h>
+#include <rtems/malloc.h>
#include <rtems/score/heapimpl.h>
#define TASK_COUNT 5
@@ -56,6 +57,8 @@ static void task_stack_init(size_t stack_space_size);
static void *task_stack_allocate(size_t stack_size);
+static void *task_stack_allocate_for_idle(uint32_t unused, size_t *stack_size);
+
static void task_stack_free(void *addr);
static void print_info(void)
@@ -149,6 +152,7 @@ static rtems_task Init(rtems_task_argument argument)
#define CONFIGURE_TASK_STACK_ALLOCATOR_INIT task_stack_init
#define CONFIGURE_TASK_STACK_ALLOCATOR task_stack_allocate
+#define CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE task_stack_allocate_for_idle
#define CONFIGURE_TASK_STACK_DEALLOCATOR task_stack_free
#define CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
#define CONFIGURE_TASK_STACK_FROM_ALLOCATOR(stack_size) \
@@ -183,6 +187,15 @@ static void *task_stack_allocate(size_t stack_size)
return _Heap_Allocate(&task_stack_heap, stack_size);
}
+static void *task_stack_allocate_for_idle(uint32_t unused, size_t *stack_size)
+{
+ return rtems_heap_allocate_aligned_with_boundary(
+ *stack_size,
+ CPU_STACK_ALIGNMENT,
+ 0
+ );
+}
+
static void task_stack_free(void *addr)
{
_Heap_Free(&task_stack_heap, addr);
diff --git a/testsuites/sptests/sptls02/init.cc b/testsuites/sptests/sptls02/init.cc
index 39fc2a2a24..b453ef3f62 100644
--- a/testsuites/sptests/sptls02/init.cc
+++ b/testsuites/sptests/sptls02/init.cc
@@ -48,7 +48,7 @@ alignas(256) static thread_local long a256 = 256;
static thread_local long i0;
-alignas(512) static thread_local long a512;
+alignas(RTEMS_MINIMUM_STACK_SIZE) static thread_local long a;
int seven()
{
@@ -61,7 +61,7 @@ static void clobber()
i123 = 0xdead0001;
a256 = 0xdead0002;
i0 = 0xdead0003;
- a512 = 0xdead0004;
+ a = 0xdead0004;
}
static long f456(bool clobber)
@@ -173,8 +173,8 @@ static void checkTLSValues()
RTEMS_OBFUSCATE_VARIABLE(addr);
rtems_test_assert((addr % 256) == 0);
rtems_test_assert(i0 == 0);
- rtems_test_assert(a512 == 0);
- addr = reinterpret_cast<uintptr_t>(&a512);
+ rtems_test_assert(a == 0);
+ addr = reinterpret_cast<uintptr_t>(&a);
RTEMS_OBFUSCATE_VARIABLE(addr);
rtems_test_assert((addr % 512) == 0);
rtems_test_assert(f456(false) == 456);
diff --git a/testsuites/validation/ts-default.h b/testsuites/validation/ts-default.h
index 6e77496b90..be26055c8b 100644
--- a/testsuites/validation/ts-default.h
+++ b/testsuites/validation/ts-default.h
@@ -317,7 +317,10 @@ RTEMS_SCHEDULER_PRIORITY( a, 64 );
#define CONFIGURE_IDLE_TASK_STACK_SIZE TEST_IDLE_STACK_SIZE
static char test_idle_stacks[ CONFIGURE_MAXIMUM_PROCESSORS ][
- ( TEST_IDLE_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE )
+ RTEMS_ALIGN_UP(
+ MAX_TLS_SIZE + TEST_IDLE_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE,
+ CPU_INTERRUPT_STACK_ALIGNMENT
+ )
]
RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT )
RTEMS_SECTION( ".rtemsstack.idle" );
diff --git a/testsuites/validation/ts-fatal-sysinit.h b/testsuites/validation/ts-fatal-sysinit.h
index 09d86d02ea..7a2f86ecca 100644
--- a/testsuites/validation/ts-fatal-sysinit.h
+++ b/testsuites/validation/ts-fatal-sysinit.h
@@ -133,6 +133,8 @@ RTEMS_SYSINIT_ITEM(
{ .fatal = FatalInitialExtension }, \
{ .fatal = TestSuiteFatalExtension }
+#define CONFIGURE_IDLE_TASK_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE
+
#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE)
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
diff --git a/testsuites/validation/ts-idle.h b/testsuites/validation/ts-idle.h
index 071209b5ef..04feaa096d 100644
--- a/testsuites/validation/ts-idle.h
+++ b/testsuites/validation/ts-idle.h
@@ -72,6 +72,10 @@ static const T_config test_config = {
#define CONFIGURE_INITIAL_EXTENSIONS \
{ .fatal = FatalInitialExtension }
+#ifndef CONFIGURE_IDLE_TASK_STORAGE_SIZE
+#define CONFIGURE_IDLE_TASK_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE
+#endif
+
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
void *IdleBody( uintptr_t ignored )
diff --git a/testsuites/validation/ts-validation-acfg-0.c b/testsuites/validation/ts-validation-acfg-0.c
index e1144dd95d..f0fd359007 100644
--- a/testsuites/validation/ts-validation-acfg-0.c
+++ b/testsuites/validation/ts-validation-acfg-0.c
@@ -72,6 +72,8 @@
const char rtems_test_name[] = "ValidationAcfg0";
+#define CONFIGURE_IDLE_TASK_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE
+
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
void *IdleBody( uintptr_t ignored )
diff --git a/testsuites/validation/ts-validation-acfg-1.c b/testsuites/validation/ts-validation-acfg-1.c
index 863a672b23..b12ccb928b 100644
--- a/testsuites/validation/ts-validation-acfg-1.c
+++ b/testsuites/validation/ts-validation-acfg-1.c
@@ -94,6 +94,8 @@ static void Init( rtems_task_argument arg )
#define CONFIGURE_DISABLE_BSP_SETTINGS
+#define CONFIGURE_IDLE_TASK_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE
+
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/validation/ts-validation-io-kernel.c b/testsuites/validation/ts-validation-io-kernel.c
index 83234ecfff..db44303890 100644
--- a/testsuites/validation/ts-validation-io-kernel.c
+++ b/testsuites/validation/ts-validation-io-kernel.c
@@ -138,6 +138,8 @@ static void *IdleBody( uintptr_t ignored )
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES { }
+#define CONFIGURE_IDLE_TASK_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE
+
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
#define CONFIGURE_IDLE_TASK_BODY IdleBody
diff --git a/testsuites/validation/ts-validation-tls-1.c b/testsuites/validation/ts-validation-tls-1.c
index b9b4adc31e..d05f9e1d08 100644
--- a/testsuites/validation/ts-validation-tls-1.c
+++ b/testsuites/validation/ts-validation-tls-1.c
@@ -68,6 +68,9 @@
const char rtems_test_name[] = "ValidationTls1";
+#define CONFIGURE_IDLE_TASK_STORAGE_SIZE \
+ ( RTEMS_MINIMUM_STACK_SIZE + 4096 )
+
#include "ts-idle.h"
/** @} */