From 55318d17b40e491839c874ecbb342925c9b1e5ea Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 11 Nov 2022 16:30:09 +0100 Subject: validation: Improve spurious interrupt test case Use the tm27 support to test a spurious interrupt. This helps to run the validation test case on targets which have no software interrupt available for tests (for example riscv/PLIC/CLINT in the SMP configuration). --- testsuites/validation/tc-bsp-interrupt-spurious.c | 40 +++++++++-------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'testsuites/validation/tc-bsp-interrupt-spurious.c') diff --git a/testsuites/validation/tc-bsp-interrupt-spurious.c b/testsuites/validation/tc-bsp-interrupt-spurious.c index f5e992a51d..eb3c98e30a 100644 --- a/testsuites/validation/tc-bsp-interrupt-spurious.c +++ b/testsuites/validation/tc-bsp-interrupt-spurious.c @@ -109,6 +109,12 @@ typedef struct { * @brief Test context for spec:/bsp/req/interrupt-spurious test case. */ typedef struct { + /** + * @brief This member references the interrupt entry to restore during test + * case teardown. + */ + rtems_interrupt_entry *entry_to_restore; + /** * @brief This member provides a jump buffer to return from the fatal error. */ @@ -119,11 +125,6 @@ typedef struct { */ rtems_interrupt_entry entry; - /** - * @brief If this member is true, then the interrupt shall be cleared. - */ - bool do_clear; - /** * @brief This member is true, then an interrupt occurred. */ @@ -234,14 +235,7 @@ static void Disable( const Context *ctx ) static void ProcessInterrupt( Context *ctx ) { ctx->interrupt_occurred = true; - - if ( ctx->do_clear ) { - rtems_status_code sc; - - sc = rtems_interrupt_clear( ctx->test_vector ); - T_rsc_success( sc ); - } - + CallWithinISRClear(); Disable( ctx ); } @@ -424,20 +418,15 @@ static void BspReqInterruptSpurious_Setup( BspReqInterruptSpurious_Context *ctx ) { - rtems_interrupt_attributes attr = { - .can_raise = true - }; rtems_status_code sc; - ctx->test_vector = GetTestableInterruptVector( &attr ); + ctx->first = NULL; + ctx->test_vector = CallWithinISRGetVector(); T_assert_lt_u32( ctx->test_vector, BSP_INTERRUPT_VECTOR_COUNT ); ctx->first = &bsp_interrupt_handler_table[ bsp_interrupt_handler_index( ctx->test_vector ) ]; - - sc = rtems_interrupt_get_attributes( ctx->test_vector, &attr ); - T_rsc_success( sc ); - ctx->do_clear = attr.can_clear && !attr.cleared_by_acknowledge; + ctx->entry_to_restore = *ctx->first; rtems_interrupt_entry_initialize( &ctx->entry, EntryRoutine, ctx, "Info" ); test_case_active = true; @@ -459,6 +448,10 @@ static void BspReqInterruptSpurious_Teardown( { SetFatalHandler( NULL, NULL ); test_case_active = false; + + if ( ctx->first != NULL ) { + *ctx->first = ctx->entry_to_restore; + } } static void BspReqInterruptSpurious_Teardown_Wrap( void *arg ) @@ -487,12 +480,9 @@ static void BspReqInterruptSpurious_Action( } else #endif { - rtems_status_code sc; - (void) rtems_interrupt_vector_enable( ctx->test_vector ); - sc = rtems_interrupt_raise( ctx->test_vector ); - T_rsc_success( sc ); + CallWithinISRRaise(); while ( !ctx->interrupt_occurred ) { /* Wait */ -- cgit v1.2.3