summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-intr-is-pending.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/validation/tc-intr-is-pending.c')
-rw-r--r--testsuites/validation/tc-intr-is-pending.c199
1 files changed, 122 insertions, 77 deletions
diff --git a/testsuites/validation/tc-intr-is-pending.c b/testsuites/validation/tc-intr-is-pending.c
index 9a81cb9c23..097e3d7a17 100644
--- a/testsuites/validation/tc-intr-is-pending.c
+++ b/testsuites/validation/tc-intr-is-pending.c
@@ -3,11 +3,11 @@
/**
* @file
*
- * @ingroup RTEMSTestCaseRtemsIntrReqIsPending
+ * @ingroup RtemsIntrReqIsPending
*/
/*
- * 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
@@ -61,9 +61,9 @@
#include <rtems/test.h>
/**
- * @defgroup RTEMSTestCaseRtemsIntrReqIsPending spec:/rtems/intr/req/is-pending
+ * @defgroup RtemsIntrReqIsPending spec:/rtems/intr/req/is-pending
*
- * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ * @ingroup TestsuitesValidationIntr
*
* @{
*/
@@ -100,6 +100,15 @@ typedef enum {
RtemsIntrReqIsPending_Post_IsPending_NA
} RtemsIntrReqIsPending_Post_IsPending;
+typedef struct {
+ uint8_t Skip : 1;
+ uint8_t Pre_Vector_NA : 1;
+ uint8_t Pre_Pending_NA : 1;
+ uint8_t Pre_IsPending_NA : 1;
+ uint8_t Post_Status : 2;
+ uint8_t Post_IsPending : 2;
+} RtemsIntrReqIsPending_Entry;
+
/**
* @brief Test context for spec:/rtems/intr/req/is-pending test case.
*/
@@ -133,7 +142,7 @@ typedef struct {
/**
* @brief This member specifies if the ``pending`` parameter value.
*/
- bool *pending;;
+ bool *pending;
/**
* @brief This member contains the return value of the
@@ -141,16 +150,39 @@ typedef struct {
*/
rtems_status_code status;
- /**
- * @brief This member defines the pre-condition states for the next action.
- */
- size_t pcs[ 3 ];
+ struct {
+ /**
+ * @brief This member defines the pre-condition indices for the next
+ * action.
+ */
+ size_t pci[ 3 ];
- /**
- * @brief This member indicates if the test action loop is currently
- * executed.
- */
- bool in_action_loop;
+ /**
+ * @brief This member defines the pre-condition states for the next action.
+ */
+ size_t pcs[ 3 ];
+
+ /**
+ * @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.
+ */
+ RtemsIntrReqIsPending_Entry entry;
+
+ /**
+ * @brief If this member is true, then the current transition variant
+ * should be skipped.
+ */
+ bool skip;
+ } Map;
} RtemsIntrReqIsPending_Context;
static RtemsIntrReqIsPending_Context
@@ -258,14 +290,21 @@ static void CheckIsPending(
if ( has_installed_entries ) {
/*
* We cannot test this vector thoroughly, since it is used by a device
- * driver.
+ * driver. It may be pending or not. For example in SMP configurations,
+ * it may be pending while being serviced right now on another processor.
*/
- T_false( IsPending( ctx ) );
+ (void) IsPending( ctx );
} else if ( !attr->is_maskable ) {
/* We can only safely test maskable interrupts */
T_false( IsPending( ctx ) );
+ } else if ( IsPending( ctx ) ) {
+ /*
+ * If there is already an interrupt pending, then it is probably raised
+ * by a peripheral which we cannot control.
+ */
} else if (
- attr->can_disable && ( attr->can_clear || attr->cleared_by_acknowledge )
+ attr->can_raise && attr->can_disable &&
+ ( attr->can_clear || attr->cleared_by_acknowledge )
) {
rtems_interrupt_entry entry;
rtems_interrupt_level level;
@@ -281,19 +320,21 @@ static void CheckIsPending(
T_rsc_success( sc );
if ( !IsPending( ctx) && ( attr->can_enable || IsEnabled( ctx ) ) ) {
- if ( attr->can_disable ) {
- Disable( ctx );
- Raise( ctx );
- T_true( IsPending( ctx ) );
-
- sc = rtems_interrupt_vector_enable( ctx->vector );
- T_rsc_success( sc );
-
- while ( ctx->interrupt_count < 1 ) {
- /* Wait */
- }
- } else {
- ++ctx->interrupt_count;
+ Disable( ctx );
+ Raise( ctx );
+
+ /*
+ * Some interrupt controllers will signal a pending interrupt if it is
+ * disabled (for example ARM GIC), others will not signal a pending
+ * interrupt if it is disabled (for example Freescale/NXP MPIC).
+ */
+ (void) IsPending( ctx );
+
+ sc = rtems_interrupt_vector_enable( ctx->vector );
+ T_rsc_success( sc );
+
+ while ( ctx->interrupt_count < 1 ) {
+ /* Wait */
}
rtems_interrupt_local_disable( level );
@@ -514,15 +555,6 @@ static void RtemsIntrReqIsPending_Action( RtemsIntrReqIsPending_Context *ctx )
}
}
-typedef struct {
- uint8_t Skip : 1;
- uint8_t Pre_Vector_NA : 1;
- uint8_t Pre_Pending_NA : 1;
- uint8_t Pre_IsPending_NA : 1;
- uint8_t Post_Status : 2;
- uint8_t Post_IsPending : 2;
-} RtemsIntrReqIsPending_Entry;
-
static const RtemsIntrReqIsPending_Entry
RtemsIntrReqIsPending_Entries[] = {
{ 0, 0, 0, 0, RtemsIntrReqIsPending_Post_Status_InvAddr,
@@ -548,8 +580,8 @@ static size_t RtemsIntrReqIsPending_Scope( void *arg, char *buf, size_t n )
ctx = arg;
- if ( ctx->in_action_loop ) {
- return T_get_scope( RtemsIntrReqIsPending_PreDesc, buf, n, ctx->pcs );
+ if ( ctx->Map.in_action_loop ) {
+ return T_get_scope( RtemsIntrReqIsPending_PreDesc, buf, n, ctx->Map.pcs );
}
return 0;
@@ -563,64 +595,77 @@ static T_fixture RtemsIntrReqIsPending_Fixture = {
.initial_context = &RtemsIntrReqIsPending_Instance
};
-static inline RtemsIntrReqIsPending_Entry RtemsIntrReqIsPending_GetEntry(
- size_t index
+static inline RtemsIntrReqIsPending_Entry RtemsIntrReqIsPending_PopEntry(
+ RtemsIntrReqIsPending_Context *ctx
)
{
+ size_t index;
+
+ index = ctx->Map.index;
+ ctx->Map.index = index + 1;
return RtemsIntrReqIsPending_Entries[
RtemsIntrReqIsPending_Map[ index ]
];
}
+static void RtemsIntrReqIsPending_SetPreConditionStates(
+ RtemsIntrReqIsPending_Context *ctx
+)
+{
+ ctx->Map.pcs[ 0 ] = ctx->Map.pci[ 0 ];
+ ctx->Map.pcs[ 1 ] = ctx->Map.pci[ 1 ];
+
+ if ( ctx->Map.entry.Pre_IsPending_NA ) {
+ ctx->Map.pcs[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_NA;
+ } else {
+ ctx->Map.pcs[ 2 ] = ctx->Map.pci[ 2 ];
+ }
+}
+
+static void RtemsIntrReqIsPending_TestVariant(
+ RtemsIntrReqIsPending_Context *ctx
+)
+{
+ RtemsIntrReqIsPending_Pre_Vector_Prepare( ctx, ctx->Map.pcs[ 0 ] );
+ RtemsIntrReqIsPending_Pre_Pending_Prepare( ctx, ctx->Map.pcs[ 1 ] );
+ RtemsIntrReqIsPending_Pre_IsPending_Prepare( ctx, ctx->Map.pcs[ 2 ] );
+ RtemsIntrReqIsPending_Action( ctx );
+ RtemsIntrReqIsPending_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
+ RtemsIntrReqIsPending_Post_IsPending_Check(
+ ctx,
+ ctx->Map.entry.Post_IsPending
+ );
+}
+
/**
* @fn void T_case_body_RtemsIntrReqIsPending( void )
*/
T_TEST_CASE_FIXTURE( RtemsIntrReqIsPending, &RtemsIntrReqIsPending_Fixture )
{
RtemsIntrReqIsPending_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 ] = RtemsIntrReqIsPending_Pre_Vector_Valid;
- ctx->pcs[ 0 ] < RtemsIntrReqIsPending_Pre_Vector_NA;
- ++ctx->pcs[ 0 ]
+ ctx->Map.pci[ 0 ] = RtemsIntrReqIsPending_Pre_Vector_Valid;
+ ctx->Map.pci[ 0 ] < RtemsIntrReqIsPending_Pre_Vector_NA;
+ ++ctx->Map.pci[ 0 ]
) {
for (
- ctx->pcs[ 1 ] = RtemsIntrReqIsPending_Pre_Pending_Obj;
- ctx->pcs[ 1 ] < RtemsIntrReqIsPending_Pre_Pending_NA;
- ++ctx->pcs[ 1 ]
+ ctx->Map.pci[ 1 ] = RtemsIntrReqIsPending_Pre_Pending_Obj;
+ ctx->Map.pci[ 1 ] < RtemsIntrReqIsPending_Pre_Pending_NA;
+ ++ctx->Map.pci[ 1 ]
) {
for (
- ctx->pcs[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_Yes;
- ctx->pcs[ 2 ] < RtemsIntrReqIsPending_Pre_IsPending_NA;
- ++ctx->pcs[ 2 ]
+ ctx->Map.pci[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_Yes;
+ ctx->Map.pci[ 2 ] < RtemsIntrReqIsPending_Pre_IsPending_NA;
+ ++ctx->Map.pci[ 2 ]
) {
- RtemsIntrReqIsPending_Entry entry;
- size_t pcs[ 3 ];
-
- entry = RtemsIntrReqIsPending_GetEntry( index );
- ++index;
-
- memcpy( pcs, ctx->pcs, sizeof( pcs ) );
-
- if ( entry.Pre_IsPending_NA ) {
- ctx->pcs[ 2 ] = RtemsIntrReqIsPending_Pre_IsPending_NA;
- }
-
- RtemsIntrReqIsPending_Pre_Vector_Prepare( ctx, ctx->pcs[ 0 ] );
- RtemsIntrReqIsPending_Pre_Pending_Prepare( ctx, ctx->pcs[ 1 ] );
- RtemsIntrReqIsPending_Pre_IsPending_Prepare( ctx, ctx->pcs[ 2 ] );
- RtemsIntrReqIsPending_Action( ctx );
- RtemsIntrReqIsPending_Post_Status_Check( ctx, entry.Post_Status );
- RtemsIntrReqIsPending_Post_IsPending_Check(
- ctx,
- entry.Post_IsPending
- );
- memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+ ctx->Map.entry = RtemsIntrReqIsPending_PopEntry( ctx );
+ RtemsIntrReqIsPending_SetPreConditionStates( ctx );
+ RtemsIntrReqIsPending_TestVariant( ctx );
}
}
}