diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-16 16:45:32 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-23 15:18:37 +0100 |
commit | 73f09ec3d062a339de6d62ad5a50f9a33fe7883a (patch) | |
tree | 298ad504a6ac1f2426d760be1bf2209531177fb1 | |
parent | 98aad9258acb2f1192b14f33781e64a7ee9a8637 (diff) |
testsuites/validation/tc-score-fatal.c
-rw-r--r-- | testsuites/validation/tc-score-fatal.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/testsuites/validation/tc-score-fatal.c b/testsuites/validation/tc-score-fatal.c index 993676d186..779d259552 100644 --- a/testsuites/validation/tc-score-fatal.c +++ b/testsuites/validation/tc-score-fatal.c @@ -86,6 +86,9 @@ * - 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. + * * @{ */ @@ -195,7 +198,7 @@ static void BadLevelThreadDispatchTask( rtems_task_argument arg ) rtems_task_exit(); } -static jmp_buf before_deadlock; +static jmp_buf before_fatal; static rtems_id deadlock_mutex; @@ -210,14 +213,14 @@ static bool ThreadCreateDeadlock( rtems_tcb *executing, rtems_tcb *created ) return true; } -static void FatalThreadQueueDeadlock( +static void FatalJumpBack( rtems_fatal_source source, rtems_fatal_code code, void *arg ) { Fatal( source, code, arg ); - longjmp( before_deadlock, 1 ); + longjmp( before_fatal, 1 ); } static void ThreadQueueDeadlockTask( rtems_task_argument arg ) @@ -338,7 +341,7 @@ static void ScoreValFatal_Action_3( ScoreValFatal_Context *ctx ) deadlock_mutex = CreateMutex(); - SetFatalHandler( FatalThreadQueueDeadlock, ctx ); + SetFatalHandler( FatalJumpBack, ctx ); SetSelfPriority( PRIO_NORMAL ); counter = ResetFatalInfo( ctx ); @@ -347,7 +350,7 @@ static void ScoreValFatal_Action_3( ScoreValFatal_Context *ctx ) task_id = CreateTask( "WORK", PRIO_HIGH ); StartTask( task_id, ThreadQueueDeadlockTask, NULL ); - if ( setjmp( before_deadlock ) == 0 ) { + if ( setjmp( before_fatal ) == 0 ) { (void) CreateTask( "DLCK", PRIO_NORMAL ); } @@ -367,6 +370,27 @@ static void ScoreValFatal_Action_3( ScoreValFatal_Context *ctx ) } /** + * @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 ) @@ -379,6 +403,7 @@ T_TEST_CASE_FIXTURE( ScoreValFatal, &ScoreValFatal_Fixture ) ScoreValFatal_Action_1( ctx ); ScoreValFatal_Action_2( ctx ); ScoreValFatal_Action_3( ctx ); + ScoreValFatal_Action_4( ctx ); } /** @} */ |