summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-16 16:45:32 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-19 08:44:23 +0100
commitf918f0d7a3d8abe5b92c3414eada3cd4fa7c048e (patch)
tree502bba34db3c710c5ee15b681821fbf09ed668ba
parent6cdd7fd4ae31327c50e0486251ede05c9ac00040 (diff)
testsuites/validation/tc-score-fatal.c
-rw-r--r--testsuites/validation/tc-score-fatal.c35
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 );
}
/** @} */