diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-10 09:04:01 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-31 07:13:56 +0200 |
commit | 81655e316e19d770ce5d32372d90a587b90ef8bf (patch) | |
tree | 3bd54ff35c1bb6192ab5d8970773de739518e86e | |
parent | d59baa5349646c18787d35690c6707317d78fa98 (diff) |
validation: rtems_interrupt_entry_install()
Check that the handler of the entries installed by
rtems_interrupt_entry_install() are invoked in the right order.
-rw-r--r-- | testsuites/validation/tc-intr-entry-install.c | 124 |
1 files changed, 101 insertions, 23 deletions
diff --git a/testsuites/validation/tc-intr-entry-install.c b/testsuites/validation/tc-intr-entry-install.c index f5280c1e73..a722db0cac 100644 --- a/testsuites/validation/tc-intr-entry-install.c +++ b/testsuites/validation/tc-intr-entry-install.c @@ -174,9 +174,14 @@ typedef struct { bool initialized_during_setup; /** - * @brief If this member is true, then an interrupt occurred. + * @brief This member provides a counter for handler invocations. */ - bool interrupt_occurred; + uint32_t handler_counter; + + /** + * @brief This member provides a counter snapshot for each entry. + */ + uint32_t counter_by_entry[ 3 ];; /** * @brief This member provides the vector number of a testable interrupt @@ -409,29 +414,66 @@ static void Install( ctx->other_installed = true; } -static void OtherRoutine( void *arg ) +static void Routine( Context *ctx, uint32_t counter ) { - Context *ctx; rtems_status_code sc; - (void) arg; - ctx = T_fixture_context(); - sc = rtems_interrupt_vector_disable( ctx->test_vector ); - T_rsc_success( sc ); + ctx->handler_counter = counter; - ctx->interrupt_occurred = true; + if ( + ctx->attributes.can_clear && + !ctx->attributes.cleared_by_acknowledge + ) { + sc = rtems_interrupt_clear( ctx->test_vector ); + T_rsc_success( sc ); + } + + if ( counter > 3 ) { + sc = rtems_interrupt_vector_disable( ctx->test_vector ); + T_rsc_success( sc ); + } } static void EntryRoutine( void *arg ) { - T_eq_ptr( arg, &entry_arg ); - OtherRoutine( NULL ); + Context *ctx; + uint32_t counter; + + ctx = T_fixture_context(); + counter = ctx->handler_counter + 1; + + if ( arg == &other_arg ) { + ctx->counter_by_entry[ 1 ] = counter; + } else { + ctx->counter_by_entry[ 0 ] = counter; + T_eq_ptr( arg, &entry_arg ); + } + + Routine( ctx, counter ); +} + +static void OtherRoutine( void *arg ) +{ + Context *ctx; + uint32_t counter; + + (void) arg; + ctx = T_fixture_context(); + counter = ctx->handler_counter + 1; + ctx->counter_by_entry[ 1 ] = counter; + Routine( ctx, counter ); } static void ThirdRoutine( void *arg ) { + Context *ctx; + uint32_t counter; + + ctx = T_fixture_context(); + counter = ctx->handler_counter + 1; + ctx->counter_by_entry[ 2 ] = counter; T_eq_ptr( arg, &third_arg ); - OtherRoutine( NULL ); + Routine( ctx, counter ); } static void InstallThird( Context *ctx ) @@ -489,6 +531,11 @@ static void Action( void *arg ) &ctx->enabled_after ); T_rsc_success( sc ); + + if ( ctx->status == RTEMS_SUCCESSFUL ) { + sc = rtems_interrupt_raise( ctx->test_vector ); + T_rsc_success( sc ); + } } static void VisitInstalled( @@ -940,7 +987,7 @@ static void RtemsIntrReqEntryInstall_Post_Enable_Check( * The enabled status of the interrupt vector specified by ``vector`` * shall not be modified by the rtems_interrupt_entry_install() call. */ - if ( !ctx->interrupt_occurred ) { + if ( ctx->handler_counter == 0 ) { T_eq( ctx->enabled_before, ctx->enabled_after ); } break; @@ -950,9 +997,7 @@ static void RtemsIntrReqEntryInstall_Post_Enable_Check( /* * The interrupt vector specified by ``vector`` shall be enabled. */ - if ( ctx->attributes.can_enable ) { - T_true( ctx->enabled_after || ctx->interrupt_occurred ); - } + T_true( ctx->enabled_after || ctx->handler_counter > 3 ); break; } @@ -960,10 +1005,13 @@ static void RtemsIntrReqEntryInstall_Post_Enable_Check( /* * The interrupt vector specified by ``vector`` may be enabled. */ - /* The comment of pre-condition ``CanEnable`` for the ``Yes`` state. */ - if ( ctx->attributes.can_enable ) { - T_true( ctx->enabled_after || ctx->interrupt_occurred ); - } + /* + * Interrupt vectors which cannot be enabled are not selected as a + * testable interrupt vector by GetTestableInterruptVector(), so this + * path is not validated by this test. See also comment for + * ``CanEnable`` pre-condition state ``Yes``. + */ + T_true( ctx->enabled_after || ctx->handler_counter > 3 ); break; } @@ -973,8 +1021,11 @@ static void RtemsIntrReqEntryInstall_Post_Enable_Check( */ /* * Interrupt vectors which cannot be enabled are not selected as a - * testable interrupt vector by GetTestableInterruptVector(). + * testable interrupt vector by GetTestableInterruptVector(), so this + * path is not validated by this test. See also comment for + * ``CanEnable`` pre-condition state ``Yes``. */ + T_true( ctx->enabled_after || ctx->handler_counter > 3 ); break; } @@ -998,6 +1049,24 @@ static void RtemsIntrReqEntryInstall_Post_Installed_Check( ); T_rsc_success( sc ); + if ( ctx->status == RTEMS_SUCCESSFUL ) { + uint32_t counter; + + counter = 1; + + if ( ctx->other_installed ) { + T_eq_u32( ctx->counter_by_entry[ 1 ], counter ); + ++counter; + } + + if ( ctx->third_installed ) { + T_eq_u32( ctx->counter_by_entry[ 2 ], counter ); + ++counter; + } + + T_eq_u32( ctx->counter_by_entry[ 0 ], counter ); + } + switch ( state ) { case RtemsIntrReqEntryInstall_Post_Installed_No: { /* @@ -1038,10 +1107,13 @@ static void RtemsIntrReqEntryInstall_Setup( RtemsIntrReqEntryInstall_Context *ctx ) { + rtems_interrupt_attributes required = { + .can_raise = true + }; rtems_status_code sc; ctx->initialized_during_setup = bsp_interrupt_is_initialized(); - ctx->test_vector = GetTestableInterruptVector( NULL ); + ctx->test_vector = GetTestableInterruptVector( &required ); sc = rtems_interrupt_get_attributes( ctx->test_vector, &ctx->attributes ); T_rsc_success( sc ); } @@ -1059,7 +1131,13 @@ static void RtemsIntrReqEntryInstall_Prepare( RtemsIntrReqEntryInstall_Context *ctx ) { - ctx->interrupt_occurred = false; + size_t i; + + for ( i = 0; i < RTEMS_ARRAY_SIZE( ctx->counter_by_entry ); ++i ) { + ctx->counter_by_entry[ i ] = 0; + } + + ctx->handler_counter = 0; ctx->other_installed = false; ctx->third_installed = false; } |