summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-intr-handler-iterate.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/validation/tc-intr-handler-iterate.c')
-rw-r--r--testsuites/validation/tc-intr-handler-iterate.c193
1 files changed, 130 insertions, 63 deletions
diff --git a/testsuites/validation/tc-intr-handler-iterate.c b/testsuites/validation/tc-intr-handler-iterate.c
index 707ea44527..fc3f498838 100644
--- a/testsuites/validation/tc-intr-handler-iterate.c
+++ b/testsuites/validation/tc-intr-handler-iterate.c
@@ -3,11 +3,11 @@
/**
* @file
*
- * @ingroup RTEMSTestCaseRtemsIntrReqHandlerIterate
+ * @ingroup RtemsIntrReqHandlerIterate
*/
/*
- * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2021 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -60,10 +60,9 @@
#include <rtems/test.h>
/**
- * @defgroup RTEMSTestCaseRtemsIntrReqHandlerIterate \
- * spec:/rtems/intr/req/handler-iterate
+ * @defgroup RtemsIntrReqHandlerIterate spec:/rtems/intr/req/handler-iterate
*
- * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ * @ingroup TestsuitesValidationIntr
*
* @{
*/
@@ -107,6 +106,16 @@ typedef enum {
RtemsIntrReqHandlerIterate_Post_Visit_NA
} RtemsIntrReqHandlerIterate_Post_Visit;
+typedef struct {
+ uint16_t Skip : 1;
+ uint16_t Pre_Vector_NA : 1;
+ uint16_t Pre_Routine_NA : 1;
+ uint16_t Pre_Init_NA : 1;
+ uint16_t Pre_ISR_NA : 1;
+ uint16_t Post_Status : 3;
+ uint16_t Post_Visit : 2;
+} RtemsIntrReqHandlerIterate_Entry;
+
/**
* @brief Test context for spec:/rtems/intr/req/handler-iterate test case.
*/
@@ -124,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.
*/
bool initialized;
@@ -160,16 +175,33 @@ typedef struct {
*/
rtems_status_code status;
- /**
- * @brief This member defines the pre-condition states for the next action.
- */
- size_t pcs[ 4 ];
-
- /**
- * @brief This member indicates if the test action loop is currently
- * executed.
- */
- bool in_action_loop;
+ struct {
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 4 ];
+
+ /**
+ * @brief If this member is true, then the test action loop is executed.
+ */
+ bool in_action_loop;
+
+ /**
+ * @brief This member contains the next transition map index.
+ */
+ size_t index;
+
+ /**
+ * @brief This member contains the current transition map entry.
+ */
+ RtemsIntrReqHandlerIterate_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
} RtemsIntrReqHandlerIterate_Context;
static RtemsIntrReqHandlerIterate_Context
@@ -255,7 +287,7 @@ static void Action( void *arg )
ctx->visited_entries = 0;
bsp_interrupt_set_handler_unique(
- BSP_INTERRUPT_HANDLER_TABLE_SIZE,
+ BSP_INTERRUPT_DISPATCH_TABLE_SIZE,
ctx->initialized
);
@@ -266,7 +298,7 @@ static void Action( void *arg )
);
bsp_interrupt_set_handler_unique(
- BSP_INTERRUPT_HANDLER_TABLE_SIZE,
+ BSP_INTERRUPT_DISPATCH_TABLE_SIZE,
ctx->initialized_during_setup
);
}
@@ -478,7 +510,12 @@ static void RtemsIntrReqHandlerIterate_Setup(
rtems_status_code sc;
ctx->initialized_during_setup = bsp_interrupt_is_initialized();
- ctx->test_vector = GetTestableInterruptVector();
+ 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,
@@ -498,10 +535,36 @@ static void RtemsIntrReqHandlerIterate_Setup_Wrap( void *arg )
RtemsIntrReqHandlerIterate_Context *ctx;
ctx = arg;
- ctx->in_action_loop = false;
+ ctx->Map.in_action_loop = false;
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
)
@@ -513,16 +576,6 @@ static void RtemsIntrReqHandlerIterate_Action(
}
}
-typedef struct {
- uint16_t Skip : 1;
- uint16_t Pre_Vector_NA : 1;
- uint16_t Pre_Routine_NA : 1;
- uint16_t Pre_Init_NA : 1;
- uint16_t Pre_ISR_NA : 1;
- uint16_t Post_Status : 3;
- uint16_t Post_Visit : 2;
-} RtemsIntrReqHandlerIterate_Entry;
-
static const RtemsIntrReqHandlerIterate_Entry
RtemsIntrReqHandlerIterate_Entries[] = {
{ 0, 0, 0, 0, 0, RtemsIntrReqHandlerIterate_Post_Status_IncStat,
@@ -554,8 +607,13 @@ static size_t RtemsIntrReqHandlerIterate_Scope(
ctx = arg;
- if ( ctx->in_action_loop ) {
- return T_get_scope( RtemsIntrReqHandlerIterate_PreDesc, buf, n, ctx->pcs );
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope(
+ RtemsIntrReqHandlerIterate_PreDesc,
+ buf,
+ n,
+ ctx->Map.pcs
+ );
}
return 0;
@@ -564,19 +622,42 @@ 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
};
static inline RtemsIntrReqHandlerIterate_Entry
-RtemsIntrReqHandlerIterate_GetEntry( size_t index )
+RtemsIntrReqHandlerIterate_PopEntry( RtemsIntrReqHandlerIterate_Context *ctx )
{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
return RtemsIntrReqHandlerIterate_Entries[
RtemsIntrReqHandlerIterate_Map[ index ]
];
}
+static void RtemsIntrReqHandlerIterate_TestVariant(
+ RtemsIntrReqHandlerIterate_Context *ctx
+)
+{
+ RtemsIntrReqHandlerIterate_Pre_Vector_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsIntrReqHandlerIterate_Pre_Routine_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ RtemsIntrReqHandlerIterate_Pre_Init_Prepare( ctx, ctx->Map.pcs[ 2 ] );
+ RtemsIntrReqHandlerIterate_Pre_ISR_Prepare( ctx, ctx->Map.pcs[ 3 ] );
+ RtemsIntrReqHandlerIterate_Action( ctx );
+ RtemsIntrReqHandlerIterate_Post_Status_Check(
+ ctx,
+ ctx->Map.entry.Post_Status
+ );
+ RtemsIntrReqHandlerIterate_Post_Visit_Check(
+ ctx,
+ ctx->Map.entry.Post_Visit
+ );
+}
+
/**
* @fn void T_case_body_RtemsIntrReqHandlerIterate( void )
*/
@@ -586,47 +667,33 @@ T_TEST_CASE_FIXTURE(
)
{
RtemsIntrReqHandlerIterate_Context *ctx;
- size_t index;
ctx = T_fixture_context();
- ctx->in_action_loop = true;
- index = 0;
+ ctx->Map.in_action_loop = true;
+ ctx->Map.index = 0;
for (
- ctx->pcs[ 0 ] = RtemsIntrReqHandlerIterate_Pre_Vector_Valid;
- ctx->pcs[ 0 ] < RtemsIntrReqHandlerIterate_Pre_Vector_NA;
- ++ctx->pcs[ 0 ]
+ ctx->Map.pcs[ 0 ] = RtemsIntrReqHandlerIterate_Pre_Vector_Valid;
+ ctx->Map.pcs[ 0 ] < RtemsIntrReqHandlerIterate_Pre_Vector_NA;
+ ++ctx->Map.pcs[ 0 ]
) {
for (
- ctx->pcs[ 1 ] = RtemsIntrReqHandlerIterate_Pre_Routine_Valid;
- ctx->pcs[ 1 ] < RtemsIntrReqHandlerIterate_Pre_Routine_NA;
- ++ctx->pcs[ 1 ]
+ ctx->Map.pcs[ 1 ] = RtemsIntrReqHandlerIterate_Pre_Routine_Valid;
+ ctx->Map.pcs[ 1 ] < RtemsIntrReqHandlerIterate_Pre_Routine_NA;
+ ++ctx->Map.pcs[ 1 ]
) {
for (
- ctx->pcs[ 2 ] = RtemsIntrReqHandlerIterate_Pre_Init_Yes;
- ctx->pcs[ 2 ] < RtemsIntrReqHandlerIterate_Pre_Init_NA;
- ++ctx->pcs[ 2 ]
+ ctx->Map.pcs[ 2 ] = RtemsIntrReqHandlerIterate_Pre_Init_Yes;
+ ctx->Map.pcs[ 2 ] < RtemsIntrReqHandlerIterate_Pre_Init_NA;
+ ++ctx->Map.pcs[ 2 ]
) {
for (
- ctx->pcs[ 3 ] = RtemsIntrReqHandlerIterate_Pre_ISR_Yes;
- ctx->pcs[ 3 ] < RtemsIntrReqHandlerIterate_Pre_ISR_NA;
- ++ctx->pcs[ 3 ]
+ ctx->Map.pcs[ 3 ] = RtemsIntrReqHandlerIterate_Pre_ISR_Yes;
+ ctx->Map.pcs[ 3 ] < RtemsIntrReqHandlerIterate_Pre_ISR_NA;
+ ++ctx->Map.pcs[ 3 ]
) {
- RtemsIntrReqHandlerIterate_Entry entry;
-
- entry = RtemsIntrReqHandlerIterate_GetEntry( index );
- ++index;
-
- RtemsIntrReqHandlerIterate_Pre_Vector_Prepare( ctx, ctx->pcs[ 0 ] );
- RtemsIntrReqHandlerIterate_Pre_Routine_Prepare( ctx, ctx->pcs[ 1 ] );
- RtemsIntrReqHandlerIterate_Pre_Init_Prepare( ctx, ctx->pcs[ 2 ] );
- RtemsIntrReqHandlerIterate_Pre_ISR_Prepare( ctx, ctx->pcs[ 3 ] );
- RtemsIntrReqHandlerIterate_Action( ctx );
- RtemsIntrReqHandlerIterate_Post_Status_Check(
- ctx,
- entry.Post_Status
- );
- RtemsIntrReqHandlerIterate_Post_Visit_Check( ctx, entry.Post_Visit );
+ ctx->Map.entry = RtemsIntrReqHandlerIterate_PopEntry( ctx );
+ RtemsIntrReqHandlerIterate_TestVariant( ctx );
}
}
}