summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
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/sptests
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/sptests')
-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
5 files changed, 92 insertions, 5 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);