[rtems-central commit] spec: Improve bsp_interrupt_spurious() test case
Sebastian Huber
sebh at rtems.org
Fri Aug 6 12:21:44 UTC 2021
Module: rtems-central
Branch: master
Commit: 9e4aced864307d2e3db3589ccaeb42ac41082546
Changeset: http://git.rtems.org/rtems-central/commit/?id=9e4aced864307d2e3db3589ccaeb42ac41082546
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Aug 5 08:50:29 2021 +0200
spec: Improve bsp_interrupt_spurious() test case
---
spec/bsp/req/interrupt-spurious.yml | 92 ++++++++++++++++++++++++++-----------
1 file changed, 64 insertions(+), 28 deletions(-)
diff --git a/spec/bsp/req/interrupt-spurious.yml b/spec/bsp/req/interrupt-spurious.yml
index c96a9a5..9495828 100644
--- a/spec/bsp/req/interrupt-spurious.yml
+++ b/spec/bsp/req/interrupt-spurious.yml
@@ -38,7 +38,7 @@ post-conditions:
states:
- name: Vector
test-code: |
- T_eq_ulong( ctx->fatal_code, ctx->vector );
+ T_eq_ulong( ctx->fatal_code, ctx->test_vector );
text: |
The fatal code shall be equal to the ``vector`` parameter.
test-epilogue: null
@@ -66,15 +66,27 @@ references: []
requirement-type: functional
skip-reasons: {}
test-action: |
+ ctx->interrupt_occurred = false;
ctx->entry_counter = 0;
ctx->fatal_counter = 0;
ctx->fatal_source = RTEMS_FATAL_SOURCE_LAST;
ctx->fatal_code = UINT32_MAX;
if ( *ctx->first == NULL ) {
- bsp_interrupt_handler_dispatch_unchecked( ctx->vector );
+ 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 */
+ }
+
+ Disable( ctx );
} else {
- bsp_interrupt_spurious( ctx->vector );
+ bsp_interrupt_spurious( ctx->test_vector );
}
test-brief: null
test-cleanup: null
@@ -90,6 +102,16 @@ test-context:
member: |
rtems_interrupt_entry entry
- brief: |
+ If this member is true, then the interrupt shall be cleared.
+ description: null
+ member: |
+ bool do_clear
+- brief: |
+ This member is true, then an interrupt occurred.
+ description: null
+ member: |
+ volatile bool interrupt_occurred
+- brief: |
This member provides an entry dispatch counter.
description: null
member: |
@@ -110,10 +132,10 @@ test-context:
member: |
rtems_fatal_code fatal_code
- brief: |
- This member contains a valid vector number.
+ This member contains the vector number of a testable interrupt.
description: null
member: |
- rtems_vector_number vector
+ rtems_vector_number test_vector
- brief: |
This member references the pointer to the first entry of the interrupt
vector.
@@ -132,28 +154,21 @@ test-prepare: null
test-setup:
brief: null
code: |
- rtems_vector_number vector;
+ rtems_interrupt_attributes attr = {
+ .can_raise = true
+ };
+ rtems_status_code sc;
- for ( vector = 0; vector < BSP_INTERRUPT_VECTOR_COUNT; ++vector ) {
- rtems_status_code sc;
- rtems_interrupt_attributes attributes;
-
- 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 );
@@ -164,12 +179,32 @@ test-support: |
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(
@@ -188,22 +223,23 @@ test-support: |
longjmp( ctx->before_call, 1 );
}
- void __real_bsp_interrupt_spurious( rtems_vector_number vector );
+ void __real_bsp_interrupt_handler_default( rtems_vector_number vector );
- void __wrap_bsp_interrupt_spurious( rtems_vector_number vector );
+ void __wrap_bsp_interrupt_handler_default( rtems_vector_number vector );
- void __wrap_bsp_interrupt_spurious( 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_spurious( vector );
+ __real_bsp_interrupt_handler_default( vector );
}
} else {
- __real_bsp_interrupt_spurious( vector );
+ __real_bsp_interrupt_handler_default( vector );
}
}
test-target: testsuites/validation/tc-bsp-interrupt-spurious.c
More information about the vc
mailing list