summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-intr-is-pending.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-16 12:41:04 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-02 08:54:58 +0200
commita93d0ce2f58f2f85b7cb8e57daeba9a0a1c58291 (patch)
tree33c9e2137f77c35e4b60b3176656988cdd380423 /testsuites/validation/tc-intr-is-pending.c
parent34099baa9c8fcb5fc8f7e375bc47ccd86e6fa8dd (diff)
downloadrtems-a93d0ce2f58f2f85b7cb8e57daeba9a0a1c58291.tar.bz2
validation: Improve generated test code
Move the transition map members of the test context to a dedicated structure. Move the transition variant pre-condition prepare, action, and post-condition checks to a separate function to reduce the indentation level and allow skipping of transition variants.
Diffstat (limited to 'testsuites/validation/tc-intr-is-pending.c')
-rw-r--r--testsuites/validation/tc-intr-is-pending.c130
1 files changed, 74 insertions, 56 deletions
diff --git a/testsuites/validation/tc-intr-is-pending.c b/testsuites/validation/tc-intr-is-pending.c
index 9a81cb9c23..4963827538 100644
--- a/testsuites/validation/tc-intr-is-pending.c
+++ b/testsuites/validation/tc-intr-is-pending.c
@@ -100,6 +100,15 @@ typedef enum {
RtemsIntrReqIsPending_Post_IsPending_NA
} RtemsIntrReqIsPending_Post_IsPending;
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Vector_NA : 1;
+ uint8_t Pre_Pending_NA : 1;
+ uint8_t Pre_IsPending_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_IsPending : 2;
+} RtemsIntrReqIsPending_Entry;
+
/**
* @brief Test context for spec:/rtems/intr/req/is-pending test case.
*/
@@ -141,16 +150,33 @@ typedef struct {
*/
rtems_status_code status;
- /**
- * @brief This member defines the pre-condition states for the next action.
- */
- size_t pcs[ 3 ];
+ struct {
+ /**
+ * @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;
+ /**
+ * @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.
+ */
+ RtemsIntrReqIsPending_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
} RtemsIntrReqIsPending_Context;
static RtemsIntrReqIsPending_Context
@@ -514,15 +540,6 @@ static void RtemsIntrReqIsPending_Action( RtemsIntrReqIsPending_Context *ctx )
}
}
-typedef struct {
- uint8_t Skip : 1;
- uint8_t Pre_Vector_NA : 1;
- uint8_t Pre_Pending_NA : 1;
- uint8_t Pre_IsPending_NA : 1;
- uint8_t Post_Status : 2;
- uint8_t Post_IsPending : 2;
-} RtemsIntrReqIsPending_Entry;
-
static const RtemsIntrReqIsPending_Entry
RtemsIntrReqIsPending_Entries[] = {
{ 0, 0, 0, 0, RtemsIntrReqIsPending_Post_Status_InvAddr,
@@ -548,8 +565,8 @@ static size_t RtemsIntrReqIsPending_Scope( void *arg, char *buf, size_t n )
ctx = arg;
- if ( ctx->in_action_loop ) {
- return T_get_scope( RtemsIntrReqIsPending_PreDesc, buf, n, ctx->pcs );
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( RtemsIntrReqIsPending_PreDesc, buf, n, ctx->Map.pcs );
}
return 0;
@@ -563,64 +580,65 @@ static T_fixture RtemsIntrReqIsPending_Fixture = {
.initial_context = &RtemsIntrReqIsPending_Instance
};
-static inline RtemsIntrReqIsPending_Entry RtemsIntrReqIsPending_GetEntry(
- size_t index
+static inline RtemsIntrReqIsPending_Entry RtemsIntrReqIsPending_PopEntry(
+ RtemsIntrReqIsPending_Context *ctx
)
{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
return RtemsIntrReqIsPending_Entries[
RtemsIntrReqIsPending_Map[ index ]
];
}
+static void RtemsIntrReqIsPending_TestVariant(
+ RtemsIntrReqIsPending_Context *ctx
+)
+{
+ RtemsIntrReqIsPending_Pre_Vector_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsIntrReqIsPending_Pre_Pending_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ RtemsIntrReqIsPending_Pre_IsPending_Prepare(
+ ctx,
+ ctx->Map.entry.Pre_IsPending_NA ? RtemsIntrReqIsPending_Pre_IsPending_NA : ctx->Map.pcs[ 2 ]
+ );
+ RtemsIntrReqIsPending_Action( ctx );
+ RtemsIntrReqIsPending_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+ RtemsIntrReqIsPending_Post_IsPending_Check(
+ ctx,
+ ctx->Map.entry.Post_IsPending
+ );
+}
+
/**
* @fn void T_case_body_RtemsIntrReqIsPending( void )
*/
T_TEST_CASE_FIXTURE( RtemsIntrReqIsPending, &RtemsIntrReqIsPending_Fixture )
{
RtemsIntrReqIsPending_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 ] = RtemsIntrReqIsPending_Pre_Vector_Valid;
- ctx->pcs[ 0 ] < RtemsIntrReqIsPending_Pre_Vector_NA;
- ++ctx->pcs[ 0 ]
+ ctx->Map.pcs[ 0 ] = RtemsIntrReqIsPending_Pre_Vector_Valid;
+ ctx->Map.pcs[ 0 ] < RtemsIntrReqIsPending_Pre_Vector_NA;
+ ++ctx->Map.pcs[ 0 ]
) {
for (
- ctx->pcs[ 1 ] = RtemsIntrReqIsPending_Pre_Pending_Obj;
- ctx->pcs[ 1 ] < RtemsIntrReqIsPending_Pre_Pending_NA;
- ++ctx->pcs[ 1 ]
+ ctx->Map.pcs[ 1 ] = RtemsIntrReqIsPending_Pre_Pending_Obj;
+ ctx->Map.pcs[ 1 ] < RtemsIntrReqIsPending_Pre_Pending_NA;
+ ++ctx->Map.pcs[ 1 ]
) {
for (
- ctx->pcs[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_Yes;
- ctx->pcs[ 2 ] < RtemsIntrReqIsPending_Pre_IsPending_NA;
- ++ctx->pcs[ 2 ]
+ ctx->Map.pcs[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_Yes;
+ ctx->Map.pcs[ 2 ] < RtemsIntrReqIsPending_Pre_IsPending_NA;
+ ++ctx->Map.pcs[ 2 ]
) {
- RtemsIntrReqIsPending_Entry entry;
- size_t pcs[ 3 ];
-
- entry = RtemsIntrReqIsPending_GetEntry( index );
- ++index;
-
- memcpy( pcs, ctx->pcs, sizeof( pcs ) );
-
- if ( entry.Pre_IsPending_NA ) {
- ctx->pcs[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_NA;
- }
-
- RtemsIntrReqIsPending_Pre_Vector_Prepare( ctx, ctx->pcs[ 0 ] );
- RtemsIntrReqIsPending_Pre_Pending_Prepare( ctx, ctx->pcs[ 1 ] );
- RtemsIntrReqIsPending_Pre_IsPending_Prepare( ctx, ctx->pcs[ 2 ] );
- RtemsIntrReqIsPending_Action( ctx );
- RtemsIntrReqIsPending_Post_Status_Check( ctx, entry.Post_Status );
- RtemsIntrReqIsPending_Post_IsPending_Check(
- ctx,
- entry.Post_IsPending
- );
- memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ ctx->Map.entry = RtemsIntrReqIsPending_PopEntry( ctx );
+ RtemsIntrReqIsPending_TestVariant( ctx );
}
}
}