summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-score-thread.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-11-22 19:09:12 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-05-19 07:47:37 +0200
commitc821b925f791f6fd138a1fda2378ed5df1d791a7 (patch)
treeb5390402fbe744900384de39ae0fc7cf7c892d07 /testsuites/validation/tc-score-thread.c
parentbasedefs.h: Improve formatting (diff)
downloadrtems-c821b925f791f6fd138a1fda2378ed5df1d791a7.tar.bz2
validation: Test the global construction
Update #3716.
Diffstat (limited to '')
-rw-r--r--testsuites/validation/tc-score-thread.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/testsuites/validation/tc-score-thread.c b/testsuites/validation/tc-score-thread.c
index 9ed4645417..4198df9a2d 100644
--- a/testsuites/validation/tc-score-thread.c
+++ b/testsuites/validation/tc-score-thread.c
@@ -95,6 +95,15 @@
*
* - Clean up all used resources.
*
+ * - Validate the global construction. Mark that the test case executed.
+ *
+ * - Check that the global constructor was called exactly once.
+ *
+ * - Check that the global construction was done by the Classic API user
+ * initialization task.
+ *
+ * - Check that the global constructor was called before the task entry.
+ *
* @{
*/
@@ -123,6 +132,21 @@ static ScoreThreadValThread_Context
typedef ScoreThreadValThread_Context Context;
+static bool test_case_executed;
+
+static bool constructor_test_case_executed;
+
+static uint32_t constructor_calls;
+
+static rtems_id constructor_id;
+
+static __attribute__(( __constructor__ )) void Constructor( void )
+{
+ constructor_test_case_executed = test_case_executed;
+ ++constructor_calls;
+ constructor_id = rtems_task_self();
+}
+
static void TaskTerminate( rtems_tcb *executing )
{
Context *ctx;
@@ -290,6 +314,30 @@ static void ScoreThreadValThread_Action_1( ScoreThreadValThread_Context *ctx )
}
/**
+ * @brief Validate the global construction. Mark that the test case executed.
+ */
+static void ScoreThreadValThread_Action_2( ScoreThreadValThread_Context *ctx )
+{
+ test_case_executed = true;
+
+ /*
+ * Check that the global constructor was called exactly once.
+ */
+ T_eq_u32( constructor_calls, 1 );
+
+ /*
+ * Check that the global construction was done by the Classic API user
+ * initialization task.
+ */
+ T_eq_u32( constructor_id, rtems_task_self() );
+
+ /*
+ * Check that the global constructor was called before the task entry.
+ */
+ T_false( constructor_test_case_executed );
+}
+
+/**
* @fn void T_case_body_ScoreThreadValThread( void )
*/
T_TEST_CASE_FIXTURE( ScoreThreadValThread, &ScoreThreadValThread_Fixture )
@@ -300,6 +348,7 @@ T_TEST_CASE_FIXTURE( ScoreThreadValThread, &ScoreThreadValThread_Fixture )
ScoreThreadValThread_Action_0( ctx );
ScoreThreadValThread_Action_1( ctx );
+ ScoreThreadValThread_Action_2( ctx );
}
/** @} */