summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-barrier-wait.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/validation/tc-barrier-wait.c')
-rw-r--r--testsuites/validation/tc-barrier-wait.c180
1 files changed, 114 insertions, 66 deletions
diff --git a/testsuites/validation/tc-barrier-wait.c b/testsuites/validation/tc-barrier-wait.c
index 6776dc0e11..49d29a45c8 100644
--- a/testsuites/validation/tc-barrier-wait.c
+++ b/testsuites/validation/tc-barrier-wait.c
@@ -3,11 +3,11 @@
/**
* @file
*
- * @ingroup RTEMSTestCaseRtemsBarrierReqWait
+ * @ingroup RtemsBarrierReqWait
*/
/*
- * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2021 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -60,9 +60,9 @@
#include <rtems/test.h>
/**
- * @defgroup RTEMSTestCaseRtemsBarrierReqWait spec:/rtems/barrier/req/wait
+ * @defgroup RtemsBarrierReqWait spec:/rtems/barrier/req/wait
*
- * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ * @ingroup TestsuitesValidationNoClock0
*
* @{
*/
@@ -97,6 +97,14 @@ typedef enum {
RtemsBarrierReqWait_Post_Status_NA
} RtemsBarrierReqWait_Post_Status;
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Id_NA : 1;
+ uint8_t Pre_Timeout_NA : 1;
+ uint8_t Pre_Satisfy_NA : 1;
+ uint8_t Post_Status : 3;
+} RtemsBarrierReqWait_Entry;
+
/**
* @brief Test context for spec:/rtems/barrier/req/wait test case.
*/
@@ -117,16 +125,39 @@ typedef struct {
rtems_status_code status;
- /**
- * @brief This member defines the pre-condition states for the next action.
- */
- size_t pcs[ 3 ];
-
- /**
- * @brief This member indicates if the test action loop is currently
- * executed.
- */
- bool in_action_loop;
+ struct {
+ /**
+ * @brief This member defines the pre-condition indices for the next
+ * action.
+ */
+ size_t pci[ 3 ];
+
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 3 ];
+
+ /**
+ * @brief If this member is true, then the test action loop is executed.
+ */
+ bool in_action_loop;
+
+ /**
+ * @brief This member contains the next transition map index.
+ */
+ size_t index;
+
+ /**
+ * @brief This member contains the current transition map entry.
+ */
+ RtemsBarrierReqWait_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
} RtemsBarrierReqWait_Context;
static RtemsBarrierReqWait_Context
@@ -162,7 +193,7 @@ static const char * const * const RtemsBarrierReqWait_PreDesc[] = {
#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
-#define EVENT_CHECK_TIMER RTEMS_EVENT_0
+#define EVENT_TIMER_INACTIVE RTEMS_EVENT_0
#define EVENT_WAIT RTEMS_EVENT_1
@@ -170,6 +201,8 @@ static const char * const * const RtemsBarrierReqWait_PreDesc[] = {
#define EVENT_DELETE RTEMS_EVENT_3
+#define EVENT_TIMER_EXPIRE RTEMS_EVENT_4
+
typedef RtemsBarrierReqWait_Context Context;
static void Worker( rtems_task_argument arg )
@@ -184,7 +217,7 @@ static void Worker( rtems_task_argument arg )
events = ReceiveAnyEvents();
- if ( ( events & EVENT_CHECK_TIMER ) != 0 ) {
+ if ( ( events & EVENT_TIMER_INACTIVE ) != 0 ) {
T_eq_int(
T_get_thread_timer_state( ctx->main_id ),
T_THREAD_TIMER_INACTIVE
@@ -231,6 +264,14 @@ static void Worker( rtems_task_argument arg )
prio = SetSelfPriority( prio );
T_eq_u32( prio, PRIO_HIGH );
}
+
+ if ( ( events & EVENT_TIMER_EXPIRE ) != 0 ) {
+ T_eq_int(
+ T_get_thread_timer_state( ctx->main_id ),
+ T_THREAD_TIMER_SCHEDULED
+ );
+ FinalClockTick();
+ }
}
}
@@ -281,7 +322,7 @@ static void RtemsBarrierReqWait_Pre_Timeout_Prepare(
/*
* While the ``released`` parameter is a clock tick interval.
*/
- ctx->timeout = 2;
+ ctx->timeout = UINT32_MAX;
break;
}
@@ -310,7 +351,9 @@ static void RtemsBarrierReqWait_Pre_Satisfy_Prepare(
* released or deleted.
*/
if ( ctx->timeout == RTEMS_NO_TIMEOUT ) {
- SendEvents( ctx->low_worker_id, EVENT_CHECK_TIMER | EVENT_RELEASE );
+ SendEvents( ctx->low_worker_id, EVENT_TIMER_INACTIVE | EVENT_RELEASE );
+ } else {
+ SendEvents( ctx->low_worker_id, EVENT_TIMER_EXPIRE );
}
break;
}
@@ -432,7 +475,7 @@ static void RtemsBarrierReqWait_Setup_Wrap( void *arg )
RtemsBarrierReqWait_Context *ctx;
ctx = arg;
- ctx->in_action_loop = false;
+ ctx->Map.in_action_loop = false;
RtemsBarrierReqWait_Setup( ctx );
}
@@ -461,7 +504,7 @@ static void RtemsBarrierReqWait_Teardown_Wrap( void *arg )
RtemsBarrierReqWait_Context *ctx;
ctx = arg;
- ctx->in_action_loop = false;
+ ctx->Map.in_action_loop = false;
RtemsBarrierReqWait_Teardown( ctx );
}
@@ -470,14 +513,6 @@ static void RtemsBarrierReqWait_Action( RtemsBarrierReqWait_Context *ctx )
ctx->status = rtems_barrier_wait( ctx->id, ctx->timeout );
}
-typedef struct {
- uint8_t Skip : 1;
- uint8_t Pre_Id_NA : 1;
- uint8_t Pre_Timeout_NA : 1;
- uint8_t Pre_Satisfy_NA : 1;
- uint8_t Post_Status : 3;
-} RtemsBarrierReqWait_Entry;
-
static const RtemsBarrierReqWait_Entry
RtemsBarrierReqWait_Entries[] = {
{ 0, 0, 1, 1, RtemsBarrierReqWait_Post_Status_InvId },
@@ -499,8 +534,8 @@ static size_t RtemsBarrierReqWait_Scope( void *arg, char *buf, size_t n )
ctx = arg;
- if ( ctx->in_action_loop ) {
- return T_get_scope( RtemsBarrierReqWait_PreDesc, buf, n, ctx->pcs );
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( RtemsBarrierReqWait_PreDesc, buf, n, ctx->Map.pcs );
}
return 0;
@@ -514,68 +549,81 @@ static T_fixture RtemsBarrierReqWait_Fixture = {
.initial_context = &RtemsBarrierReqWait_Instance
};
-static inline RtemsBarrierReqWait_Entry RtemsBarrierReqWait_GetEntry(
- size_t index
+static inline RtemsBarrierReqWait_Entry RtemsBarrierReqWait_PopEntry(
+ RtemsBarrierReqWait_Context *ctx
)
{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
return RtemsBarrierReqWait_Entries[
RtemsBarrierReqWait_Map[ index ]
];
}
+static void RtemsBarrierReqWait_SetPreConditionStates(
+ RtemsBarrierReqWait_Context *ctx
+)
+{
+ ctx->Map.pcs[ 0 ] = ctx->Map.pci[ 0 ];
+
+ if ( ctx->Map.entry.Pre_Timeout_NA ) {
+ ctx->Map.pcs[ 1 ] = RtemsBarrierReqWait_Pre_Timeout_NA;
+ } else {
+ ctx->Map.pcs[ 1 ] = ctx->Map.pci[ 1 ];
+ }
+
+ if ( ctx->Map.entry.Pre_Satisfy_NA ) {
+ ctx->Map.pcs[ 2 ] = RtemsBarrierReqWait_Pre_Satisfy_NA;
+ } else {
+ ctx->Map.pcs[ 2 ] = ctx->Map.pci[ 2 ];
+ }
+}
+
+static void RtemsBarrierReqWait_TestVariant( RtemsBarrierReqWait_Context *ctx )
+{
+ RtemsBarrierReqWait_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsBarrierReqWait_Pre_Timeout_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ RtemsBarrierReqWait_Pre_Satisfy_Prepare( ctx, ctx->Map.pcs[ 2 ] );
+ RtemsBarrierReqWait_Action( ctx );
+ RtemsBarrierReqWait_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+}
+
/**
* @fn void T_case_body_RtemsBarrierReqWait( void )
*/
T_TEST_CASE_FIXTURE( RtemsBarrierReqWait, &RtemsBarrierReqWait_Fixture )
{
RtemsBarrierReqWait_Context *ctx;
- size_t index;
ctx = T_fixture_context();
- ctx->in_action_loop = true;
- index = 0;
+ ctx->Map.in_action_loop = true;
+ ctx->Map.index = 0;
for (
- ctx->pcs[ 0 ] = RtemsBarrierReqWait_Pre_Id_NoObj;
- ctx->pcs[ 0 ] < RtemsBarrierReqWait_Pre_Id_NA;
- ++ctx->pcs[ 0 ]
+ ctx->Map.pci[ 0 ] = RtemsBarrierReqWait_Pre_Id_NoObj;
+ ctx->Map.pci[ 0 ] < RtemsBarrierReqWait_Pre_Id_NA;
+ ++ctx->Map.pci[ 0 ]
) {
for (
- ctx->pcs[ 1 ] = RtemsBarrierReqWait_Pre_Timeout_Ticks;
- ctx->pcs[ 1 ] < RtemsBarrierReqWait_Pre_Timeout_NA;
- ++ctx->pcs[ 1 ]
+ ctx->Map.pci[ 1 ] = RtemsBarrierReqWait_Pre_Timeout_Ticks;
+ ctx->Map.pci[ 1 ] < RtemsBarrierReqWait_Pre_Timeout_NA;
+ ++ctx->Map.pci[ 1 ]
) {
for (
- ctx->pcs[ 2 ] = RtemsBarrierReqWait_Pre_Satisfy_Never;
- ctx->pcs[ 2 ] < RtemsBarrierReqWait_Pre_Satisfy_NA;
- ++ctx->pcs[ 2 ]
+ ctx->Map.pci[ 2 ] = RtemsBarrierReqWait_Pre_Satisfy_Never;
+ ctx->Map.pci[ 2 ] < RtemsBarrierReqWait_Pre_Satisfy_NA;
+ ++ctx->Map.pci[ 2 ]
) {
- RtemsBarrierReqWait_Entry entry;
- size_t pcs[ 3 ];
-
- entry = RtemsBarrierReqWait_GetEntry( index );
- ++index;
+ ctx->Map.entry = RtemsBarrierReqWait_PopEntry( ctx );
- if ( entry.Skip ) {
+ if ( ctx->Map.entry.Skip ) {
continue;
}
- memcpy( pcs, ctx->pcs, sizeof( pcs ) );
-
- if ( entry.Pre_Timeout_NA ) {
- ctx->pcs[ 1 ] = RtemsBarrierReqWait_Pre_Timeout_NA;
- }
-
- if ( entry.Pre_Satisfy_NA ) {
- ctx->pcs[ 2 ] = RtemsBarrierReqWait_Pre_Satisfy_NA;
- }
-
- RtemsBarrierReqWait_Pre_Id_Prepare( ctx, ctx->pcs[ 0 ] );
- RtemsBarrierReqWait_Pre_Timeout_Prepare( ctx, ctx->pcs[ 1 ] );
- RtemsBarrierReqWait_Pre_Satisfy_Prepare( ctx, ctx->pcs[ 2 ] );
- RtemsBarrierReqWait_Action( ctx );
- RtemsBarrierReqWait_Post_Status_Check( ctx, entry.Post_Status );
- memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ RtemsBarrierReqWait_SetPreConditionStates( ctx );
+ RtemsBarrierReqWait_TestVariant( ctx );
}
}
}