summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-intr-vector-disable.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-vector-disable.c
parentlibtest: Return fixture context in T_case_begin() (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 '')
-rw-r--r--testsuites/validation/tc-intr-vector-disable.c145
1 files changed, 85 insertions, 60 deletions
diff --git a/testsuites/validation/tc-intr-vector-disable.c b/testsuites/validation/tc-intr-vector-disable.c
index 7596f4f526..fea05a257a 100644
--- a/testsuites/validation/tc-intr-vector-disable.c
+++ b/testsuites/validation/tc-intr-vector-disable.c
@@ -102,6 +102,15 @@ typedef enum {
RtemsIntrReqVectorDisable_Post_IsEnabled_NA
} RtemsIntrReqVectorDisable_Post_IsEnabled;
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Vector_NA : 1;
+ uint8_t Pre_IsEnabled_NA : 1;
+ uint8_t Pre_CanDisable_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_IsEnabled : 2;
+} RtemsIntrReqVectorDisable_Entry;
+
/**
* @brief Test context for spec:/rtems/intr/req/vector-disable test case.
*/
@@ -128,16 +137,33 @@ 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 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.
+ */
+ RtemsIntrReqVectorDisable_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
} RtemsIntrReqVectorDisable_Context;
static RtemsIntrReqVectorDisable_Context
@@ -513,15 +539,6 @@ static void RtemsIntrReqVectorDisable_Action(
}
}
-typedef struct {
- uint8_t Skip : 1;
- uint8_t Pre_Vector_NA : 1;
- uint8_t Pre_IsEnabled_NA : 1;
- uint8_t Pre_CanDisable_NA : 1;
- uint8_t Post_Status : 2;
- uint8_t Post_IsEnabled : 2;
-} RtemsIntrReqVectorDisable_Entry;
-
static const RtemsIntrReqVectorDisable_Entry
RtemsIntrReqVectorDisable_Entries[] = {
{ 0, 0, 1, 1, RtemsIntrReqVectorDisable_Post_Status_InvId,
@@ -545,8 +562,13 @@ static size_t RtemsIntrReqVectorDisable_Scope( void *arg, char *buf, size_t n )
ctx = arg;
- if ( ctx->in_action_loop ) {
- return T_get_scope( RtemsIntrReqVectorDisable_PreDesc, buf, n, ctx->pcs );
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope(
+ RtemsIntrReqVectorDisable_PreDesc,
+ buf,
+ n,
+ ctx->Map.pcs
+ );
}
return 0;
@@ -561,13 +583,41 @@ static T_fixture RtemsIntrReqVectorDisable_Fixture = {
};
static inline RtemsIntrReqVectorDisable_Entry
-RtemsIntrReqVectorDisable_GetEntry( size_t index )
+RtemsIntrReqVectorDisable_PopEntry( RtemsIntrReqVectorDisable_Context *ctx )
{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
return RtemsIntrReqVectorDisable_Entries[
RtemsIntrReqVectorDisable_Map[ index ]
];
}
+static void RtemsIntrReqVectorDisable_TestVariant(
+ RtemsIntrReqVectorDisable_Context *ctx
+)
+{
+ RtemsIntrReqVectorDisable_Pre_Vector_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsIntrReqVectorDisable_Pre_IsEnabled_Prepare(
+ ctx,
+ ctx->Map.entry.Pre_IsEnabled_NA ? RtemsIntrReqVectorDisable_Pre_IsEnabled_NA : ctx->Map.pcs[ 1 ]
+ );
+ RtemsIntrReqVectorDisable_Pre_CanDisable_Prepare(
+ ctx,
+ ctx->Map.entry.Pre_CanDisable_NA ? RtemsIntrReqVectorDisable_Pre_CanDisable_NA : ctx->Map.pcs[ 2 ]
+ );
+ RtemsIntrReqVectorDisable_Action( ctx );
+ RtemsIntrReqVectorDisable_Post_Status_Check(
+ ctx,
+ ctx->Map.entry.Post_Status
+ );
+ RtemsIntrReqVectorDisable_Post_IsEnabled_Check(
+ ctx,
+ ctx->Map.entry.Post_IsEnabled
+ );
+}
+
/**
* @fn void T_case_body_RtemsIntrReqVectorDisable( void )
*/
@@ -577,53 +627,28 @@ T_TEST_CASE_FIXTURE(
)
{
RtemsIntrReqVectorDisable_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 ] = RtemsIntrReqVectorDisable_Pre_Vector_Valid;
- ctx->pcs[ 0 ] < RtemsIntrReqVectorDisable_Pre_Vector_NA;
- ++ctx->pcs[ 0 ]
+ ctx->Map.pcs[ 0 ] = RtemsIntrReqVectorDisable_Pre_Vector_Valid;
+ ctx->Map.pcs[ 0 ] < RtemsIntrReqVectorDisable_Pre_Vector_NA;
+ ++ctx->Map.pcs[ 0 ]
) {
for (
- ctx->pcs[ 1 ] = RtemsIntrReqVectorDisable_Pre_IsEnabled_Yes;
- ctx->pcs[ 1 ] < RtemsIntrReqVectorDisable_Pre_IsEnabled_NA;
- ++ctx->pcs[ 1 ]
+ ctx->Map.pcs[ 1 ] = RtemsIntrReqVectorDisable_Pre_IsEnabled_Yes;
+ ctx->Map.pcs[ 1 ] < RtemsIntrReqVectorDisable_Pre_IsEnabled_NA;
+ ++ctx->Map.pcs[ 1 ]
) {
for (
- ctx->pcs[ 2 ] = RtemsIntrReqVectorDisable_Pre_CanDisable_Yes;
- ctx->pcs[ 2 ] < RtemsIntrReqVectorDisable_Pre_CanDisable_NA;
- ++ctx->pcs[ 2 ]
+ ctx->Map.pcs[ 2 ] = RtemsIntrReqVectorDisable_Pre_CanDisable_Yes;
+ ctx->Map.pcs[ 2 ] < RtemsIntrReqVectorDisable_Pre_CanDisable_NA;
+ ++ctx->Map.pcs[ 2 ]
) {
- RtemsIntrReqVectorDisable_Entry entry;
- size_t pcs[ 3 ];
-
- entry = RtemsIntrReqVectorDisable_GetEntry( index );
- ++index;
-
- memcpy( pcs, ctx->pcs, sizeof( pcs ) );
-
- if ( entry.Pre_IsEnabled_NA ) {
- ctx->pcs[ 1 ] = RtemsIntrReqVectorDisable_Pre_IsEnabled_NA;
- }
-
- if ( entry.Pre_CanDisable_NA ) {
- ctx->pcs[ 2 ] = RtemsIntrReqVectorDisable_Pre_CanDisable_NA;
- }
-
- RtemsIntrReqVectorDisable_Pre_Vector_Prepare( ctx, ctx->pcs[ 0 ] );
- RtemsIntrReqVectorDisable_Pre_IsEnabled_Prepare( ctx, ctx->pcs[ 1 ] );
- RtemsIntrReqVectorDisable_Pre_CanDisable_Prepare( ctx, ctx->pcs[ 2 ] );
- RtemsIntrReqVectorDisable_Action( ctx );
- RtemsIntrReqVectorDisable_Post_Status_Check( ctx, entry.Post_Status );
- RtemsIntrReqVectorDisable_Post_IsEnabled_Check(
- ctx,
- entry.Post_IsEnabled
- );
- memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ ctx->Map.entry = RtemsIntrReqVectorDisable_PopEntry( ctx );
+ RtemsIntrReqVectorDisable_TestVariant( ctx );
}
}
}