summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-05 08:51:38 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-06 14:06:50 +0200
commitef0d2baeacc4ad426fb581d8dbb415954979377f (patch)
treeab944ddd245b4ccf76fcabc90b2bfa985c074707
parentb0924142cb343d46d872803b8712bea0a10983cc (diff)
testsuites/validation/tc-bsp-interrupt-spurious.c
-rw-r--r--spec/build/testsuites/validation/validation-smp-only-0.yml3
-rw-r--r--testsuites/validation/tc-bsp-interrupt-spurious.c143
2 files changed, 94 insertions, 52 deletions
diff --git a/spec/build/testsuites/validation/validation-smp-only-0.yml b/spec/build/testsuites/validation/validation-smp-only-0.yml
index 0dac7c3081..cfae6dfabb 100644
--- a/spec/build/testsuites/validation/validation-smp-only-0.yml
+++ b/spec/build/testsuites/validation/validation-smp-only-0.yml
@@ -8,7 +8,8 @@ cxxflags: []
enabled-by: RTEMS_SMP
features: c cprogram
includes: []
-ldflags: []
+ldflags:
+- -Wl,--wrap=bsp_interrupt_handler_default
links: []
source:
- 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 accfb03736..8a2549cba6 100644
--- a/testsuites/validation/tc-bsp-interrupt-spurious.c
+++ b/testsuites/validation/tc-bsp-interrupt-spurious.c
@@ -105,6 +105,16 @@ 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.
+ */
+ volatile bool interrupt_occurred;
+
+ /**
* @brief This member provides an entry dispatch counter.
*/
uint32_t entry_counter;
@@ -117,17 +127,17 @@ typedef struct {
/**
* @brief This member contains the fatal source.
*/
- rtems_fatal_source fatal_source[ 2 ];
+ rtems_fatal_source fatal_source;
/**
* @brief This member contains a fatal code.
*/
- rtems_fatal_code fatal_code[ 2 ];
+ rtems_fatal_code fatal_code;
/**
- * @brief This member contains a valid vector number.
+ * @brief This member contains the vector number of a testable interrupt.
*/
- rtems_vector_number vector;
+ rtems_vector_number test_vector;
/**
* @brief This member references the pointer to the first entry of the
@@ -163,12 +173,34 @@ static const char * const * const BspReqInterruptSpurious_PreDesc[] = {
typedef BspReqInterruptSpurious_Context Context;
+static bool test_case_active;
+
+static void Disable( const Context *ctx )
+{
+ (void) rtems_interrupt_vector_disable( ctx->test_vector );
+}
+
+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 );
+ }
+
+ Disable( ctx );
+}
+
static void EntryRoutine( void *arg )
{
Context *ctx;
ctx = arg;
++ctx->entry_counter;
+ ProcessInterrupt( ctx );
}
static void FatalExtension(
@@ -178,19 +210,33 @@ static void FatalExtension(
)
{
Context *ctx;
- uint32_t counter;
ctx = T_fixture_context();
T_false( always_set_to_false );
- counter = ctx->fatal_counter;
- ctx->fatal_counter = counter + 1;
+ ctx->fatal_source = source;
+ ctx->fatal_code = code;
+ ++ctx->fatal_counter;
+ longjmp( ctx->before_call, 1 );
+}
- if ( counter < 2 ) {
- ctx->fatal_source[ counter ] = source;
- ctx->fatal_code[ counter ] = code;
- }
+void __real_bsp_interrupt_handler_default( rtems_vector_number vector );
- longjmp( ctx->before_call, 1 );
+void __wrap_bsp_interrupt_handler_default( rtems_vector_number vector );
+
+void __wrap_bsp_interrupt_handler_default( rtems_vector_number vector )
+{
+ if ( test_case_active ) {
+ Context *ctx;
+
+ ctx = T_fixture_context();
+ ProcessInterrupt( ctx );
+
+ if ( setjmp( ctx->before_call ) == 0 ) {
+ __real_bsp_interrupt_handler_default( vector );
+ }
+ } else {
+ __real_bsp_interrupt_handler_default( vector );
+ }
}
static void BspReqInterruptSpurious_Pre_First_Prepare(
@@ -234,7 +280,7 @@ static void BspReqInterruptSpurious_Post_Result_Check(
* A fatal error shall occur.
*/
T_eq_u32( ctx->entry_counter, 0 );
- T_eq_u32( ctx->fatal_counter, 2 );
+ T_eq_u32( ctx->fatal_counter, 1 );
break;
}
@@ -243,7 +289,7 @@ static void BspReqInterruptSpurious_Post_Result_Check(
* The interrupt entries installed at the interrupt vector specified by
* the ``vector`` parameter shall be dispatched.
*/
- T_eq_u32( ctx->entry_counter, 2 );
+ T_eq_u32( ctx->entry_counter, 1 );
T_eq_u32( ctx->fatal_counter, 0 );
break;
}
@@ -264,14 +310,7 @@ static void BspReqInterruptSpurious_Post_FatalSource_Check(
* The fatal source shall be equal to
* RTEMS_FATAL_SOURCE_SPURIOUS_INTERRUPT.
*/
- T_eq_int(
- ctx->fatal_source[ 0 ],
- RTEMS_FATAL_SOURCE_SPURIOUS_INTERRUPT
- );
- T_eq_int(
- ctx->fatal_source[ 1 ],
- RTEMS_FATAL_SOURCE_SPURIOUS_INTERRUPT
- );
+ T_eq_int( ctx->fatal_source, RTEMS_FATAL_SOURCE_SPURIOUS_INTERRUPT );
break;
}
@@ -290,8 +329,7 @@ static void BspReqInterruptSpurious_Post_FatalCode_Check(
/*
* The fatal code shall be equal to the ``vector`` parameter.
*/
- T_eq_ulong( ctx->fatal_code[ 0 ], ctx->vector );
- T_eq_ulong( ctx->fatal_code[ 1 ], ctx->vector );
+ T_eq_ulong( ctx->fatal_code, ctx->test_vector );
break;
}
@@ -304,29 +342,23 @@ static void BspReqInterruptSpurious_Setup(
BspReqInterruptSpurious_Context *ctx
)
{
- rtems_vector_number vector;
-
- for ( vector = 0; vector < BSP_INTERRUPT_VECTOR_COUNT; ++vector ) {
- rtems_status_code sc;
- rtems_interrupt_attributes attributes;
+ rtems_interrupt_attributes attr = {
+ .can_raise = true
+ };
+ rtems_status_code sc;
- sc = rtems_interrupt_get_attributes( vector, &attributes );
-
- if (
- sc == RTEMS_SUCCESSFUL &&
- !HasInterruptVectorEntriesInstalled( vector )
- ) {
- break;
- }
- }
-
- T_assert_lt_u32( vector, BSP_INTERRUPT_VECTOR_COUNT );
- ctx->vector = vector;
+ ctx->test_vector = GetTestableInterruptVector( &attr );
+ T_assert_lt_u32( ctx->test_vector, BSP_INTERRUPT_VECTOR_COUNT );
ctx->first = &bsp_interrupt_handler_table[
- bsp_interrupt_handler_index( vector )
+ 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;
+
rtems_interrupt_entry_initialize( &ctx->entry, EntryRoutine, ctx, "Info" );
+ test_case_active = true;
SetFatalExtension( FatalExtension );
}
@@ -344,6 +376,7 @@ static void BspReqInterruptSpurious_Teardown(
)
{
SetFatalExtension( NULL );
+ test_case_active = false;
}
static void BspReqInterruptSpurious_Teardown_Wrap( void *arg )
@@ -359,19 +392,27 @@ static void BspReqInterruptSpurious_Action(
BspReqInterruptSpurious_Context *ctx
)
{
+ ctx->interrupt_occurred = false;
ctx->entry_counter = 0;
ctx->fatal_counter = 0;
- ctx->fatal_source[ 0 ] = RTEMS_FATAL_SOURCE_LAST;
- ctx->fatal_source[ 1 ] = RTEMS_FATAL_SOURCE_LAST;
- ctx->fatal_code[ 0 ] = UINT32_MAX;
- ctx->fatal_code[ 1 ] = UINT32_MAX;
+ ctx->fatal_source = RTEMS_FATAL_SOURCE_LAST;
+ ctx->fatal_code = UINT32_MAX;
- if ( setjmp( ctx->before_call ) == 0 ) {
- bsp_interrupt_handler_dispatch_unchecked( ctx->vector );
- }
+ if ( *ctx->first == NULL ) {
+ rtems_status_code sc;
+
+ (void) rtems_interrupt_vector_enable( ctx->test_vector );
+
+ sc = rtems_interrupt_raise( ctx->test_vector );
+ T_rsc_success( sc );
+
+ while ( !ctx->interrupt_occurred ) {
+ /* Wait */
+ }
- if ( setjmp( ctx->before_call ) == 0 ) {
- bsp_interrupt_spurious( ctx->vector );
+ Disable( ctx );
+ } else {
+ bsp_interrupt_spurious( ctx->test_vector );
}
}