From c39133b88262a81da9eff3f744b62f3d675334a6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 10 Dec 2021 09:41:22 +0100 Subject: validation: Add system termination test suites The test source code is generated from specification items by the "./spec2modules.py" script contained in the git://git.rtems.org/rtems-central.git Git repository. Please read the "How-To" section in the "Software Requirements Engineering" chapter of the RTEMS Software Engineering manual to get more information about the process. Update #3716. --- testsuites/validation/tc-score-fatal.c | 409 ++++++++++ .../tc-start-of-optional-processor-failed.c | 116 +++ testsuites/validation/tc-terminate.c | 447 +++++++++++ testsuites/validation/tc-userext.c | 849 +++++++++++++++++++++ testsuites/validation/tc-userext.h | 93 +++ ...atal-boot-processor-not-assigned-to-scheduler.c | 159 ++++ ...atal-boot-processor-not-assigned-to-scheduler.h | 84 ++ .../tr-fatal-init-task-construct-failed.c | 172 +++++ .../tr-fatal-init-task-construct-failed.h | 84 ++ .../tr-fatal-mandatory-processor-not-present.c | 158 ++++ .../tr-fatal-mandatory-processor-not-present.h | 84 ++ ...atal-scheduler-requires-exactly-one-processor.c | 159 ++++ ...atal-scheduler-requires-exactly-one-processor.h | 84 ++ testsuites/validation/tr-fatal-smp.c | 320 ++++++++ testsuites/validation/tr-fatal-smp.h | 81 ++ .../tr-fatal-start-of-mandatory-processor-failed.c | 166 ++++ .../tr-fatal-start-of-mandatory-processor-failed.h | 84 ++ .../validation/tr-fatal-too-large-tls-size.c | 182 +++++ .../validation/tr-fatal-too-large-tls-size.h | 84 ++ ...atal-boot-processor-not-assigned-to-scheduler.c | 98 +++ .../ts-fatal-init-task-construct-failed.c | 95 +++ .../ts-fatal-mandatory-processor-not-present.c | 127 +++ ...atal-scheduler-requires-exactly-one-processor.c | 98 +++ testsuites/validation/ts-fatal-smp.c | 97 +++ .../ts-fatal-start-of-mandatory-processor-failed.c | 97 +++ testsuites/validation/ts-fatal-sysinit.h | 144 ++++ .../validation/ts-fatal-too-large-tls-size.c | 82 ++ testsuites/validation/ts-terminate.c | 82 ++ testsuites/validation/ts-validation-smp-only-2.c | 102 +++ 29 files changed, 4837 insertions(+) create mode 100644 testsuites/validation/tc-score-fatal.c create mode 100644 testsuites/validation/tc-start-of-optional-processor-failed.c create mode 100644 testsuites/validation/tc-terminate.c create mode 100644 testsuites/validation/tc-userext.c create mode 100644 testsuites/validation/tc-userext.h create mode 100644 testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.c create mode 100644 testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.h create mode 100644 testsuites/validation/tr-fatal-init-task-construct-failed.c create mode 100644 testsuites/validation/tr-fatal-init-task-construct-failed.h create mode 100644 testsuites/validation/tr-fatal-mandatory-processor-not-present.c create mode 100644 testsuites/validation/tr-fatal-mandatory-processor-not-present.h create mode 100644 testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.c create mode 100644 testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.h create mode 100644 testsuites/validation/tr-fatal-smp.c create mode 100644 testsuites/validation/tr-fatal-smp.h create mode 100644 testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.c create mode 100644 testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.h create mode 100644 testsuites/validation/tr-fatal-too-large-tls-size.c create mode 100644 testsuites/validation/tr-fatal-too-large-tls-size.h create mode 100644 testsuites/validation/ts-fatal-boot-processor-not-assigned-to-scheduler.c create mode 100644 testsuites/validation/ts-fatal-init-task-construct-failed.c create mode 100644 testsuites/validation/ts-fatal-mandatory-processor-not-present.c create mode 100644 testsuites/validation/ts-fatal-scheduler-requires-exactly-one-processor.c create mode 100644 testsuites/validation/ts-fatal-smp.c create mode 100644 testsuites/validation/ts-fatal-start-of-mandatory-processor-failed.c create mode 100644 testsuites/validation/ts-fatal-sysinit.h create mode 100644 testsuites/validation/ts-fatal-too-large-tls-size.c create mode 100644 testsuites/validation/ts-terminate.c create mode 100644 testsuites/validation/ts-validation-smp-only-2.c (limited to 'testsuites/validation') diff --git a/testsuites/validation/tc-score-fatal.c b/testsuites/validation/tc-score-fatal.c new file mode 100644 index 0000000000..02131ee68e --- /dev/null +++ b/testsuites/validation/tc-score-fatal.c @@ -0,0 +1,409 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreValFatal + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +#include "tx-support.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreValFatal spec:/score/val/fatal + * + * @ingroup RTEMSTestSuiteTestsuitesValidationNoClock0 + * @ingroup RTEMSTestSuiteTestsuitesValidationOneCpu0 + * + * @brief Tests some fatal errors. + * + * This test case performs the following actions: + * + * - Construct a task with a task body which returns. Check that the right + * fatal error occurs. + * + * - Construct a task which performs a thread dispatch with maskable interrupts + * disabled. Check that the right fatal error occurs or no fatal error + * occurs. + * + * - Construct a task which performs a direct thread dispatch with a thread + * dispatch level not equal to one. Check that the right fatal error occurs. + * + * - Create a mutex and construct a task which produces a deadlock which + * involves the allocator mutex. + * + * - Check that rtems_fatal() terminates the system. Since SetFatalHandler() + * requires an initial extension this validates CONFIGURE_INITIAL_EXTENSIONS. + * + * @{ + */ + +/** + * @brief Test context for spec:/score/val/fatal test case. + */ +typedef struct { + /** + * @brief This member is a fatal extension invocation counter. + */ + Atomic_Uint counter; + + /** + * @brief This member contains the last fatal source. + */ + rtems_fatal_source source; + + /** + * @brief This member contains the last fatal code. + */ + rtems_fatal_code code; +} ScoreValFatal_Context; + +static ScoreValFatal_Context + ScoreValFatal_Instance; + +typedef ScoreValFatal_Context Context; + +static unsigned int GetFatalCounter( const Context *ctx ) +{ + return _Atomic_Load_uint( &ctx->counter, ATOMIC_ORDER_RELAXED ); +} + +static unsigned int ResetFatalInfo( Context *ctx ) +{ + ctx->source = RTEMS_FATAL_SOURCE_APPLICATION; + ctx->code = INTERNAL_ERROR_NO_MPCI; + + return GetFatalCounter( ctx ); +} + +static void Fatal( + rtems_fatal_source source, + rtems_fatal_code code, + Context *ctx +) +{ + ctx->source = source; + ctx->code = code; + _Atomic_Fetch_add_uint( &ctx->counter, 1, ATOMIC_ORDER_RELAXED ); +} + +static void FatalTaskExit( + rtems_fatal_source source, + rtems_fatal_code code, + void *arg +) +{ + Fatal( source, code, arg ); + rtems_task_exit(); +} + +static void ExitTask( rtems_task_argument arg ) +{ + (void) arg; +} + +static void FatalBadThreadDispatchEnvironment( + rtems_fatal_source source, + rtems_fatal_code code, + void *arg +) +{ + Fatal( source, code, arg ); + _ISR_Set_level( 0 ); + _Thread_Dispatch_direct_no_return( _Per_CPU_Get() ); +} + +static void ISRDisabledThreadDispatchTask( rtems_task_argument arg ) +{ + rtems_interrupt_level level; + + (void) arg; + rtems_interrupt_local_disable( level ); + (void) level; + rtems_task_exit(); +} + +static void FatalBadThreadDispatchDisableLevel( + rtems_fatal_source source, + rtems_fatal_code code, + void *arg +) +{ + Per_CPU_Control *cpu_self; + + Fatal( source, code, arg ); + cpu_self = _Per_CPU_Get(); + _Thread_Dispatch_unnest( cpu_self ); + _Thread_Dispatch_direct_no_return( cpu_self ); +} + +static void BadLevelThreadDispatchTask( rtems_task_argument arg ) +{ + (void) arg; + _Thread_Dispatch_disable(); + rtems_task_exit(); +} + +static jmp_buf before_fatal; + +static rtems_id deadlock_mutex; + +static bool ThreadCreateDeadlock( rtems_tcb *executing, rtems_tcb *created ) +{ + (void) executing; + (void) created; + + ObtainMutex( deadlock_mutex ); + ReleaseMutex( deadlock_mutex ); + + return true; +} + +static void FatalJumpBack( + rtems_fatal_source source, + rtems_fatal_code code, + void *arg +) +{ + SetFatalHandler( NULL, NULL ); + Fatal( source, code, arg ); + longjmp( before_fatal, 1 ); +} + +static void ThreadQueueDeadlockTask( rtems_task_argument arg ) +{ + rtems_id id; + + (void) arg; + id = CreateTask( "DORM", PRIO_NORMAL ); + DeleteTask( id ); + + rtems_task_exit(); +} + +static T_fixture ScoreValFatal_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &ScoreValFatal_Instance +}; + +/** + * @brief Construct a task with a task body which returns. Check that the + * right fatal error occurs. + */ +static void ScoreValFatal_Action_0( ScoreValFatal_Context *ctx ) +{ + rtems_id id; + unsigned int counter; + + SetFatalHandler( FatalTaskExit, ctx ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo( ctx ); + id = CreateTask( "EXIT", PRIO_HIGH ); + StartTask( id, ExitTask, NULL ); + T_eq_uint( GetFatalCounter( ctx ), counter + 1 ); + T_eq_int( ctx->source, INTERNAL_ERROR_CORE ); + T_eq_ulong( ctx->code, INTERNAL_ERROR_THREAD_EXITTED ); + RestoreRunnerPriority(); + SetFatalHandler( NULL, NULL ); +} + +/** + * @brief Construct a task which performs a thread dispatch with maskable + * interrupts disabled. Check that the right fatal error occurs or no fatal + * error occurs. + */ +static void ScoreValFatal_Action_1( ScoreValFatal_Context *ctx ) +{ + rtems_id id; + unsigned int counter; + + SetFatalHandler( FatalBadThreadDispatchEnvironment, ctx ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo( ctx ); + id = CreateTask( "BENV", PRIO_HIGH ); + StartTask( id, ISRDisabledThreadDispatchTask, NULL ); + + #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE + if ( rtems_configuration_get_maximum_processors() > 1 ) { + #endif + T_eq_uint( GetFatalCounter( ctx ), counter + 1 ); + T_eq_int( ctx->source, INTERNAL_ERROR_CORE ); + T_eq_ulong( ctx->code, INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT ); + #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE + } else { + T_eq_uint( GetFatalCounter( ctx ), counter ); + } + #endif + + RestoreRunnerPriority(); + SetFatalHandler( NULL, NULL ); +} + +/** + * @brief Construct a task which performs a direct thread dispatch with a + * thread dispatch level not equal to one. Check that the right fatal error + * occurs. + */ +static void ScoreValFatal_Action_2( ScoreValFatal_Context *ctx ) +{ + rtems_id id; + unsigned int counter; + + SetFatalHandler( FatalBadThreadDispatchDisableLevel, ctx ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo( ctx ); + id = CreateTask( "BLVL", PRIO_HIGH ); + StartTask( id, BadLevelThreadDispatchTask, NULL ); + T_eq_uint( GetFatalCounter( ctx ), counter + 1 ); + T_eq_int( ctx->source, INTERNAL_ERROR_CORE ); + T_eq_ulong( ctx->code, INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL ); + RestoreRunnerPriority(); + SetFatalHandler( NULL, NULL ); +} + +/** + * @brief Create a mutex and construct a task which produces a deadlock which + * involves the allocator mutex. + */ +static void ScoreValFatal_Action_3( ScoreValFatal_Context *ctx ) +{ + rtems_extensions_table extensions; + rtems_status_code sc; + rtems_id extension_id; + rtems_id task_id; + unsigned int counter; + + memset( &extensions, 0, sizeof( extensions ) ); + extensions.thread_create = ThreadCreateDeadlock; + + sc = rtems_extension_create( + rtems_build_name( 'T', 'E', 'X', 'T' ), + &extensions, + &extension_id + ); + T_rsc_success( sc ); + + deadlock_mutex = CreateMutex(); + + SetFatalHandler( FatalJumpBack, ctx ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo( ctx ); + + ObtainMutex( deadlock_mutex ); + + task_id = CreateTask( "WORK", PRIO_HIGH ); + StartTask( task_id, ThreadQueueDeadlockTask, NULL ); + + if ( setjmp( before_fatal ) == 0 ) { + (void) CreateTask( "DLCK", PRIO_NORMAL ); + } + + ReleaseMutex( deadlock_mutex ); + + T_eq_uint( GetFatalCounter( ctx ), counter + 1 ); + T_eq_int( ctx->source, INTERNAL_ERROR_CORE ); + T_eq_ulong( ctx->code, INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK ); + + RestoreRunnerPriority(); + + sc = rtems_extension_delete( extension_id ); + T_rsc_success( sc ); + + DeleteMutex( deadlock_mutex ); +} + +/** + * @brief Check that rtems_fatal() terminates the system. Since + * SetFatalHandler() requires an initial extension this validates + * CONFIGURE_INITIAL_EXTENSIONS. + */ +static void ScoreValFatal_Action_4( ScoreValFatal_Context *ctx ) +{ + unsigned int counter; + + SetFatalHandler( FatalJumpBack, ctx ); + counter = ResetFatalInfo( ctx ); + + if ( setjmp( before_fatal ) == 0 ) { + rtems_fatal( 123, 4567890 ); + } + + T_eq_uint( GetFatalCounter( ctx ), counter + 1 ); + T_eq_int( ctx->source, 123 ); + T_eq_ulong( ctx->code, 4567890 ); +} + +/** + * @fn void T_case_body_ScoreValFatal( void ) + */ +T_TEST_CASE_FIXTURE( ScoreValFatal, &ScoreValFatal_Fixture ) +{ + ScoreValFatal_Context *ctx; + + ctx = T_fixture_context(); + + ScoreValFatal_Action_0( ctx ); + ScoreValFatal_Action_1( ctx ); + ScoreValFatal_Action_2( ctx ); + ScoreValFatal_Action_3( ctx ); + ScoreValFatal_Action_4( ctx ); +} + +/** @} */ diff --git a/testsuites/validation/tc-start-of-optional-processor-failed.c b/testsuites/validation/tc-start-of-optional-processor-failed.c new file mode 100644 index 0000000000..b033a18bae --- /dev/null +++ b/testsuites/validation/tc-start-of-optional-processor-failed.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValStartOfOptionalProcessorFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +/** + * @defgroup RTEMSTestCaseScoreSmpValStartOfOptionalProcessorFailed \ + * spec:/score/smp/val/start-of-optional-processor-failed + * + * @ingroup RTEMSTestSuiteTestsuitesValidationSmpOnly2 + * + * @brief Tests the state of an optional processor which failed to start. + * + * This test case performs the following actions: + * + * - The test action was carried by the system initialization. If we execute + * this test case, then the failed start of an optional processor did not + * abort the system initialization. + * + * - Check that the boot processor is online. + * + * - Check that the optional processor which failed to start is not online. + * + * @{ + */ + +/** + * @brief The test action was carried by the system initialization. If we + * execute this test case, then the failed start of an optional processor did + * not abort the system initialization. + */ +static void ScoreSmpValStartOfOptionalProcessorFailed_Action_0( void ) +{ + /* Nothing to do */ + + /* + * Check that the boot processor is online. + */ + T_step_true( + 0, + _Per_CPU_Is_processor_online( _Per_CPU_Get_by_index( 0 ) ) + ); + + /* + * Check that the optional processor which failed to start is not online. + */ + T_step_false( + 1, + _Per_CPU_Is_processor_online( _Per_CPU_Get_by_index( 1 ) ) + ); +} + +/** + * @fn void T_case_body_ScoreSmpValStartOfOptionalProcessorFailed( void ) + */ +T_TEST_CASE( ScoreSmpValStartOfOptionalProcessorFailed ) +{ + T_plan( 2 ); + + ScoreSmpValStartOfOptionalProcessorFailed_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-terminate.c b/testsuites/validation/tc-terminate.c new file mode 100644 index 0000000000..a3f55fcc6c --- /dev/null +++ b/testsuites/validation/tc-terminate.c @@ -0,0 +1,447 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreInterrValTerminate + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tc-userext.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreInterrValTerminate \ + * spec:/score/interr/val/terminate + * + * @ingroup RTEMSTestSuiteTestsuitesTerminate + * + * @brief Tests system termination procedure. + * + * This test case performs the following actions: + * + * - Create five dynamic extensions. Call the system termination procedure. + * Delete three dynamic extension during the fatal extension invocation. + * Delete the two remaining dynamic extensions. + * + * - Where the system was built with SMP support enabled, check that a + * shutdown request was issued. + * + * - Delete the dynamic extension sets. + * + * - Check that the fatal extensions were invoked with the expected source. + * + * - Check that the fatal extensions were invoked with the expected always + * set to false argument. + * + * - Check that the fatal extensions were invoked with the expected code. + * + * - Check that the fatal extensions were invoked in forward order. + * + * - Check that the fatal extension in the deleted extension set was not + * invoked. + * + * - Check that the system state is terminated. + * + * - Check that the system was halted with the expected fatal source. + * + * - Check that the system was halted with the expected fatal code. + * + * - Check that the system was finally halted. + * + * @{ + */ + +typedef struct { + unsigned int counter; + rtems_fatal_source source; + bool always_set_to_false; + rtems_fatal_code code; +} FatalInfo; + +static Atomic_Uint counter; + +static FatalInfo info[ 7 ]; + +static bool test_case_active; + +static const rtems_extensions_table bsp = BSP_INITIAL_EXTENSION; + +static jmp_buf before_terminate; + +static unsigned int halt_counter; + +static rtems_fatal_source halt_source; + +static rtems_fatal_code halt_code; + +static rtems_id extension_ids[ 7 ]; + +static unsigned int GetCounter( void ) +{ + return _Atomic_Fetch_add_uint( &counter, 1, ATOMIC_ORDER_RELAXED ) + 1; +} + +void __real__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr code ); + +void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr code ); + +void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr code ) +{ + if ( test_case_active ) { + halt_counter = GetCounter(); + halt_source = source; + halt_code = code; + longjmp( before_terminate, 1 ); + } else { +#if defined(RTEMS_COVERAGE) + _IO_Dump_gcov_info( rtems_put_char, NULL ); +#endif + __real__CPU_Fatal_halt( source, code ); + } +} + +static void FatalExtension( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code, + size_t index +) +{ + if ( test_case_active ) { + info[ index ].counter = GetCounter(); + info[ index ].source = source; + info[ index ].always_set_to_false = always_set_to_false; + info[ index ].code = code; + } else { + ( *bsp.fatal )( source, always_set_to_false, code ); + } +} + +void FatalExtension0( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + FatalExtension( source, always_set_to_false, code, 0 ); +} + +void FatalExtension1( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + FatalExtension( source, always_set_to_false, code, 1 ); +} + +static void FatalExtension2( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + rtems_status_code sc; + + FatalExtension( source, always_set_to_false, code, 2 ); + + sc = rtems_extension_delete( extension_ids[ 3 ] ); + T_quiet_rsc_success( sc ); +} + +static void FatalExtension3( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + FatalExtension( source, always_set_to_false, code, 3 ); +} + +static void FatalExtension4( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + FatalExtension( source, always_set_to_false, code, 4 ); +} + +static void FatalExtension5( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + rtems_status_code sc; + + FatalExtension( source, always_set_to_false, code, 5 ); + + sc = rtems_extension_delete( extension_ids[ 5 ] ); + T_quiet_rsc_success( sc ); +} + +static void FatalExtension6( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + rtems_status_code sc; + + FatalExtension( source, always_set_to_false, code, 6 ); + + sc = rtems_extension_delete( extension_ids[ 4 ] ); + T_quiet_rsc_success( sc ); +} + +/** + * @brief Create five dynamic extensions. Call the system termination + * procedure. Delete three dynamic extension during the fatal extension + * invocation. Delete the two remaining dynamic extensions. + */ +static void ScoreInterrValTerminate_Action_0( void ) +{ + rtems_status_code sc; + rtems_extensions_table table; + bool shutdown_ok; + + #if defined(RTEMS_SMP) + shutdown_ok = + ( _Per_CPU_Get_state( _Per_CPU_Get_snapshot() ) == PER_CPU_STATE_UP ); + #else + shutdown_ok = true; + #endif + + memset( &table, 0, sizeof( table ) ); + + table.fatal = FatalExtension2; + sc = rtems_extension_create( + rtems_build_name( ' ', ' ', ' ', '2' ), + &table, + &extension_ids[ 2 ] + ); + T_step_rsc_success( 0, sc ); + + table.fatal = FatalExtension3; + sc = rtems_extension_create( + rtems_build_name( ' ', ' ', ' ', '3' ), + &table, + &extension_ids[ 3 ] + ); + T_step_rsc_success( 1, sc ); + + table.fatal = FatalExtension4; + sc = rtems_extension_create( + rtems_build_name( ' ', ' ', ' ', '4' ), + &table, + &extension_ids[ 4 ] + ); + T_step_rsc_success( 2, sc ); + + table.fatal = FatalExtension5; + sc = rtems_extension_create( + rtems_build_name( ' ', ' ', ' ', '5' ), + &table, + &extension_ids[ 5 ] + ); + T_step_rsc_success( 3, sc ); + + table.fatal = FatalExtension6; + sc = rtems_extension_create( + rtems_build_name( ' ', ' ', ' ', '6' ), + &table, + &extension_ids[ 6 ] + ); + T_step_rsc_success( 4, sc ); + + test_case_active = true; + + if ( setjmp( before_terminate ) == 0 ) { + _Terminate( RTEMS_FATAL_SOURCE_APPLICATION, 123456 ); + } + + test_case_active = false; + + /* + * Where the system was built with SMP support enabled, check that a shutdown + * request was issued. + */ + #if defined(RTEMS_SMP) + shutdown_ok = ( shutdown_ok && _ISR_Get_level() != 0 && + _Per_CPU_Get_state( _Per_CPU_Get() ) == PER_CPU_STATE_SHUTDOWN ); + _ISR_Set_level( 0 ); + #endif + T_step_true( 5, shutdown_ok ); + + /* + * Delete the dynamic extension sets. + */ + sc = rtems_extension_delete( extension_ids[ 2 ] ); + T_step_rsc_success( 6, sc ); + + sc = rtems_extension_delete( extension_ids[ 6 ] ); + T_step_rsc_success( 7, sc ); + + /* + * Check that the fatal extensions were invoked with the expected source. + */ + T_step_eq_int( + 8, + info[ 0 ].source, + RTEMS_FATAL_SOURCE_APPLICATION + ); + T_step_eq_int( + 9, + info[ 1 ].source, + RTEMS_FATAL_SOURCE_APPLICATION + ); + T_step_eq_int( + 10, + info[ 2 ].source, + RTEMS_FATAL_SOURCE_APPLICATION + ); + T_step_eq_int( + 11, + info[ 4 ].source, + RTEMS_FATAL_SOURCE_APPLICATION + ); + T_step_eq_int( + 12, + info[ 5 ].source, + RTEMS_FATAL_SOURCE_APPLICATION + ); + T_step_eq_int( + 13, + info[ 6 ].source, + RTEMS_FATAL_SOURCE_APPLICATION + ); + + /* + * Check that the fatal extensions were invoked with the expected always set + * to false argument. + */ + T_step_false( 14, info[ 0 ].always_set_to_false ); + T_step_false( 15, info[ 1 ].always_set_to_false ); + T_step_false( 16, info[ 2 ].always_set_to_false ); + T_step_false( 17, info[ 4 ].always_set_to_false ); + T_step_false( 18, info[ 5 ].always_set_to_false ); + T_step_false( 19, info[ 6 ].always_set_to_false ); + + /* + * Check that the fatal extensions were invoked with the expected code. + */ + T_step_eq_ulong( 20, info[ 0 ].code, 123456 ); + T_step_eq_ulong( 21, info[ 1 ].code, 123456 ); + T_step_eq_ulong( 22, info[ 2 ].code, 123456 ); + T_step_eq_ulong( 23, info[ 4 ].code, 123456 ); + T_step_eq_ulong( 24, info[ 5 ].code, 123456 ); + T_step_eq_ulong( 25, info[ 6 ].code, 123456 ); + + /* + * Check that the fatal extensions were invoked in forward order. + */ + T_step_eq_uint( 26, info[ 0 ].counter, 1 ); + T_step_eq_uint( 27, info[ 1 ].counter, 2 ); + T_step_eq_uint( 28, info[ 2 ].counter, 3 ); + T_step_eq_uint( 29, info[ 4 ].counter, 4 ); + T_step_eq_uint( 30, info[ 5 ].counter, 5 ); + T_step_eq_uint( 31, info[ 6 ].counter, 6 ); + + /* + * Check that the fatal extension in the deleted extension set was not + * invoked. + */ + T_step_eq_int( 32, info[ 3 ].source, 0 ); + T_step_false( 33, info[ 3 ].always_set_to_false ); + T_step_eq_ulong( 34, info[ 3 ].code, 0 ); + T_step_eq_uint( 35, info[ 3 ].counter, 0 ); + + /* + * Check that the system state is terminated. + */ + T_step_eq_int( 36, _System_state_Get(), SYSTEM_STATE_TERMINATED ); + + /* + * Check that the system was halted with the expected fatal source. + */ + T_step_eq_int( 37, halt_source, RTEMS_FATAL_SOURCE_APPLICATION ); + + /* + * Check that the system was halted with the expected fatal code. + */ + T_step_eq_ulong( 38, halt_code, 123456 ); + + /* + * Check that the system was finally halted. + */ + T_step_eq_uint( 39, counter, 7 ); +} + +/** + * @fn void T_case_body_ScoreInterrValTerminate( void ) + */ +T_TEST_CASE( ScoreInterrValTerminate ) +{ + T_plan( 40 ); + + ScoreInterrValTerminate_Action_0(); +} + +/** @} */ diff --git a/testsuites/validation/tc-userext.c b/testsuites/validation/tc-userext.c new file mode 100644 index 0000000000..252946e026 --- /dev/null +++ b/testsuites/validation/tc-userext.c @@ -0,0 +1,849 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsUserextValUserext + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "tc-userext.h" +#include "tx-support.h" + +#include + +/** + * @defgroup RTEMSTestCaseRtemsUserextValUserext \ + * spec:/rtems/userext/val/userext + * + * @ingroup RTEMSTestSuiteTestsuitesUserext + * + * @brief Tests the thread user extensions. + * + * This test case performs the following actions: + * + * - Create five dynamic extensions. Switch to a started thread. Delete three + * dynamic extension during the thread begin invocation. Clean up the used + * resources. + * + * - Check that the thread switch extensions were invoked in the right order + * before the thread begin extensions. + * + * - Check that the thread begin extensions were invoked in the right order. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread begin extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * - Create five dynamic extensions. Create a thread. Delete three dynamic + * extension during the thread create invocation. Clean up the used + * resources. + * + * - Check that the thread create extensions were invoked in the right order. + * + * - Check that the thread create extensions were invoked under protection of + * the allocator mutex. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread create extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * - Create five dynamic extensions. Delete a thread. Delete three dynamic + * extension during the thread delete invocation. Clean up the used + * resources. + * + * - Check that the thread delete extensions were invoked in the right order. + * + * - Check that the thread delete extensions were invoked under protection of + * the allocator mutex. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread delete extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * - Create five dynamic extensions. Return from a thread entry. Delete three + * dynamic extension during the thread exitted invocation. Clean up the used + * resources. + * + * - Check that the thread exitted extensions were invoked in the right + * order. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread exitted extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * - Create five dynamic extensions. Restart a thread. Delete three dynamic + * extension during the thread restart invocation. Clean up the used + * resources. + * + * - Check that the thread restart extensions were invoked in the right + * order. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread restart extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * - Create five dynamic extensions. Start a thread. Delete three dynamic + * extension during the thread start invocation. Clean up the used + * resources. + * + * - Check that the thread start extensions were invoked in the right order. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread start extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * - Create five dynamic extensions. Terminate a thread. Delete three dynamic + * extension during the thread terminate invocation. Clean up the used + * resources. + * + * - Check that the thread terminate extensions were invoked in the right + * order. + * + * - Check that the other extensions were not invoked. + * + * - Check that the thread terminate extension of the extension set deleted + * before its turn in the invocation was not invoked. + * + * @{ + */ + +typedef struct { + unsigned int counter; + rtems_tcb *executing; + rtems_tcb *thread; +} ExtensionEvent; + +typedef enum { + THREAD_BEGIN, + THREAD_CREATE, + THREAD_DELETE, + THREAD_EXITTED, + THREAD_RESTART, + THREAD_START, + THREAD_SWITCH, + THREAD_TERMINATE, + EXTENSION_KIND_COUNT +} ExtensionKind; + +static rtems_id extension_ids[ 7 ]; + +static Atomic_Uint extension_counter[ RTEMS_ARRAY_SIZE( extension_ids ) ] + [ EXTENSION_KIND_COUNT ]; + +static ExtensionEvent extension_events[ RTEMS_ARRAY_SIZE( extension_ids ) ] + [ EXTENSION_KIND_COUNT ][ 3 ]; + +static Atomic_Uint global_counter; + +static ExtensionKind extension_under_test = EXTENSION_KIND_COUNT; + +static uint32_t thread_create_allocator_owner_count; + +static uint32_t thread_delete_allocator_owner_count; + +static void StopTestCase( void ) +{ + ExtensionKind kind; + rtems_status_code sc; + + kind = extension_under_test; + extension_under_test = EXTENSION_KIND_COUNT; + + sc = rtems_extension_delete( extension_ids[ 2 ] ); + T_rsc_success( sc ); + + if ( kind == THREAD_SWITCH ) { + sc = rtems_extension_delete( extension_ids[ 3 ] ); + T_rsc_success( sc ); + + sc = rtems_extension_delete( extension_ids[ 4 ] ); + T_rsc_success( sc ); + + sc = rtems_extension_delete( extension_ids[ 5 ] ); + T_rsc_success( sc ); + } + + sc = rtems_extension_delete( extension_ids[ 6 ] ); + T_rsc_success( sc ); +} + +static void Extension( + size_t index, + ExtensionKind kind, + rtems_tcb *executing, + rtems_tcb *thread +) +{ + unsigned int gc; + unsigned int c; + rtems_status_code sc; + + if ( extension_under_test == EXTENSION_KIND_COUNT ) { + return; + } + + if ( kind == THREAD_CREATE && _RTEMS_Allocator_is_owner() ) { + ++thread_create_allocator_owner_count; + } + + if ( kind == THREAD_DELETE && _RTEMS_Allocator_is_owner() ) { + ++thread_delete_allocator_owner_count; + } + + gc = _Atomic_Fetch_add_uint( &global_counter, 1, ATOMIC_ORDER_RELAXED ) + 1; + c = _Atomic_Fetch_add_uint( + &extension_counter[ index ][ kind ], + 1, + ATOMIC_ORDER_RELAXED + ); + + if ( c < RTEMS_ARRAY_SIZE( extension_events[ index ][ kind ] ) ) { + extension_events[ index ][ kind ][ c ].counter = gc; + extension_events[ index ][ kind ][ c ].executing = executing; + extension_events[ index ][ kind ][ c ].thread = thread; + } + + if ( kind == THREAD_SWITCH ) { + /* Extension set deletion is not allowed in thread switch extensions */ + return; + } + + if ( kind != extension_under_test ) { + return; + } + + if ( kind == THREAD_DELETE || kind == THREAD_TERMINATE ) { + if ( index == 6 ) { + sc = rtems_extension_delete( extension_ids[ 5 ] ); + T_rsc_success( sc ); + } else if ( index == 3 ) { + sc = rtems_extension_delete( extension_ids[ 3 ] ); + T_rsc_success( sc ); + } else if ( index == 2 ) { + sc = rtems_extension_delete( extension_ids[ 4 ] ); + T_rsc_success( sc ); + } + } else { + if ( index == 2 ) { + sc = rtems_extension_delete( extension_ids[ 3 ] ); + T_rsc_success( sc ); + } else if ( index == 5 ) { + sc = rtems_extension_delete( extension_ids[ 5 ] ); + T_rsc_success( sc ); + } else if ( index == 6 ) { + sc = rtems_extension_delete( extension_ids[ 4 ] ); + T_rsc_success( sc ); + } + } + + if ( index == 6 && ( kind == THREAD_EXITTED || kind == THREAD_RESTART ) ) { + StopTestCase(); + rtems_task_exit(); + } + + if ( index == 0 && kind == THREAD_TERMINATE ) { + StopTestCase(); + } +} + +#define DEFINE_EXTENSIONS( index, linkage ) \ + linkage void ThreadBeginExtension##index( rtems_tcb *executing ) \ + { \ + Extension( index, THREAD_BEGIN, executing, NULL ); \ + } \ + linkage bool ThreadCreateExtension##index( \ + rtems_tcb *executing, \ + rtems_tcb *created \ + ) \ + { \ + Extension( index, THREAD_CREATE, executing, created ); \ + return true; \ + } \ + linkage void ThreadDeleteExtension##index( \ + rtems_tcb *executing, \ + rtems_tcb *deleted \ + ) \ + { \ + Extension( index, THREAD_DELETE, executing, deleted ); \ + } \ + linkage void ThreadExittedExtension##index( rtems_tcb *executing ) \ + { \ + Extension( index, THREAD_EXITTED, executing, NULL ); \ + } \ + linkage void ThreadRestartExtension##index( \ + rtems_tcb *executing, \ + rtems_tcb *restarted \ + ) \ + { \ + Extension( index, THREAD_RESTART, executing, restarted ); \ + } \ + linkage void ThreadStartExtension##index( \ + rtems_tcb *executing, \ + rtems_tcb *started \ + ) \ + { \ + Extension( index, THREAD_START, executing, started ); \ + } \ + linkage void ThreadSwitchExtension##index( \ + rtems_tcb *executing, \ + rtems_tcb *heir \ + ) \ + { \ + Extension( index, THREAD_SWITCH, executing, heir ); \ + } \ + linkage void ThreadTerminateExtension##index( rtems_tcb *executing ) \ + { \ + Extension( index, THREAD_TERMINATE, executing, NULL ); \ + } + +DEFINE_EXTENSIONS( 0, ) +DEFINE_EXTENSIONS( 1, ) + +#define DEFINE_EXTENSIONS_AND_TABLE( index ) \ + DEFINE_EXTENSIONS( index, static ) \ + static const rtems_extensions_table table_##index = { \ + .thread_begin = ThreadBeginExtension##index, \ + .thread_create = ThreadCreateExtension##index, \ + .thread_delete = ThreadDeleteExtension##index, \ + .thread_exitted = ThreadExittedExtension##index, \ + .thread_restart = ThreadRestartExtension##index, \ + .thread_start = ThreadStartExtension##index, \ + .thread_switch = ThreadSwitchExtension##index, \ + .thread_terminate = ThreadTerminateExtension##index \ + } + +DEFINE_EXTENSIONS_AND_TABLE( 2 ); +DEFINE_EXTENSIONS_AND_TABLE( 3 ); +DEFINE_EXTENSIONS_AND_TABLE( 4 ); +DEFINE_EXTENSIONS_AND_TABLE( 5 ); +DEFINE_EXTENSIONS_AND_TABLE( 6 ); + +static const rtems_extensions_table * const tables[] = { + NULL, + NULL, + &table_2, + &table_3, + &table_4, + &table_5, + &table_6 +}; + +static rtems_tcb *StartTestCase( ExtensionKind kind ) +{ + size_t i; + + thread_create_allocator_owner_count = 0; + thread_delete_allocator_owner_count = 0; + _Atomic_Store_uint( &global_counter, 0, ATOMIC_ORDER_RELAXED ); + memset( extension_counter, 0, sizeof( extension_counter ) ); + memset( extension_events, 0, sizeof( extension_events ) ); + + extension_under_test = kind; + + for ( i = 2; i < RTEMS_ARRAY_SIZE( extension_ids ); ++i ) { + rtems_status_code sc; + + sc = rtems_extension_create( + rtems_build_name( ' ', ' ', ' ', '2' + i ), + tables[ i ], + &extension_ids[ i ] + ); + T_rsc_success( sc ); + } + + return GetExecuting(); +} + +static void CheckForward( + ExtensionKind kind, + unsigned int counter, + unsigned int increment, + rtems_tcb *executing, + rtems_tcb *thread +) +{ + size_t i; + + for ( i = 0; i < RTEMS_ARRAY_SIZE( extension_ids ); ++i ) { + if ( i == 3 && kind != THREAD_SWITCH ) { + continue; + } + + if ( counter == 0 ) { + T_eq_uint( extension_counter[ i ][ kind ], 0 ); + } else { + T_eq_uint( extension_counter[ i ][ kind ], 1 ); + T_eq_uint( extension_events[ i ][ kind ][ 0 ].counter, counter ); + T_eq_ptr( extension_events[ i ][ kind ][ 0 ].executing, executing ); + T_eq_ptr( extension_events[ i ][ kind ][ 0 ].thread, thread ); + + counter += increment; + } + } +} + +static void CheckReverse( + ExtensionKind kind, + unsigned int counter, + unsigned int increment, + rtems_tcb *executing, + rtems_tcb *thread +) +{ + size_t i; + + for ( i = 0; i < RTEMS_ARRAY_SIZE( extension_ids ); ++i ) { + if ( i == 5 && kind != THREAD_SWITCH ) { + continue; + } + + if ( counter == 0 ) { + T_eq_uint( extension_counter[ i ][ kind ], 0 ); + } else { + T_eq_uint( extension_counter[ i ][ kind ], 1 ); + T_eq_uint( + extension_events[ i ][ kind ][ 0 ].counter, + 7 - counter + ); + T_eq_ptr( extension_events[ i ][ kind ][ 0 ].executing, executing ); + T_eq_ptr( extension_events[ i ][ kind ][ 0 ].thread, thread ); + + counter += increment; + } + } +} + +static void CheckDeletedNotInvoked( ExtensionKind kind ) +{ + size_t index; + + if ( kind == THREAD_DELETE || kind == THREAD_TERMINATE ) { + index = 5; + } else { + index = 3; + } + + T_eq_uint( extension_events[ index ][ kind ][ 0 ].counter, 0 ); + T_null( extension_events[ index ][ kind ][ 0 ].executing ); + T_null( extension_events[ index ][ kind ][ 0 ].thread ); +} + +static void BeginWorker( rtems_task_argument arg ) +{ + T_eq_u32( arg, 0 ); + StopTestCase(); + rtems_task_exit(); +} + +static void ExittedWorker( rtems_task_argument arg ) +{ + T_eq_u32( arg, 0 ); + (void) StartTestCase( THREAD_EXITTED ); +} + +static void RestartWorker( rtems_task_argument arg ) +{ + T_eq_u32( arg, 0 ); + (void) StartTestCase( THREAD_RESTART ); + (void) rtems_task_restart( RTEMS_SELF, 1 ); +} + +static void StartWorker( rtems_task_argument arg ) +{ + (void) arg; + T_unreachable(); +} + +static void TerminateWorker( rtems_task_argument arg ) +{ + T_eq_u32( arg, 0 ); + (void) StartTestCase( THREAD_TERMINATE ); + rtems_task_exit(); +} + +static void RtemsUserextValUserext_Setup( void *ctx ) +{ + SetSelfPriority( PRIO_NORMAL ); +} + +static void RtemsUserextValUserext_Teardown( void *ctx ) +{ + RestoreRunnerPriority(); +} + +static T_fixture RtemsUserextValUserext_Fixture = { + .setup = RtemsUserextValUserext_Setup, + .stop = NULL, + .teardown = RtemsUserextValUserext_Teardown, + .scope = NULL, + .initial_context = NULL +}; + +/** + * @brief Create five dynamic extensions. Switch to a started thread. Delete + * three dynamic extension during the thread begin invocation. Clean up the + * used resources. + */ +static void RtemsUserextValUserext_Action_0( void ) +{ + rtems_tcb *executing; + rtems_tcb *thread; + rtems_id id; + + id = CreateTask( "WORK", PRIO_LOW ); + thread = GetThread( id ); + StartTask( id, BeginWorker, NULL ); + executing = StartTestCase( THREAD_BEGIN ); + SetPriority( id, PRIO_HIGH ); + KillZombies(); + + /* + * Check that the thread switch extensions were invoked in the right order + * before the thread begin extensions. + */ + CheckForward( THREAD_SWITCH, 1, 1, executing, thread ); + + /* + * Check that the thread begin extensions were invoked in the right order. + */ + CheckForward( THREAD_BEGIN, 8, 1, thread, NULL ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_CREATE, 0, 0, NULL, NULL ); + CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL ); + CheckForward( THREAD_EXITTED, 0, 0, NULL, NULL ); + CheckForward( THREAD_RESTART, 0, 0, NULL, NULL ); + CheckForward( THREAD_START, 0, 0, NULL, NULL ); + CheckReverse( THREAD_TERMINATE, 0, 0, NULL, NULL ); + + /* + * Check that the thread begin extension of the extension set deleted before + * its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_BEGIN ); +} + +/** + * @brief Create five dynamic extensions. Create a thread. Delete three + * dynamic extension during the thread create invocation. Clean up the used + * resources. + */ +static void RtemsUserextValUserext_Action_1( void ) +{ + rtems_tcb *executing; + rtems_tcb *thread; + rtems_id id; + + executing = StartTestCase( THREAD_CREATE ); + id = CreateTask( "WORK", PRIO_NORMAL ); + thread = GetThread( id ); + StopTestCase(); + DeleteTask( id ); + KillZombies(); + + /* + * Check that the thread create extensions were invoked in the right order. + */ + CheckForward( THREAD_CREATE, 1, 1, executing, thread ); + + /* + * Check that the thread create extensions were invoked under protection of + * the allocator mutex. + */ + T_eq_u32( thread_create_allocator_owner_count, 6 ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL ); + CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL ); + CheckForward( THREAD_EXITTED, 0, 0, NULL, NULL ); + CheckForward( THREAD_RESTART, 0, 0, NULL, NULL ); + CheckForward( THREAD_START, 0, 0, NULL, NULL ); + CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL ); + CheckReverse( THREAD_TERMINATE, 0, 0, NULL, NULL ); + + /* + * Check that the thread create extension of the extension set deleted before + * its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_CREATE ); +} + +/** + * @brief Create five dynamic extensions. Delete a thread. Delete three + * dynamic extension during the thread delete invocation. Clean up the used + * resources. + */ +static void RtemsUserextValUserext_Action_2( void ) +{ + rtems_tcb *executing; + rtems_tcb *thread; + rtems_id id; + + id = CreateTask( "WORK", PRIO_NORMAL ); + thread = GetThread( id ); + DeleteTask( id ); + executing = StartTestCase( THREAD_DELETE ); + KillZombies(); + StopTestCase(); + + /* + * Check that the thread delete extensions were invoked in the right order. + */ + CheckReverse( THREAD_DELETE, 1, 1, executing, thread ); + + /* + * Check that the thread delete extensions were invoked under protection of + * the allocator mutex. + */ + T_eq_u32( thread_delete_allocator_owner_count, 6 ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL ); + CheckForward( THREAD_CREATE, 0, 0, NULL, NULL ); + CheckForward( THREAD_EXITTED, 0, 0, NULL, NULL ); + CheckForward( THREAD_RESTART, 0, 0, NULL, NULL ); + CheckForward( THREAD_START, 0, 0, NULL, NULL ); + CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL ); + CheckReverse( THREAD_TERMINATE, 0, 0, NULL, NULL ); + + /* + * Check that the thread delete extension of the extension set deleted before + * its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_DELETE ); +} + +/** + * @brief Create five dynamic extensions. Return from a thread entry. Delete + * three dynamic extension during the thread exitted invocation. Clean up + * the used resources. + */ +static void RtemsUserextValUserext_Action_3( void ) +{ + rtems_tcb *thread; + rtems_id id; + + id = CreateTask( "WORK", PRIO_HIGH ); + thread = GetThread( id ); + StartTask( id, ExittedWorker, NULL ); + KillZombies(); + + /* + * Check that the thread exitted extensions were invoked in the right order. + */ + CheckForward( THREAD_EXITTED, 1, 1, thread, NULL ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL ); + CheckForward( THREAD_CREATE, 0, 0, NULL, NULL ); + CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL ); + CheckForward( THREAD_RESTART, 0, 0, NULL, NULL ); + CheckForward( THREAD_START, 0, 0, NULL, NULL ); + CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL ); + CheckReverse( THREAD_TERMINATE, 0, 0, NULL, NULL ); + + /* + * Check that the thread exitted extension of the extension set deleted + * before its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_EXITTED ); +} + +/** + * @brief Create five dynamic extensions. Restart a thread. Delete three + * dynamic extension during the thread restart invocation. Clean up the used + * resources. + */ +static void RtemsUserextValUserext_Action_4( void ) +{ + rtems_tcb *thread; + rtems_id id; + + id = CreateTask( "WORK", PRIO_HIGH ); + thread = GetThread( id ); + StartTask( id, RestartWorker, NULL ); + KillZombies(); + + /* + * Check that the thread restart extensions were invoked in the right order. + */ + CheckForward( THREAD_RESTART, 1, 1, thread, thread ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL ); + CheckForward( THREAD_EXITTED, 0, 0, NULL, NULL ); + CheckForward( THREAD_CREATE, 0, 0, NULL, NULL ); + CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL ); + CheckForward( THREAD_START, 0, 0, NULL, NULL ); + CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL ); + CheckForward( THREAD_TERMINATE, 0, 0, NULL, NULL ); + + /* + * Check that the thread restart extension of the extension set deleted + * before its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_RESTART ); +} + +/** + * @brief Create five dynamic extensions. Start a thread. Delete three + * dynamic extension during the thread start invocation. Clean up the used + * resources. + */ +static void RtemsUserextValUserext_Action_5( void ) +{ + rtems_tcb *executing; + rtems_tcb *thread; + rtems_id id; + + id = CreateTask( "WORK", PRIO_LOW ); + thread = GetThread( id ); + executing = StartTestCase( THREAD_START ); + StartTask( id, StartWorker, NULL ); + StopTestCase(); + DeleteTask( id ); + KillZombies(); + + /* + * Check that the thread start extensions were invoked in the right order. + */ + CheckForward( THREAD_START, 1, 1, executing, thread ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL ); + CheckForward( THREAD_EXITTED, 0, 0, NULL, NULL ); + CheckForward( THREAD_CREATE, 0, 0, NULL, NULL ); + CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL ); + CheckForward( THREAD_RESTART, 0, 0, NULL, NULL ); + CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL ); + CheckForward( THREAD_TERMINATE, 0, 0, NULL, NULL ); + + /* + * Check that the thread start extension of the extension set deleted before + * its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_START ); +} + +/** + * @brief Create five dynamic extensions. Terminate a thread. Delete three + * dynamic extension during the thread terminate invocation. Clean up the + * used resources. + */ +static void RtemsUserextValUserext_Action_6( void ) +{ + rtems_tcb *thread; + rtems_id id; + + id = CreateTask( "WORK", PRIO_HIGH ); + thread = GetThread( id ); + StartTask( id, TerminateWorker, NULL ); + KillZombies(); + + /* + * Check that the thread terminate extensions were invoked in the right + * order. + */ + CheckReverse( THREAD_TERMINATE, 1, 1, thread, NULL ); + + /* + * Check that the other extensions were not invoked. + */ + CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL ); + CheckForward( THREAD_EXITTED, 0, 0, NULL, NULL ); + CheckForward( THREAD_CREATE, 0, 0, NULL, NULL ); + CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL ); + CheckForward( THREAD_RESTART, 0, 0, NULL, NULL ); + CheckForward( THREAD_START, 0, 0, NULL, NULL ); + CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL ); + + /* + * Check that the thread terminate extension of the extension set deleted + * before its turn in the invocation was not invoked. + */ + CheckDeletedNotInvoked( THREAD_TERMINATE ); +} + +/** + * @fn void T_case_body_RtemsUserextValUserext( void ) + */ +T_TEST_CASE_FIXTURE( RtemsUserextValUserext, &RtemsUserextValUserext_Fixture ) +{ + RtemsUserextValUserext_Action_0(); + RtemsUserextValUserext_Action_1(); + RtemsUserextValUserext_Action_2(); + RtemsUserextValUserext_Action_3(); + RtemsUserextValUserext_Action_4(); + RtemsUserextValUserext_Action_5(); + RtemsUserextValUserext_Action_6(); +} + +/** @} */ diff --git a/testsuites/validation/tc-userext.h b/testsuites/validation/tc-userext.h new file mode 100644 index 0000000000..dbe9e30b67 --- /dev/null +++ b/testsuites/validation/tc-userext.h @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreInterrValTerminate + * + * @brief This header file provides functions used by corresponding test suite. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +#ifndef _TC_USEREXT_H +#define _TC_USEREXT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void ThreadBeginExtension0( rtems_tcb *executing ); + +bool ThreadCreateExtension0( rtems_tcb *executing, rtems_tcb *created ); + +void ThreadDeleteExtension0( rtems_tcb *executing, rtems_tcb *deleted ); + +void ThreadExittedExtension0( rtems_tcb *executing ); + +void ThreadRestartExtension0( rtems_tcb *executing, rtems_tcb *restarted ); + +void ThreadStartExtension0( rtems_tcb *executing, rtems_tcb *started ); + +void ThreadSwitchExtension0( rtems_tcb *executing, rtems_tcb *heir ); + +void ThreadTerminateExtension0( rtems_tcb *executing ); + +void FatalExtension0( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +); + +void ThreadBeginExtension1( rtems_tcb *executing ); + +bool ThreadCreateExtension1( rtems_tcb *executing, rtems_tcb *created ); + +void ThreadDeleteExtension1( rtems_tcb *executing, rtems_tcb *deleted ); + +void ThreadExittedExtension1( rtems_tcb *executing ); + +void ThreadRestartExtension1( rtems_tcb *executing, rtems_tcb *restarted ); + +void ThreadStartExtension1( rtems_tcb *executing, rtems_tcb *started ); + +void ThreadSwitchExtension1( rtems_tcb *executing, rtems_tcb *heir ); + +void ThreadTerminateExtension1( rtems_tcb *executing ); + +void FatalExtension1( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +); + +#ifdef __cplusplus +} +#endif + +#endif /* _TC_USEREXT_H */ diff --git a/testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.c b/testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.c new file mode 100644 index 0000000000..f7cf1e1eb8 --- /dev/null +++ b/testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.c @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalBootProcessorNotAssignedToScheduler + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "tr-fatal-boot-processor-not-assigned-to-scheduler.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreSmpValFatalBootProcessorNotAssignedToScheduler \ + * spec:/score/smp/val/fatal-boot-processor-not-assigned-to-scheduler + * + * @ingroup RTEMSTestSuiteTestsuitesFatalBootProcessorNotAssignedToScheduler + * + * @brief Tests a fatal error. + * + * This test case performs the following actions: + * + * - The test action is carried out by the application configuration of the + * test suite. + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * @{ + */ + +/** + * @brief Test context for + * spec:/score/smp/val/fatal-boot-processor-not-assigned-to-scheduler test + * case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Run() parameter. + */ + rtems_fatal_code code; +} ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Context; + +static ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Context + ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Instance; + +static T_fixture ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Instance +}; + +/** + * @brief The test action is carried out by the application configuration of + * the test suite. + */ +static void ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Action_0( + ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Context *ctx +) +{ + /* Nothing to do */ + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, RTEMS_FATAL_SOURCE_SMP ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( + 1, + ctx->code, + SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER + ); +} + +void ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Run( + rtems_fatal_source source, + rtems_fatal_code code +) +{ + ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Context *ctx; + + ctx = &ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( + "ScoreSmpValFatalBootProcessorNotAssignedToScheduler", + &ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Fixture + ); + + T_plan( 2 ); + + ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Action_0( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.h b/testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.h new file mode 100644 index 0000000000..3cf19f5322 --- /dev/null +++ b/testsuites/validation/tr-fatal-boot-processor-not-assigned-to-scheduler.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalBootProcessorNotAssignedToScheduler + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER_H +#define _TR_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseScoreSmpValFatalBootProcessorNotAssignedToScheduler + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Run( + rtems_fatal_source source, + rtems_fatal_code code +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER_H */ diff --git a/testsuites/validation/tr-fatal-init-task-construct-failed.c b/testsuites/validation/tr-fatal-init-task-construct-failed.c new file mode 100644 index 0000000000..a7ee911f08 --- /dev/null +++ b/testsuites/validation/tr-fatal-init-task-construct-failed.c @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseAcfgValFatalInitTaskConstructFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "tr-fatal-init-task-construct-failed.h" + +#include + +/** + * @defgroup RTEMSTestCaseAcfgValFatalInitTaskConstructFailed \ + * spec:/acfg/val/fatal-init-task-construct-failed + * + * @ingroup RTEMSTestSuiteTestsuitesFatalInitTaskConstructFailed + * + * @brief Tests a fatal error caused by an invalid application configuration. + * + * This test case performs the following actions: + * + * - The test action is carried out by configuring an invalid task priority + * used to construct the initialization task. + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * - Check that the CONFIGURE_INIT_TASK_PRIORITY application configuration + * option resulted in the expected system setting. + * + * @{ + */ + +/** + * @brief Test context for spec:/acfg/val/fatal-init-task-construct-failed test + * case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * AcfgValFatalInitTaskConstructFailed_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * AcfgValFatalInitTaskConstructFailed_Run() parameter. + */ + rtems_fatal_code code; +} AcfgValFatalInitTaskConstructFailed_Context; + +static AcfgValFatalInitTaskConstructFailed_Context + AcfgValFatalInitTaskConstructFailed_Instance; + +static T_fixture AcfgValFatalInitTaskConstructFailed_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &AcfgValFatalInitTaskConstructFailed_Instance +}; + +/** + * @brief The test action is carried out by configuring an invalid task + * priority used to construct the initialization task. + */ +static void AcfgValFatalInitTaskConstructFailed_Action_0( + AcfgValFatalInitTaskConstructFailed_Context *ctx +) +{ + /* Nothing to do */ + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, INTERNAL_ERROR_CORE ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( + 1, + ctx->code, + INTERNAL_ERROR_RTEMS_INIT_TASK_CONSTRUCT_FAILED + ); + + /* + * Check that the CONFIGURE_INIT_TASK_PRIORITY application configuration + * option resulted in the expected system setting. + */ + T_step_eq_u32( + 2, + _RTEMS_tasks_User_task_config.config.initial_priority, + 0 + ); +} + +void AcfgValFatalInitTaskConstructFailed_Run( + rtems_fatal_source source, + rtems_fatal_code code +) +{ + AcfgValFatalInitTaskConstructFailed_Context *ctx; + + ctx = &AcfgValFatalInitTaskConstructFailed_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( + "AcfgValFatalInitTaskConstructFailed", + &AcfgValFatalInitTaskConstructFailed_Fixture + ); + + T_plan( 3 ); + + AcfgValFatalInitTaskConstructFailed_Action_0( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-init-task-construct-failed.h b/testsuites/validation/tr-fatal-init-task-construct-failed.h new file mode 100644 index 0000000000..1685ed567f --- /dev/null +++ b/testsuites/validation/tr-fatal-init-task-construct-failed.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseAcfgValFatalInitTaskConstructFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_INIT_TASK_CONSTRUCT_FAILED_H +#define _TR_FATAL_INIT_TASK_CONSTRUCT_FAILED_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseAcfgValFatalInitTaskConstructFailed + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void AcfgValFatalInitTaskConstructFailed_Run( + rtems_fatal_source source, + rtems_fatal_code code +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_INIT_TASK_CONSTRUCT_FAILED_H */ diff --git a/testsuites/validation/tr-fatal-mandatory-processor-not-present.c b/testsuites/validation/tr-fatal-mandatory-processor-not-present.c new file mode 100644 index 0000000000..0f2435d0d5 --- /dev/null +++ b/testsuites/validation/tr-fatal-mandatory-processor-not-present.c @@ -0,0 +1,158 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalMandatoryProcessorNotPresent + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "tr-fatal-mandatory-processor-not-present.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreSmpValFatalMandatoryProcessorNotPresent \ + * spec:/score/smp/val/fatal-mandatory-processor-not-present + * + * @ingroup RTEMSTestSuiteTestsuitesFatalMandatoryProcessorNotPresent + * + * @brief Tests a fatal error. + * + * This test case performs the following actions: + * + * - The test action is carried out by the application configuration of the + * test suite. + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * @{ + */ + +/** + * @brief Test context for + * spec:/score/smp/val/fatal-mandatory-processor-not-present test case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalMandatoryProcessorNotPresent_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalMandatoryProcessorNotPresent_Run() parameter. + */ + rtems_fatal_code code; +} ScoreSmpValFatalMandatoryProcessorNotPresent_Context; + +static ScoreSmpValFatalMandatoryProcessorNotPresent_Context + ScoreSmpValFatalMandatoryProcessorNotPresent_Instance; + +static T_fixture ScoreSmpValFatalMandatoryProcessorNotPresent_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &ScoreSmpValFatalMandatoryProcessorNotPresent_Instance +}; + +/** + * @brief The test action is carried out by the application configuration of + * the test suite. + */ +static void ScoreSmpValFatalMandatoryProcessorNotPresent_Action_0( + ScoreSmpValFatalMandatoryProcessorNotPresent_Context *ctx +) +{ + /* Nothing to do */ + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, RTEMS_FATAL_SOURCE_SMP ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( + 1, + ctx->code, + SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT + ); +} + +void ScoreSmpValFatalMandatoryProcessorNotPresent_Run( + rtems_fatal_source source, + rtems_fatal_code code +) +{ + ScoreSmpValFatalMandatoryProcessorNotPresent_Context *ctx; + + ctx = &ScoreSmpValFatalMandatoryProcessorNotPresent_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( + "ScoreSmpValFatalMandatoryProcessorNotPresent", + &ScoreSmpValFatalMandatoryProcessorNotPresent_Fixture + ); + + T_plan( 2 ); + + ScoreSmpValFatalMandatoryProcessorNotPresent_Action_0( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-mandatory-processor-not-present.h b/testsuites/validation/tr-fatal-mandatory-processor-not-present.h new file mode 100644 index 0000000000..fd41d1b961 --- /dev/null +++ b/testsuites/validation/tr-fatal-mandatory-processor-not-present.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalMandatoryProcessorNotPresent + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT_H +#define _TR_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseScoreSmpValFatalMandatoryProcessorNotPresent + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void ScoreSmpValFatalMandatoryProcessorNotPresent_Run( + rtems_fatal_source source, + rtems_fatal_code code +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT_H */ diff --git a/testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.c b/testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.c new file mode 100644 index 0000000000..aefe76bb31 --- /dev/null +++ b/testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.c @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalSchedulerRequiresExactlyOneProcessor + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "tr-fatal-scheduler-requires-exactly-one-processor.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreSmpValFatalSchedulerRequiresExactlyOneProcessor \ + * spec:/score/smp/val/fatal-scheduler-requires-exactly-one-processor + * + * @ingroup RTEMSTestSuiteTestsuitesFatalSchedulerRequiresExactlyOneProcessor + * + * @brief Tests a fatal error. + * + * This test case performs the following actions: + * + * - The test action is carried out by the application configuration of the + * test suite. + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * @{ + */ + +/** + * @brief Test context for + * spec:/score/smp/val/fatal-scheduler-requires-exactly-one-processor test + * case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Run() parameter. + */ + rtems_fatal_code code; +} ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Context; + +static ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Context + ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Instance; + +static T_fixture ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Instance +}; + +/** + * @brief The test action is carried out by the application configuration of + * the test suite. + */ +static void ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Action_0( + ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Context *ctx +) +{ + /* Nothing to do */ + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, RTEMS_FATAL_SOURCE_SMP ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( + 1, + ctx->code, + SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR + ); +} + +void ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Run( + rtems_fatal_source source, + rtems_fatal_code code +) +{ + ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Context *ctx; + + ctx = &ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( + "ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor", + &ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Fixture + ); + + T_plan( 2 ); + + ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Action_0( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.h b/testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.h new file mode 100644 index 0000000000..2d0e3f32b2 --- /dev/null +++ b/testsuites/validation/tr-fatal-scheduler-requires-exactly-one-processor.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalSchedulerRequiresExactlyOneProcessor + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR_H +#define _TR_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseScoreSmpValFatalSchedulerRequiresExactlyOneProcessor + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Run( + rtems_fatal_source source, + rtems_fatal_code code +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR_H */ diff --git a/testsuites/validation/tr-fatal-smp.c b/testsuites/validation/tr-fatal-smp.c new file mode 100644 index 0000000000..425a95ade0 --- /dev/null +++ b/testsuites/validation/tr-fatal-smp.c @@ -0,0 +1,320 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatal + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include "tr-fatal-smp.h" +#include "tx-support.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreSmpValFatal spec:/score/smp/val/fatal + * + * @ingroup RTEMSTestSuiteTestsuitesFatalSmp + * + * @brief Tests four fatal errors. + * + * This test case performs the following actions: + * + * - The test action is carried out by TriggerTestCase(). + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * - Check that the processor state is shutdown. + * + * - Check that a second shutdown request does not end in a recursive + * shutdown response. + * + * - Issue a job on a processor in the shutdown state. Check that the right + * fatal error occurs if we try to wait for this job to complete. + * + * - Start multitasking on an invalid processor. Check that the right fatal + * error occurs. + * + * - Start multitasking on an unassigned processor. Check that the right fatal + * error occurs. + * + * @{ + */ + +/** + * @brief Test context for spec:/score/smp/val/fatal test case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatal_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatal_Run() parameter. + */ + rtems_fatal_code code; +} ScoreSmpValFatal_Context; + +static ScoreSmpValFatal_Context + ScoreSmpValFatal_Instance; + +static void TriggerTestCase( void ) +{ + _SMP_Request_shutdown(); + (void) _CPU_Thread_Idle_body( 0 ); +} + +RTEMS_SYSINIT_ITEM( + TriggerTestCase, + RTEMS_SYSINIT_DEVICE_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +static jmp_buf fatal_before; + +static Atomic_Uint fatal_counter; + +static rtems_fatal_source fatal_source; + +static rtems_fatal_code fatal_code; + +static void FatalRecordAndJump( + rtems_fatal_source source, + rtems_fatal_code code, + void *arg +) +{ + (void) arg; + + fatal_source = source; + fatal_code = code; + _Atomic_Fetch_add_uint( &fatal_counter, 1, ATOMIC_ORDER_RELAXED ); + longjmp( fatal_before, 1 ); +} + +static void DoNothing( void *arg ) +{ + (void) arg; +} + +static const Per_CPU_Job_context job_context = { + .handler = DoNothing +}; + +Per_CPU_Job job = { + .context = &job_context +}; + +static T_fixture ScoreSmpValFatal_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &ScoreSmpValFatal_Instance +}; + +/** + * @brief The test action is carried out by TriggerTestCase(). + */ +static void ScoreSmpValFatal_Action_0( ScoreSmpValFatal_Context *ctx ) +{ + /* Nothing to do */ + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, RTEMS_FATAL_SOURCE_SMP ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( 1, ctx->code, SMP_FATAL_SHUTDOWN_RESPONSE ); + + /* + * Check that the processor state is shutdown. + */ + T_step_eq_int( + 2, + _Per_CPU_Get_state( _Per_CPU_Get() ), + PER_CPU_STATE_SHUTDOWN + ); + + /* + * Check that a second shutdown request does not end in a recursive shutdown + * response. + */ + _SMP_Process_message( _Per_CPU_Get(), SMP_MESSAGE_SHUTDOWN ); +} + +/** + * @brief Issue a job on a processor in the shutdown state. Check that the + * right fatal error occurs if we try to wait for this job to complete. + */ +static void ScoreSmpValFatal_Action_1( ScoreSmpValFatal_Context *ctx ) +{ + Per_CPU_Control *cpu; + + SetFatalHandler( FatalRecordAndJump, ctx ); + cpu = _Per_CPU_Get_by_index( 0 ); + _Per_CPU_Submit_job( cpu, &job ); + + if ( setjmp( fatal_before ) == 0 ) { + _Per_CPU_Wait_for_job( cpu, &job ); + } + + T_step_eq_uint( + 3, + _Atomic_Load_uint( &fatal_counter, ATOMIC_ORDER_RELAXED ), + 1 + ); + T_step_eq_int( 4, fatal_source, RTEMS_FATAL_SOURCE_SMP ); + T_step_eq_ulong( + 5, + fatal_code, + SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS + ); + SetFatalHandler( NULL, NULL ); +} + +/** + * @brief Start multitasking on an invalid processor. Check that the right + * fatal error occurs. + */ +static void ScoreSmpValFatal_Action_2( ScoreSmpValFatal_Context *ctx ) +{ + Per_CPU_Control *cpu; + + SetFatalHandler( FatalRecordAndJump, ctx ); + + /* + * This element is outside the array. This is not an issue since + * _SMP_Start_multitasking_on_secondary_processor() does not access the + * structure. + */ + cpu = _Per_CPU_Get_by_index( 3 ); + + if ( setjmp( fatal_before ) == 0 ) { + _SMP_Start_multitasking_on_secondary_processor( cpu ); + } + + T_step_eq_uint( + 6, + _Atomic_Load_uint( &fatal_counter, ATOMIC_ORDER_RELAXED ), + 2 + ); + T_step_eq_int( 7, fatal_source, RTEMS_FATAL_SOURCE_SMP ); + T_step_eq_ulong( + 8, + fatal_code, + SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR + ); + SetFatalHandler( NULL, NULL ); +} + +/** + * @brief Start multitasking on an unassigned processor. Check that the right + * fatal error occurs. + */ +static void ScoreSmpValFatal_Action_3( ScoreSmpValFatal_Context *ctx ) +{ + Per_CPU_Control *cpu; + + SetFatalHandler( FatalRecordAndJump, ctx ); + cpu = _Per_CPU_Get_by_index( 2 ); + + if ( setjmp( fatal_before ) == 0 ) { + _SMP_Start_multitasking_on_secondary_processor( cpu ); + } + + T_step_eq_uint( + 9, + _Atomic_Load_uint( &fatal_counter, ATOMIC_ORDER_RELAXED ), + 3 + ); + T_step_eq_int( 10, fatal_source, RTEMS_FATAL_SOURCE_SMP ); + T_step_eq_ulong( + 11, + fatal_code, + SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR + ); + SetFatalHandler( NULL, NULL ); +} + +void ScoreSmpValFatal_Run( rtems_fatal_source source, rtems_fatal_code code ) +{ + ScoreSmpValFatal_Context *ctx; + + ctx = &ScoreSmpValFatal_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( "ScoreSmpValFatal", &ScoreSmpValFatal_Fixture ); + + T_plan( 12 ); + + ScoreSmpValFatal_Action_0( ctx ); + ScoreSmpValFatal_Action_1( ctx ); + ScoreSmpValFatal_Action_2( ctx ); + ScoreSmpValFatal_Action_3( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-smp.h b/testsuites/validation/tr-fatal-smp.h new file mode 100644 index 0000000000..5b36498d29 --- /dev/null +++ b/testsuites/validation/tr-fatal-smp.h @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatal + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_SMP_H +#define _TR_FATAL_SMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseScoreSmpValFatal + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void ScoreSmpValFatal_Run( rtems_fatal_source source, rtems_fatal_code code ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_SMP_H */ diff --git a/testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.c b/testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.c new file mode 100644 index 0000000000..cc0de8c83c --- /dev/null +++ b/testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.c @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalStartOfMandatoryProcessorFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "tr-fatal-start-of-mandatory-processor-failed.h" + +#include + +/** + * @defgroup RTEMSTestCaseScoreSmpValFatalStartOfMandatoryProcessorFailed \ + * spec:/score/smp/val/fatal-start-of-mandatory-processor-failed + * + * @ingroup RTEMSTestSuiteTestsuitesFatalStartOfMandatoryProcessorFailed + * + * @brief Tests a fatal error. + * + * This test case performs the following actions: + * + * - The test action is carried out by the application configuration of the + * test suite and the wrapped _CPU_SMP_Start_processor(). + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * @{ + */ + +/** + * @brief Test context for + * spec:/score/smp/val/fatal-start-of-mandatory-processor-failed test case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalStartOfMandatoryProcessorFailed_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * ScoreSmpValFatalStartOfMandatoryProcessorFailed_Run() parameter. + */ + rtems_fatal_code code; +} ScoreSmpValFatalStartOfMandatoryProcessorFailed_Context; + +static ScoreSmpValFatalStartOfMandatoryProcessorFailed_Context + ScoreSmpValFatalStartOfMandatoryProcessorFailed_Instance; + +bool __wrap__CPU_SMP_Start_processor( uint32_t cpu_index ); + +bool __wrap__CPU_SMP_Start_processor( uint32_t cpu_index ) +{ + (void) cpu_index; + return false; +} + +static T_fixture ScoreSmpValFatalStartOfMandatoryProcessorFailed_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &ScoreSmpValFatalStartOfMandatoryProcessorFailed_Instance +}; + +/** + * @brief The test action is carried out by the application configuration of + * the test suite and the wrapped _CPU_SMP_Start_processor(). + */ +static void ScoreSmpValFatalStartOfMandatoryProcessorFailed_Action_0( + ScoreSmpValFatalStartOfMandatoryProcessorFailed_Context *ctx +) +{ + /* Nothing to do */ + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, RTEMS_FATAL_SOURCE_SMP ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( + 1, + ctx->code, + SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED + ); +} + +void ScoreSmpValFatalStartOfMandatoryProcessorFailed_Run( + rtems_fatal_source source, + rtems_fatal_code code +) +{ + ScoreSmpValFatalStartOfMandatoryProcessorFailed_Context *ctx; + + ctx = &ScoreSmpValFatalStartOfMandatoryProcessorFailed_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( + "ScoreSmpValFatalStartOfMandatoryProcessorFailed", + &ScoreSmpValFatalStartOfMandatoryProcessorFailed_Fixture + ); + + T_plan( 2 ); + + ScoreSmpValFatalStartOfMandatoryProcessorFailed_Action_0( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.h b/testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.h new file mode 100644 index 0000000000..c80456bd77 --- /dev/null +++ b/testsuites/validation/tr-fatal-start-of-mandatory-processor-failed.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseScoreSmpValFatalStartOfMandatoryProcessorFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED_H +#define _TR_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseScoreSmpValFatalStartOfMandatoryProcessorFailed + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void ScoreSmpValFatalStartOfMandatoryProcessorFailed_Run( + rtems_fatal_source source, + rtems_fatal_code code +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED_H */ diff --git a/testsuites/validation/tr-fatal-too-large-tls-size.c b/testsuites/validation/tr-fatal-too-large-tls-size.c new file mode 100644 index 0000000000..12beeaef90 --- /dev/null +++ b/testsuites/validation/tr-fatal-too-large-tls-size.c @@ -0,0 +1,182 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseAcfgValFatalTooLargeTlsSize + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "tr-fatal-too-large-tls-size.h" + +#include + +/** + * @defgroup RTEMSTestCaseAcfgValFatalTooLargeTlsSize \ + * spec:/acfg/val/fatal-too-large-tls-size + * + * @ingroup RTEMSTestSuiteTestsuitesFatalTooLargeTlsSize + * + * @brief Tests a fatal error. + * + * This test case performs the following actions: + * + * - The test action is carried out by providing a thread-local storage object + * of sufficient size with respect to the application configuration of the + * test suite. + * + * - Check that the expected fatal source is present. + * + * - Check that the expected fatal code is present. + * + * - Check that the CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE application + * configuration option resulted in the expected system setting. + * + * @{ + */ + +/** + * @brief Test context for spec:/acfg/val/fatal-too-large-tls-size test case. + */ +typedef struct { + /** + * @brief This member contains a copy of the corresponding + * AcfgValFatalTooLargeTlsSize_Run() parameter. + */ + rtems_fatal_source source; + + /** + * @brief This member contains a copy of the corresponding + * AcfgValFatalTooLargeTlsSize_Run() parameter. + */ + rtems_fatal_code code; +} AcfgValFatalTooLargeTlsSize_Context; + +static AcfgValFatalTooLargeTlsSize_Context + AcfgValFatalTooLargeTlsSize_Instance; + +static volatile _Thread_local uint8_t large_tls_object[ RTEMS_TASK_STORAGE_ALIGNMENT + 1 ]; + +static volatile bool shall_not_load_the_value; + +static T_fixture AcfgValFatalTooLargeTlsSize_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = NULL, + .initial_context = &AcfgValFatalTooLargeTlsSize_Instance +}; + +/** + * @brief The test action is carried out by providing a thread-local storage + * object of sufficient size with respect to the application configuration of + * the test suite. + */ +static void AcfgValFatalTooLargeTlsSize_Action_0( + AcfgValFatalTooLargeTlsSize_Context *ctx +) +{ + if ( shall_not_load_the_value ) { + uint8_t value; + + value = large_tls_object[ 0 ]; + RTEMS_OBFUSCATE_VARIABLE( value ); + } + + /* + * Check that the expected fatal source is present. + */ + T_step_eq_int( 0, ctx->source, INTERNAL_ERROR_CORE ); + + /* + * Check that the expected fatal code is present. + */ + T_step_eq_ulong( + 1, + ctx->code, + INTERNAL_ERROR_TOO_LARGE_TLS_SIZE + ); + + /* + * Check that the CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE application + * configuration option resulted in the expected system setting. + */ + T_step_eq_sz( + 2, + _Thread_Maximum_TLS_size, + RTEMS_TASK_STORAGE_ALIGNMENT + ); +} + +void AcfgValFatalTooLargeTlsSize_Run( + rtems_fatal_source source, + rtems_fatal_code code +) +{ + AcfgValFatalTooLargeTlsSize_Context *ctx; + + ctx = &AcfgValFatalTooLargeTlsSize_Instance; + ctx->source = source; + ctx->code = code; + + ctx = T_case_begin( + "AcfgValFatalTooLargeTlsSize", + &AcfgValFatalTooLargeTlsSize_Fixture + ); + + T_plan( 3 ); + + AcfgValFatalTooLargeTlsSize_Action_0( ctx ); + + T_case_end(); +} + +/** @} */ diff --git a/testsuites/validation/tr-fatal-too-large-tls-size.h b/testsuites/validation/tr-fatal-too-large-tls-size.h new file mode 100644 index 0000000000..1b5c24e469 --- /dev/null +++ b/testsuites/validation/tr-fatal-too-large-tls-size.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseAcfgValFatalTooLargeTlsSize + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifndef _TR_FATAL_TOO_LARGE_TLS_SIZE_H +#define _TR_FATAL_TOO_LARGE_TLS_SIZE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestCaseAcfgValFatalTooLargeTlsSize + * + * @{ + */ + +/** + * @brief Runs the parameterized test case. + * + * @param source is fatal source. + * + * @param code is fatal code. + */ +void AcfgValFatalTooLargeTlsSize_Run( + rtems_fatal_source source, + rtems_fatal_code code +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TR_FATAL_TOO_LARGE_TLS_SIZE_H */ diff --git a/testsuites/validation/ts-fatal-boot-processor-not-assigned-to-scheduler.c b/testsuites/validation/ts-fatal-boot-processor-not-assigned-to-scheduler.c new file mode 100644 index 0000000000..1222b26b2e --- /dev/null +++ b/testsuites/validation/ts-fatal-boot-processor-not-assigned-to-scheduler.c @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalBootProcessorNotAssignedToScheduler + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-boot-processor-not-assigned-to-scheduler.h" +#include "ts-config.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalBootProcessorNotAssignedToScheduler \ + * spec:/testsuites/fatal-boot-processor-not-assigned-to-scheduler + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite uses an application configuration which + * triggers a fatal error during system initialization. + * + * @{ + */ + +const char rtems_test_name[] = "FatalBootProcessorNotAssignedToScheduler"; + +#define FATAL_SYSINIT_RUN \ + ScoreSmpValFatalBootProcessorNotAssignedToScheduler_Run + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_PROCESSORS 2 + +#include + +#define CONFIGURE_SCHEDULER_EDF_SMP + +#include + +RTEMS_SCHEDULER_EDF_SMP( a ); + +#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ + RTEMS_SCHEDULER_TABLE_EDF_SMP( a, TEST_SCHEDULER_A_NAME ) + +#define CONFIGURE_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER, \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL ) + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-fatal-init-task-construct-failed.c b/testsuites/validation/ts-fatal-init-task-construct-failed.c new file mode 100644 index 0000000000..8efd2b32ce --- /dev/null +++ b/testsuites/validation/ts-fatal-init-task-construct-failed.c @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalInitTaskConstructFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-init-task-construct-failed.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalInitTaskConstructFailed \ + * spec:/testsuites/fatal-init-task-construct-failed + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite contains a test case which triggers a + * fatal error during system initialization. + * + * @{ + */ + +const char rtems_test_name[] = "FatalInitTaskConstructFailed"; + +#define FATAL_SYSINIT_RUN AcfgValFatalInitTaskConstructFailed_Run + +static void Init( rtems_task_argument arg ) +{ + (void) arg; + rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, 1 ); +} + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE 1 + +#define CONFIGURE_INIT_TASK_PRIORITY 0 + +#define CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE RTEMS_MINIMUM_STACK_SIZE + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-fatal-mandatory-processor-not-present.c b/testsuites/validation/ts-fatal-mandatory-processor-not-present.c new file mode 100644 index 0000000000..3645313755 --- /dev/null +++ b/testsuites/validation/ts-fatal-mandatory-processor-not-present.c @@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalMandatoryProcessorNotPresent + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-mandatory-processor-not-present.h" +#include "ts-config.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalMandatoryProcessorNotPresent \ + * spec:/testsuites/fatal-mandatory-processor-not-present + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite contains a test case which triggers a + * fatal error during system initialization. + * + * @{ + */ + +const char rtems_test_name[] = "FatalMandatoryProcessorNotPresent"; + +#define FATAL_SYSINIT_RUN ScoreSmpValFatalMandatoryProcessorNotPresent_Run + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_PROCESSORS 32 + +#include + +#define CONFIGURE_SCHEDULER_EDF_SMP + +#include + +RTEMS_SCHEDULER_EDF_SMP( a ); + +#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ + RTEMS_SCHEDULER_TABLE_EDF_SMP( a, TEST_SCHEDULER_A_NAME ) + +#define CONFIGURE_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ) + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-fatal-scheduler-requires-exactly-one-processor.c b/testsuites/validation/ts-fatal-scheduler-requires-exactly-one-processor.c new file mode 100644 index 0000000000..d9eed5b092 --- /dev/null +++ b/testsuites/validation/ts-fatal-scheduler-requires-exactly-one-processor.c @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalSchedulerRequiresExactlyOneProcessor + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-scheduler-requires-exactly-one-processor.h" +#include "ts-config.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalSchedulerRequiresExactlyOneProcessor \ + * spec:/testsuites/fatal-scheduler-requires-exactly-one-processor + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite uses an application configuration which + * triggers a fatal error during system initialization. + * + * @{ + */ + +const char rtems_test_name[] = "FatalSchedulerRequiresExactlyOneProcessor"; + +#define FATAL_SYSINIT_RUN \ + ScoreSmpValFatalSchedulerRequiresExactlyOneProcessor_Run + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_PROCESSORS 2 + +#include + +#define CONFIGURE_SCHEDULER_PRIORITY + +#include + +RTEMS_SCHEDULER_PRIORITY( a, 256 ); + +#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ + RTEMS_SCHEDULER_TABLE_PRIORITY( a, TEST_SCHEDULER_A_NAME ) + +#define CONFIGURE_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ) + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-fatal-smp.c b/testsuites/validation/ts-fatal-smp.c new file mode 100644 index 0000000000..c1c4844643 --- /dev/null +++ b/testsuites/validation/ts-fatal-smp.c @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalSmp + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-smp.h" +#include "ts-config.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalSmp spec:/testsuites/fatal-smp + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite contains a test case which triggers + * SMP-specific fatal errors. + * + * @{ + */ + +const char rtems_test_name[] = "FatalSmp"; + +#define FATAL_SYSINIT_RUN ScoreSmpValFatal_Run + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_PROCESSORS 3 + +#include + +#define CONFIGURE_SCHEDULER_EDF_SMP + +#include + +RTEMS_SCHEDULER_EDF_SMP( a ); + +#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ + RTEMS_SCHEDULER_TABLE_EDF_SMP( a, TEST_SCHEDULER_A_NAME ) + +#define CONFIGURE_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-fatal-start-of-mandatory-processor-failed.c b/testsuites/validation/ts-fatal-start-of-mandatory-processor-failed.c new file mode 100644 index 0000000000..76e96f50ef --- /dev/null +++ b/testsuites/validation/ts-fatal-start-of-mandatory-processor-failed.c @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalStartOfMandatoryProcessorFailed + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-start-of-mandatory-processor-failed.h" +#include "ts-config.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalStartOfMandatoryProcessorFailed \ + * spec:/testsuites/fatal-start-of-mandatory-processor-failed + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite contains a test case which triggers a + * fatal error during system initialization. + * + * @{ + */ + +const char rtems_test_name[] = "FatalStartOfMandatoryProcessorFailed"; + +#define FATAL_SYSINIT_RUN ScoreSmpValFatalStartOfMandatoryProcessorFailed_Run + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_PROCESSORS 2 + +#include + +#define CONFIGURE_SCHEDULER_EDF_SMP + +#include + +RTEMS_SCHEDULER_EDF_SMP( a ); + +#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ + RTEMS_SCHEDULER_TABLE_EDF_SMP( a, TEST_SCHEDULER_A_NAME ) + +#define CONFIGURE_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ) + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-fatal-sysinit.h b/testsuites/validation/ts-fatal-sysinit.h new file mode 100644 index 0000000000..33a5232813 --- /dev/null +++ b/testsuites/validation/ts-fatal-sysinit.h @@ -0,0 +1,144 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @brief This header file provides a configurable validation test suite runner + * and application configuration for fatal error tests which occur during + * system initialization. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "tx-support.h" + +static char buffer[ 512 ]; + +static const T_action actions[] = { + T_report_hash_sha256 +}; + +static const T_config test_config = { + .name = rtems_test_name, + .buf = buffer, + .buf_size = sizeof( buffer ), + .putchar = rtems_put_char, + .verbosity = RTEMS_TEST_VERBOSITY, +#if defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) + .now = T_now_clock, +#else + .now = T_now_tick, +#endif + .allocate = T_memory_allocate, + .deallocate = T_memory_deallocate, + .action_count = T_ARRAY_SIZE( actions ), + .actions = actions +}; + +static Atomic_Uint counter; + +static void TestSuiteFatalExtension( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + rtems_fatal_code exit_code; + + (void) always_set_to_false; + + if ( source == RTEMS_FATAL_SOURCE_EXIT ) { + return; + } + + if ( _Atomic_Fetch_add_uint( &counter, 1, ATOMIC_ORDER_RELAXED ) != 0 ) { + return; + } + + T_make_runner(); + FATAL_SYSINIT_RUN( source, code ); + + if ( T_run_finalize() ) { + rtems_test_end( rtems_test_name ); + exit_code = 0; + } else { + exit_code = 1; + } + +#if defined(FATAL_SYSINIT_EXIT) + FATAL_SYSINIT_EXIT( exit_code ); +#else + rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, exit_code ); +#endif +} + +static void TestRunInitialize( void ) +{ + rtems_test_begin( rtems_test_name, TEST_STATE ); + T_run_initialize( &test_config ); +} + +RTEMS_SYSINIT_ITEM( + TestRunInitialize, + RTEMS_SYSINIT_BSP_EARLY, + RTEMS_SYSINIT_ORDER_FIRST +); + +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0 + +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY + +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + +#define CONFIGURE_INITIAL_EXTENSIONS \ + { .fatal = FatalInitialExtension }, \ + { .fatal = TestSuiteFatalExtension } + +#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) +#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION + +void *IdleBody( uintptr_t ignored ) +{ + (void) ignored; + + rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, 1 ); +} + +#define CONFIGURE_IDLE_TASK_BODY IdleBody +#endif + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/validation/ts-fatal-too-large-tls-size.c b/testsuites/validation/ts-fatal-too-large-tls-size.c new file mode 100644 index 0000000000..ba41390680 --- /dev/null +++ b/testsuites/validation/ts-fatal-too-large-tls-size.c @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesFatalTooLargeTlsSize + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tr-fatal-too-large-tls-size.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesFatalTooLargeTlsSize \ + * spec:/testsuites/fatal-too-large-tls-size + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite contains a test case which triggers a + * fatal error during system initialization. + * + * @{ + */ + +const char rtems_test_name[] = "FatalTooLargeTlsSize"; + +#define FATAL_SYSINIT_RUN AcfgValFatalTooLargeTlsSize_Run + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE \ + RTEMS_TASK_STORAGE_ALIGNMENT + +#include "ts-fatal-sysinit.h" + +/** @} */ diff --git a/testsuites/validation/ts-terminate.c b/testsuites/validation/ts-terminate.c new file mode 100644 index 0000000000..52676db6d9 --- /dev/null +++ b/testsuites/validation/ts-terminate.c @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesTerminate + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tc-userext.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesTerminate spec:/testsuites/terminate + * + * @ingroup RTEMSTestSuites + * + * @brief This validation test suite contains a test case for the system + * termination procedure. + * + * @{ + */ + +const char rtems_test_name[] = "Terminate"; + +#define CONFIGURE_MAXIMUM_PROCESSORS 2 + +#define CONFIGURE_INITIAL_EXTENSIONS \ + { .fatal = FatalExtension0 }, \ + { .fatal = FatalExtension1 } + +#define CONFIGURE_DISABLE_BSP_SETTINGS + +#include "ts-default.h" + +/** @} */ diff --git a/testsuites/validation/ts-validation-smp-only-2.c b/testsuites/validation/ts-validation-smp-only-2.c new file mode 100644 index 0000000000..74cf5e1db8 --- /dev/null +++ b/testsuites/validation/ts-validation-smp-only-2.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesValidationSmpOnly2 + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ts-config.h" + +#include + +/** + * @defgroup RTEMSTestSuiteTestsuitesValidationSmpOnly2 \ + * spec:/testsuites/validation-smp-only-2 + * + * @ingroup RTEMSTestSuites + * + * @brief This SMP-only test suite validates the clustered scheduler + * configuration through an application configuration with a processor + * maximum of two. The second processor has a optional scheduler assigned + * and fails to start. + * + * @{ + */ + +const char rtems_test_name[] = "ValidationSMPOnly2"; + +bool __wrap__CPU_SMP_Start_processor( uint32_t cpu_index ); + +bool __wrap__CPU_SMP_Start_processor( uint32_t cpu_index ) +{ + (void) cpu_index; + return false; +} + +#define CONFIGURE_MAXIMUM_PROCESSORS 2 + +#include + +#define CONFIGURE_SCHEDULER_EDF_SMP + +#include + +RTEMS_SCHEDULER_EDF_SMP( a ); + +#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \ + RTEMS_SCHEDULER_TABLE_EDF_SMP( a, TEST_SCHEDULER_A_NAME ) + +#define CONFIGURE_SCHEDULER_ASSIGNMENTS \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \ + RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL ) + +#include "ts-default.h" + +/** @} */ -- cgit v1.2.3