summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-intr-handler-iterate.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-11-09 14:41:26 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-11-09 16:55:15 +0100
commitf151e6f68015b63c1f39d513ce35d5c4e2bca08f (patch)
tree94bece074c7ee50603eb09ec85f1f88b53ce9c62 /testsuites/validation/tc-intr-handler-iterate.c
parentriscv: Simplify _CPU_ISR_Set_level() (diff)
downloadrtems-f151e6f68015b63c1f39d513ce35d5c4e2bca08f.tar.bz2
validation: Properly teardown test cases
Make sure that the state of the testable interrupt vector is restored to the state at the test case begin.
Diffstat (limited to '')
-rw-r--r--testsuites/validation/tc-intr-handler-iterate.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/testsuites/validation/tc-intr-handler-iterate.c b/testsuites/validation/tc-intr-handler-iterate.c
index 77b9b2b7d7..66259318c8 100644
--- a/testsuites/validation/tc-intr-handler-iterate.c
+++ b/testsuites/validation/tc-intr-handler-iterate.c
@@ -134,6 +134,12 @@ typedef struct {
rtems_vector_number test_vector;
/**
+ * @brief If this member is true, then the testable interrupt vector was
+ * enabled at the test case begin.
+ */
+ bool test_vector_was_enabled;
+
+ /**
* @brief If this member is true, then the service shall be initialized.
*/
bool initialized;
@@ -506,6 +512,11 @@ static void RtemsIntrReqHandlerIterate_Setup(
ctx->initialized_during_setup = bsp_interrupt_is_initialized();
ctx->test_vector = GetTestableInterruptVector( NULL );
+ ctx->test_vector_was_enabled = false;
+ (void) rtems_interrupt_vector_is_enabled(
+ ctx->test_vector,
+ &ctx->test_vector_was_enabled
+ );
rtems_interrupt_entry_initialize(
&ctx->entry,
EntryRoutine,
@@ -529,6 +540,32 @@ static void RtemsIntrReqHandlerIterate_Setup_Wrap( void *arg )
RtemsIntrReqHandlerIterate_Setup( ctx );
}
+static void RtemsIntrReqHandlerIterate_Teardown(
+ RtemsIntrReqHandlerIterate_Context *ctx
+)
+{
+ rtems_status_code sc;
+
+ sc = rtems_interrupt_entry_remove(
+ ctx->test_vector,
+ &ctx->entry
+ );
+ T_rsc_success( sc );
+
+ if ( ctx->test_vector_was_enabled ) {
+ (void) rtems_interrupt_vector_enable( ctx->test_vector );
+ }
+}
+
+static void RtemsIntrReqHandlerIterate_Teardown_Wrap( void *arg )
+{
+ RtemsIntrReqHandlerIterate_Context *ctx;
+
+ ctx = arg;
+ ctx->Map.in_action_loop = false;
+ RtemsIntrReqHandlerIterate_Teardown( ctx );
+}
+
static void RtemsIntrReqHandlerIterate_Action(
RtemsIntrReqHandlerIterate_Context *ctx
)
@@ -586,7 +623,7 @@ static size_t RtemsIntrReqHandlerIterate_Scope(
static T_fixture RtemsIntrReqHandlerIterate_Fixture = {
.setup = RtemsIntrReqHandlerIterate_Setup_Wrap,
.stop = NULL,
- .teardown = NULL,
+ .teardown = RtemsIntrReqHandlerIterate_Teardown_Wrap,
.scope = RtemsIntrReqHandlerIterate_Scope,
.initial_context = &RtemsIntrReqHandlerIterate_Instance
};