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.
This commit is contained in:
Sebastian Huber
2022-11-09 16:55:15 +01:00
parent 4a46161b3f
commit f151e6f680
3 changed files with 98 additions and 3 deletions
+30 -1
View File
@@ -189,6 +189,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 This member provides the attributes of the testable interrupt
* vector.
@@ -1120,6 +1126,11 @@ static void RtemsIntrReqEntryInstall_Setup(
ctx->initialized_during_setup = bsp_interrupt_is_initialized();
ctx->test_vector = GetTestableInterruptVector( &required );
ctx->test_vector_was_enabled = false;
(void) rtems_interrupt_vector_is_enabled(
ctx->test_vector,
&ctx->test_vector_was_enabled
);
sc = rtems_interrupt_get_attributes( ctx->test_vector, &ctx->attributes );
T_rsc_success( sc );
}
@@ -1133,6 +1144,24 @@ static void RtemsIntrReqEntryInstall_Setup_Wrap( void *arg )
RtemsIntrReqEntryInstall_Setup( ctx );
}
static void RtemsIntrReqEntryInstall_Teardown(
RtemsIntrReqEntryInstall_Context *ctx
)
{
if ( ctx->test_vector_was_enabled ) {
(void) rtems_interrupt_vector_enable( ctx->test_vector );
}
}
static void RtemsIntrReqEntryInstall_Teardown_Wrap( void *arg )
{
RtemsIntrReqEntryInstall_Context *ctx;
ctx = arg;
ctx->Map.in_action_loop = false;
RtemsIntrReqEntryInstall_Teardown( ctx );
}
static void RtemsIntrReqEntryInstall_Prepare(
RtemsIntrReqEntryInstall_Context *ctx
)
@@ -1320,7 +1349,7 @@ static size_t RtemsIntrReqEntryInstall_Scope( void *arg, char *buf, size_t n )
static T_fixture RtemsIntrReqEntryInstall_Fixture = {
.setup = RtemsIntrReqEntryInstall_Setup_Wrap,
.stop = NULL,
.teardown = NULL,
.teardown = RtemsIntrReqEntryInstall_Teardown_Wrap,
.scope = RtemsIntrReqEntryInstall_Scope,
.initial_context = &RtemsIntrReqEntryInstall_Instance
};
+30 -1
View File
@@ -233,6 +233,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 This member provides the attributes of the testable interrupt
* vector.
@@ -1088,6 +1094,11 @@ static void RtemsIntrReqEntryRemove_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
);
sc = rtems_interrupt_get_attributes( ctx->test_vector, &ctx->attributes );
T_rsc_success( sc );
}
@@ -1101,6 +1112,24 @@ static void RtemsIntrReqEntryRemove_Setup_Wrap( void *arg )
RtemsIntrReqEntryRemove_Setup( ctx );
}
static void RtemsIntrReqEntryRemove_Teardown(
RtemsIntrReqEntryRemove_Context *ctx
)
{
if ( ctx->test_vector_was_enabled ) {
(void) rtems_interrupt_vector_enable( ctx->test_vector );
}
}
static void RtemsIntrReqEntryRemove_Teardown_Wrap( void *arg )
{
RtemsIntrReqEntryRemove_Context *ctx;
ctx = arg;
ctx->Map.in_action_loop = false;
RtemsIntrReqEntryRemove_Teardown( ctx );
}
static void RtemsIntrReqEntryRemove_Prepare(
RtemsIntrReqEntryRemove_Context *ctx
)
@@ -1292,7 +1321,7 @@ static size_t RtemsIntrReqEntryRemove_Scope( void *arg, char *buf, size_t n )
static T_fixture RtemsIntrReqEntryRemove_Fixture = {
.setup = RtemsIntrReqEntryRemove_Setup_Wrap,
.stop = NULL,
.teardown = NULL,
.teardown = RtemsIntrReqEntryRemove_Teardown_Wrap,
.scope = RtemsIntrReqEntryRemove_Scope,
.initial_context = &RtemsIntrReqEntryRemove_Instance
};
@@ -133,6 +133,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.
*/
@@ -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
};