From a93d0ce2f58f2f85b7cb8e57daeba9a0a1c58291 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 16 Aug 2021 12:41:04 +0200 Subject: 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. --- testsuites/validation/tc-intr-entry-install.c | 243 +++++++++++++------------- 1 file changed, 120 insertions(+), 123 deletions(-) (limited to 'testsuites/validation/tc-intr-entry-install.c') diff --git a/testsuites/validation/tc-intr-entry-install.c b/testsuites/validation/tc-intr-entry-install.c index 20d06df997..37583249aa 100644 --- a/testsuites/validation/tc-intr-entry-install.c +++ b/testsuites/validation/tc-intr-entry-install.c @@ -148,6 +148,21 @@ typedef enum { RtemsIntrReqEntryInstall_Post_Installed_NA } RtemsIntrReqEntryInstall_Post_Installed; +typedef struct { + uint32_t Skip : 1; + uint32_t Pre_Vector_NA : 1; + uint32_t Pre_Options_NA : 1; + uint32_t Pre_Entry_NA : 1; + uint32_t Pre_Routine_NA : 1; + uint32_t Pre_Init_NA : 1; + uint32_t Pre_ISR_NA : 1; + uint32_t Pre_CanEnable_NA : 1; + uint32_t Pre_Installed_NA : 1; + uint32_t Post_Status : 4; + uint32_t Post_Enable : 3; + uint32_t Post_Installed : 2; +} RtemsIntrReqEntryInstall_Entry; + /** * @brief Test context for spec:/rtems/intr/req/entry-install test case. */ @@ -255,16 +270,33 @@ typedef struct { */ rtems_status_code status; - /** - * @brief This member defines the pre-condition states for the next action. - */ - size_t pcs[ 8 ]; - - /** - * @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[ 8 ]; + + /** + * @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. + */ + RtemsIntrReqEntryInstall_Entry entry; + + /** + * @brief If this member is true, then the current transition variant + * should be skipped. + */ + bool skip; + } Map; } RtemsIntrReqEntryInstall_Context; static RtemsIntrReqEntryInstall_Context @@ -1019,7 +1051,7 @@ static void RtemsIntrReqEntryInstall_Setup_Wrap( void *arg ) RtemsIntrReqEntryInstall_Context *ctx; ctx = arg; - ctx->in_action_loop = false; + ctx->Map.in_action_loop = false; RtemsIntrReqEntryInstall_Setup( ctx ); } @@ -1065,21 +1097,6 @@ static void RtemsIntrReqEntryInstall_Cleanup( } } -typedef struct { - uint32_t Skip : 1; - uint32_t Pre_Vector_NA : 1; - uint32_t Pre_Options_NA : 1; - uint32_t Pre_Entry_NA : 1; - uint32_t Pre_Routine_NA : 1; - uint32_t Pre_Init_NA : 1; - uint32_t Pre_ISR_NA : 1; - uint32_t Pre_CanEnable_NA : 1; - uint32_t Pre_Installed_NA : 1; - uint32_t Post_Status : 4; - uint32_t Post_Enable : 3; - uint32_t Post_Installed : 2; -} RtemsIntrReqEntryInstall_Entry; - static const RtemsIntrReqEntryInstall_Entry RtemsIntrReqEntryInstall_Entries[] = { { 0, 0, 0, 0, 1, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_InvAddr, @@ -1204,8 +1221,13 @@ static size_t RtemsIntrReqEntryInstall_Scope( void *arg, char *buf, size_t n ) ctx = arg; - if ( ctx->in_action_loop ) { - return T_get_scope( RtemsIntrReqEntryInstall_PreDesc, buf, n, ctx->pcs ); + if ( ctx->Map.in_action_loop ) { + return T_get_scope( + RtemsIntrReqEntryInstall_PreDesc, + buf, + n, + ctx->Map.pcs + ); } return 0; @@ -1219,15 +1241,55 @@ static T_fixture RtemsIntrReqEntryInstall_Fixture = { .initial_context = &RtemsIntrReqEntryInstall_Instance }; -static inline RtemsIntrReqEntryInstall_Entry RtemsIntrReqEntryInstall_GetEntry( - size_t index +static inline RtemsIntrReqEntryInstall_Entry RtemsIntrReqEntryInstall_PopEntry( + RtemsIntrReqEntryInstall_Context *ctx ) { + size_t index; + + index = ctx->Map.index; + ctx->Map.index = index + 1; return RtemsIntrReqEntryInstall_Entries[ RtemsIntrReqEntryInstall_Map[ index ] ]; } +static void RtemsIntrReqEntryInstall_TestVariant( + RtemsIntrReqEntryInstall_Context *ctx +) +{ + RtemsIntrReqEntryInstall_Pre_Vector_Prepare( ctx, ctx->Map.pcs[ 0 ] ); + RtemsIntrReqEntryInstall_Pre_Options_Prepare( ctx, ctx->Map.pcs[ 1 ] ); + RtemsIntrReqEntryInstall_Pre_Entry_Prepare( ctx, ctx->Map.pcs[ 2 ] ); + RtemsIntrReqEntryInstall_Pre_Routine_Prepare( + ctx, + ctx->Map.entry.Pre_Routine_NA ? RtemsIntrReqEntryInstall_Pre_Routine_NA : ctx->Map.pcs[ 3 ] + ); + RtemsIntrReqEntryInstall_Pre_Init_Prepare( ctx, ctx->Map.pcs[ 4 ] ); + RtemsIntrReqEntryInstall_Pre_ISR_Prepare( ctx, ctx->Map.pcs[ 5 ] ); + RtemsIntrReqEntryInstall_Pre_CanEnable_Prepare( + ctx, + ctx->Map.entry.Pre_CanEnable_NA ? RtemsIntrReqEntryInstall_Pre_CanEnable_NA : ctx->Map.pcs[ 6 ] + ); + RtemsIntrReqEntryInstall_Pre_Installed_Prepare( + ctx, + ctx->Map.entry.Pre_Installed_NA ? RtemsIntrReqEntryInstall_Pre_Installed_NA : ctx->Map.pcs[ 7 ] + ); + RtemsIntrReqEntryInstall_Action( ctx ); + RtemsIntrReqEntryInstall_Post_Status_Check( + ctx, + ctx->Map.entry.Post_Status + ); + RtemsIntrReqEntryInstall_Post_Enable_Check( + ctx, + ctx->Map.entry.Post_Enable + ); + RtemsIntrReqEntryInstall_Post_Installed_Check( + ctx, + ctx->Map.entry.Post_Installed + ); +} + /** * @fn void T_case_body_RtemsIntrReqEntryInstall( void ) */ @@ -1237,120 +1299,55 @@ T_TEST_CASE_FIXTURE( ) { RtemsIntrReqEntryInstall_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 ] = RtemsIntrReqEntryInstall_Pre_Vector_Valid; - ctx->pcs[ 0 ] < RtemsIntrReqEntryInstall_Pre_Vector_NA; - ++ctx->pcs[ 0 ] + ctx->Map.pcs[ 0 ] = RtemsIntrReqEntryInstall_Pre_Vector_Valid; + ctx->Map.pcs[ 0 ] < RtemsIntrReqEntryInstall_Pre_Vector_NA; + ++ctx->Map.pcs[ 0 ] ) { for ( - ctx->pcs[ 1 ] = RtemsIntrReqEntryInstall_Pre_Options_Unique; - ctx->pcs[ 1 ] < RtemsIntrReqEntryInstall_Pre_Options_NA; - ++ctx->pcs[ 1 ] + ctx->Map.pcs[ 1 ] = RtemsIntrReqEntryInstall_Pre_Options_Unique; + ctx->Map.pcs[ 1 ] < RtemsIntrReqEntryInstall_Pre_Options_NA; + ++ctx->Map.pcs[ 1 ] ) { for ( - ctx->pcs[ 2 ] = RtemsIntrReqEntryInstall_Pre_Entry_Obj; - ctx->pcs[ 2 ] < RtemsIntrReqEntryInstall_Pre_Entry_NA; - ++ctx->pcs[ 2 ] + ctx->Map.pcs[ 2 ] = RtemsIntrReqEntryInstall_Pre_Entry_Obj; + ctx->Map.pcs[ 2 ] < RtemsIntrReqEntryInstall_Pre_Entry_NA; + ++ctx->Map.pcs[ 2 ] ) { for ( - ctx->pcs[ 3 ] = RtemsIntrReqEntryInstall_Pre_Routine_Valid; - ctx->pcs[ 3 ] < RtemsIntrReqEntryInstall_Pre_Routine_NA; - ++ctx->pcs[ 3 ] + ctx->Map.pcs[ 3 ] = RtemsIntrReqEntryInstall_Pre_Routine_Valid; + ctx->Map.pcs[ 3 ] < RtemsIntrReqEntryInstall_Pre_Routine_NA; + ++ctx->Map.pcs[ 3 ] ) { for ( - ctx->pcs[ 4 ] = RtemsIntrReqEntryInstall_Pre_Init_Yes; - ctx->pcs[ 4 ] < RtemsIntrReqEntryInstall_Pre_Init_NA; - ++ctx->pcs[ 4 ] + ctx->Map.pcs[ 4 ] = RtemsIntrReqEntryInstall_Pre_Init_Yes; + ctx->Map.pcs[ 4 ] < RtemsIntrReqEntryInstall_Pre_Init_NA; + ++ctx->Map.pcs[ 4 ] ) { for ( - ctx->pcs[ 5 ] = RtemsIntrReqEntryInstall_Pre_ISR_Yes; - ctx->pcs[ 5 ] < RtemsIntrReqEntryInstall_Pre_ISR_NA; - ++ctx->pcs[ 5 ] + ctx->Map.pcs[ 5 ] = RtemsIntrReqEntryInstall_Pre_ISR_Yes; + ctx->Map.pcs[ 5 ] < RtemsIntrReqEntryInstall_Pre_ISR_NA; + ++ctx->Map.pcs[ 5 ] ) { for ( - ctx->pcs[ 6 ] = RtemsIntrReqEntryInstall_Pre_CanEnable_Yes; - ctx->pcs[ 6 ] < RtemsIntrReqEntryInstall_Pre_CanEnable_NA; - ++ctx->pcs[ 6 ] + ctx->Map.pcs[ 6 ] = RtemsIntrReqEntryInstall_Pre_CanEnable_Yes; + ctx->Map.pcs[ 6 ] < RtemsIntrReqEntryInstall_Pre_CanEnable_NA; + ++ctx->Map.pcs[ 6 ] ) { for ( - ctx->pcs[ 7 ] = RtemsIntrReqEntryInstall_Pre_Installed_None; - ctx->pcs[ 7 ] < RtemsIntrReqEntryInstall_Pre_Installed_NA; - ++ctx->pcs[ 7 ] + ctx->Map.pcs[ 7 ] = RtemsIntrReqEntryInstall_Pre_Installed_None; + ctx->Map.pcs[ 7 ] < RtemsIntrReqEntryInstall_Pre_Installed_NA; + ++ctx->Map.pcs[ 7 ] ) { - RtemsIntrReqEntryInstall_Entry entry; - size_t pcs[ 8 ]; - - entry = RtemsIntrReqEntryInstall_GetEntry( index ); - ++index; - - memcpy( pcs, ctx->pcs, sizeof( pcs ) ); - - if ( entry.Pre_Routine_NA ) { - ctx->pcs[ 3 ] = RtemsIntrReqEntryInstall_Pre_Routine_NA; - } - - if ( entry.Pre_CanEnable_NA ) { - ctx->pcs[ 6 ] = RtemsIntrReqEntryInstall_Pre_CanEnable_NA; - } - - if ( entry.Pre_Installed_NA ) { - ctx->pcs[ 7 ] = RtemsIntrReqEntryInstall_Pre_Installed_NA; - } - + ctx->Map.entry = RtemsIntrReqEntryInstall_PopEntry( ctx ); RtemsIntrReqEntryInstall_Prepare( ctx ); - RtemsIntrReqEntryInstall_Pre_Vector_Prepare( - ctx, - ctx->pcs[ 0 ] - ); - RtemsIntrReqEntryInstall_Pre_Options_Prepare( - ctx, - ctx->pcs[ 1 ] - ); - RtemsIntrReqEntryInstall_Pre_Entry_Prepare( - ctx, - ctx->pcs[ 2 ] - ); - RtemsIntrReqEntryInstall_Pre_Routine_Prepare( - ctx, - ctx->pcs[ 3 ] - ); - RtemsIntrReqEntryInstall_Pre_Init_Prepare( - ctx, - ctx->pcs[ 4 ] - ); - RtemsIntrReqEntryInstall_Pre_ISR_Prepare( - ctx, - ctx->pcs[ 5 ] - ); - RtemsIntrReqEntryInstall_Pre_CanEnable_Prepare( - ctx, - ctx->pcs[ 6 ] - ); - RtemsIntrReqEntryInstall_Pre_Installed_Prepare( - ctx, - ctx->pcs[ 7 ] - ); - RtemsIntrReqEntryInstall_Action( ctx ); - RtemsIntrReqEntryInstall_Post_Status_Check( - ctx, - entry.Post_Status - ); - RtemsIntrReqEntryInstall_Post_Enable_Check( - ctx, - entry.Post_Enable - ); - RtemsIntrReqEntryInstall_Post_Installed_Check( - ctx, - entry.Post_Installed - ); + RtemsIntrReqEntryInstall_TestVariant( ctx ); RtemsIntrReqEntryInstall_Cleanup( ctx ); - memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) ); } } } -- cgit v1.2.3