[PATCH 34/41] validation: Test rtems_interrupt_entry_install()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 12 12:49:56 UTC 2021


Update #3269.
---
 .../testsuites/validation/validation-0.yml    |    1 +
 testsuites/validation/tc-intr-entry-install.c | 1222 +++++++++++++++++
 2 files changed, 1223 insertions(+)
 create mode 100644 testsuites/validation/tc-intr-entry-install.c

diff --git a/spec/build/testsuites/validation/validation-0.yml b/spec/build/testsuites/validation/validation-0.yml
index 78633bebe5..c536779f2d 100644
--- a/spec/build/testsuites/validation/validation-0.yml
+++ b/spec/build/testsuites/validation/validation-0.yml
@@ -15,6 +15,7 @@ source:
 - testsuites/validation/tc-barrier-delete.c
 - testsuites/validation/tc-barrier-release.c
 - testsuites/validation/tc-barrier-wait.c
+- testsuites/validation/tc-intr-entry-install.c
 - testsuites/validation/tc-intr-get-attributes.c
 - testsuites/validation/tc-intr-vector-disable.c
 - testsuites/validation/tc-intr-vector-enable.c
diff --git a/testsuites/validation/tc-intr-entry-install.c b/testsuites/validation/tc-intr-entry-install.c
new file mode 100644
index 0000000000..3ba8452226
--- /dev/null
+++ b/testsuites/validation/tc-intr-entry-install.c
@@ -0,0 +1,1222 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsIntrReqEntryInstall
+ */
+
+/*
+ * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file is part of the RTEMS quality process and was automatically
+ * generated.  If you find something that needs to be fixed or
+ * worded better please post a report or patch to an RTEMS mailing list
+ * or raise a bug report:
+ *
+ * https://www.rtems.org/bugs.html
+ *
+ * For information on updating and regenerating please refer to the How-To
+ * section in the Software Requirements Engineering chapter of the
+ * RTEMS Software Engineering manual.  The manual is provided as a part of
+ * a release.  For development sources please refer to the online
+ * documentation at:
+ *
+ * https://docs.rtems.org
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <bsp/irq-generic.h>
+#include <rtems/irq-extension.h>
+
+#include "tx-support.h"
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsIntrReqEntryInstall \
+ *   spec:/rtems/intr/req/entry-install
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_Vector_Valid,
+  RtemsIntrReqEntryInstall_Pre_Vector_Invalid,
+  RtemsIntrReqEntryInstall_Pre_Vector_NA
+} RtemsIntrReqEntryInstall_Pre_Vector;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_Options_Unique,
+  RtemsIntrReqEntryInstall_Pre_Options_Shared,
+  RtemsIntrReqEntryInstall_Pre_Options_Replace,
+  RtemsIntrReqEntryInstall_Pre_Options_NA
+} RtemsIntrReqEntryInstall_Pre_Options;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_Entry_Obj,
+  RtemsIntrReqEntryInstall_Pre_Entry_Null,
+  RtemsIntrReqEntryInstall_Pre_Entry_NA
+} RtemsIntrReqEntryInstall_Pre_Entry;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_Routine_Valid,
+  RtemsIntrReqEntryInstall_Pre_Routine_Null,
+  RtemsIntrReqEntryInstall_Pre_Routine_NA
+} RtemsIntrReqEntryInstall_Pre_Routine;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_Init_Yes,
+  RtemsIntrReqEntryInstall_Pre_Init_No,
+  RtemsIntrReqEntryInstall_Pre_Init_NA
+} RtemsIntrReqEntryInstall_Pre_Init;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_ISR_Yes,
+  RtemsIntrReqEntryInstall_Pre_ISR_No,
+  RtemsIntrReqEntryInstall_Pre_ISR_NA
+} RtemsIntrReqEntryInstall_Pre_ISR;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Pre_Installed_None,
+  RtemsIntrReqEntryInstall_Pre_Installed_Unique,
+  RtemsIntrReqEntryInstall_Pre_Installed_Other,
+  RtemsIntrReqEntryInstall_Pre_Installed_EqRoutine,
+  RtemsIntrReqEntryInstall_Pre_Installed_EqArg,
+  RtemsIntrReqEntryInstall_Pre_Installed_Match,
+  RtemsIntrReqEntryInstall_Pre_Installed_NA
+} RtemsIntrReqEntryInstall_Pre_Installed;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Post_Status_Ok,
+  RtemsIntrReqEntryInstall_Post_Status_InvAddr,
+  RtemsIntrReqEntryInstall_Post_Status_IncStat,
+  RtemsIntrReqEntryInstall_Post_Status_InvId,
+  RtemsIntrReqEntryInstall_Post_Status_InvNum,
+  RtemsIntrReqEntryInstall_Post_Status_CalledFromISR,
+  RtemsIntrReqEntryInstall_Post_Status_InUse,
+  RtemsIntrReqEntryInstall_Post_Status_TooMany,
+  RtemsIntrReqEntryInstall_Post_Status_NA
+} RtemsIntrReqEntryInstall_Post_Status;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+  RtemsIntrReqEntryInstall_Post_IsEnabled_Yes,
+  RtemsIntrReqEntryInstall_Post_IsEnabled_NA
+} RtemsIntrReqEntryInstall_Post_IsEnabled;
+
+typedef enum {
+  RtemsIntrReqEntryInstall_Post_Installed_No,
+  RtemsIntrReqEntryInstall_Post_Installed_Last,
+  RtemsIntrReqEntryInstall_Post_Installed_NA
+} RtemsIntrReqEntryInstall_Post_Installed;
+
+/**
+ * @brief Test context for spec:/rtems/intr/req/entry-install test case.
+ */
+typedef struct {
+  /**
+   * @brief If this member is true, then the service was initialized during
+   *   setup.
+   */
+  bool initialized_during_setup;
+
+  /**
+   * @brief If this member is true, then an interrupt occurred.
+   */
+  bool interrupt_occurred;
+
+  /**
+   * @brief This member provides a valid interrupt vector number.
+   */
+  rtems_vector_number valid_vector;
+
+  /**
+   * @brief If this member is true, then the service shall be initialized.
+   */
+  bool initialized;
+
+  /**
+   * @brief If this member is true, then rtems_interrupt_entry_install() shall
+   *   be called from within interrupt context.
+   */
+  bool isr;
+
+  /**
+   * @brief This member contains the enabled status before the
+   *   rtems_interrupt_entry_install() call.
+   */
+  bool enabled_before;
+
+  /**
+   * @brief This member contains the enabled status after the
+   *   rtems_interrupt_entry_install() call.
+   */
+  bool enabled_after;
+
+  /**
+   * @brief This member provides the count of visited entries.
+   */
+  uint32_t visited_entries;
+
+  /**
+   * @brief This member provides another rtems_interrupt_entry object.
+   */
+  rtems_interrupt_entry other_entry;
+
+  /**
+   * @brief If this member is true, then another entry was installed.
+   */
+  bool other_installed;
+
+  /**
+   * @brief This member provides a third rtems_interrupt_entry object.
+   */
+  rtems_interrupt_entry third_entry;
+
+  /**
+   * @brief If this member is true, then the third entry was installed.
+   */
+  bool third_installed;
+
+  /**
+   * @brief This member provides the options used to install the other
+   *   rtems_interrupt_entry object.
+   */
+  rtems_option other_options;
+
+  /**
+   * @brief This member provides the rtems_interrupt_entry object.
+   */
+  rtems_interrupt_entry entry_obj;
+
+  /**
+   * @brief This member specifies if the ``vector`` parameter value.
+   */
+  rtems_vector_number vector;
+
+  /**
+   * @brief This member specifies if the ``options`` parameter value.
+   */
+  rtems_option options;
+
+  /**
+   * @brief This member specifies if the ``entry`` parameter value.
+   */
+  rtems_interrupt_entry *entry;;
+
+  /**
+   * @brief This member contains the return value of the
+   *   rtems_interrupt_entry_install() call.
+   */
+  rtems_status_code status;
+
+  /**
+   * @brief This member defines the pre-condition states for the next action.
+   */
+  size_t pcs[ 7 ];
+
+  /**
+   * @brief This member indicates if the test action loop is currently
+   *   executed.
+   */
+  bool in_action_loop;
+} RtemsIntrReqEntryInstall_Context;
+
+static RtemsIntrReqEntryInstall_Context
+  RtemsIntrReqEntryInstall_Instance;
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_Vector[] = {
+  "Valid",
+  "Invalid",
+  "NA"
+};
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_Options[] = {
+  "Unique",
+  "Shared",
+  "Replace",
+  "NA"
+};
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_Entry[] = {
+  "Obj",
+  "Null",
+  "NA"
+};
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_Routine[] = {
+  "Valid",
+  "Null",
+  "NA"
+};
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_Init[] = {
+  "Yes",
+  "No",
+  "NA"
+};
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_ISR[] = {
+  "Yes",
+  "No",
+  "NA"
+};
+
+static const char * const RtemsIntrReqEntryInstall_PreDesc_Installed[] = {
+  "None",
+  "Unique",
+  "Other",
+  "EqRoutine",
+  "EqArg",
+  "Match",
+  "NA"
+};
+
+static const char * const * const RtemsIntrReqEntryInstall_PreDesc[] = {
+  RtemsIntrReqEntryInstall_PreDesc_Vector,
+  RtemsIntrReqEntryInstall_PreDesc_Options,
+  RtemsIntrReqEntryInstall_PreDesc_Entry,
+  RtemsIntrReqEntryInstall_PreDesc_Routine,
+  RtemsIntrReqEntryInstall_PreDesc_Init,
+  RtemsIntrReqEntryInstall_PreDesc_ISR,
+  RtemsIntrReqEntryInstall_PreDesc_Installed,
+  NULL
+};
+
+typedef RtemsIntrReqEntryInstall_Context Context;
+
+static char entry_arg;
+
+static char other_arg;
+
+static char third_arg;
+
+static const char entry_info[] = "Entry";
+
+static const char other_info[] = "Other";
+
+static const char third_info[] = "Third";
+
+static void Install(
+  Context                *ctx,
+  rtems_option            options,
+  rtems_interrupt_handler routine,
+  void                   *arg
+)
+{
+  rtems_status_code sc;
+
+  ctx->other_options = options;
+  rtems_interrupt_entry_initialize(
+    &ctx->other_entry,
+    routine,
+    arg,
+    other_info
+  );
+
+  sc = rtems_interrupt_entry_install(
+    ctx->valid_vector,
+    options,
+    &ctx->other_entry
+  );
+  T_rsc_success( sc );
+
+  ctx->other_installed = true;
+}
+
+static void OtherRoutine( void *arg )
+{
+  Context          *ctx;
+  rtems_status_code sc;
+
+  (void) arg;
+  ctx = T_fixture_context();
+  sc = rtems_interrupt_vector_disable( ctx->valid_vector );
+  T_rsc_success( sc );
+
+  ctx->interrupt_occurred = true;
+}
+
+static void EntryRoutine( void *arg )
+{
+  T_eq_ptr( arg, &entry_arg );
+  OtherRoutine( NULL );
+}
+
+static void ThirdRoutine( void *arg )
+{
+  T_eq_ptr( arg, &third_arg );
+  OtherRoutine( NULL );
+}
+
+static void InstallThird( Context *ctx )
+{
+  rtems_status_code sc;
+
+  rtems_interrupt_entry_initialize(
+    &ctx->third_entry,
+    ThirdRoutine,
+    &third_arg,
+    third_info
+  );
+
+  sc = rtems_interrupt_entry_install(
+    ctx->valid_vector,
+    RTEMS_INTERRUPT_SHARED,
+    &ctx->third_entry
+  );
+  T_rsc_success( sc );
+
+  ctx->third_installed = true;
+}
+
+static void Action( void *arg )
+{
+  Context          *ctx;
+  rtems_status_code sc;
+
+  ctx = arg;
+
+  sc = rtems_interrupt_vector_is_enabled(
+    ctx->valid_vector,
+    &ctx->enabled_before
+  );
+  T_rsc_success( sc );
+
+  bsp_interrupt_set_handler_unique(
+    BSP_INTERRUPT_HANDLER_TABLE_SIZE,
+    ctx->initialized
+  );
+
+  ctx->status = rtems_interrupt_entry_install(
+    ctx->vector,
+    ctx->options,
+    ctx->entry
+  );
+
+  bsp_interrupt_set_handler_unique(
+    BSP_INTERRUPT_HANDLER_TABLE_SIZE,
+    ctx->initialized_during_setup
+  );
+
+  sc = rtems_interrupt_vector_is_enabled(
+    ctx->valid_vector,
+    &ctx->enabled_after
+  );
+  T_rsc_success( sc );
+}
+
+static void VisitInstalled(
+  void                   *arg,
+  const char             *info,
+  rtems_option            options,
+  rtems_interrupt_handler handler_routine,
+  void                   *handler_arg
+)
+{
+  Context *ctx;
+  uint32_t visited_entries;
+
+  ctx = arg;
+  visited_entries = ctx->visited_entries;
+
+  if ( visited_entries == 0 && ctx->other_installed ) {
+    T_eq_ptr( info, other_info );
+    T_eq_u32( options, ctx->other_options );
+    T_eq_ptr( handler_routine, ctx->other_entry.handler );
+    T_eq_ptr( handler_arg, ctx->other_entry.arg );
+  } else if ( visited_entries == 1 && ctx->third_installed ) {
+    T_eq_ptr( info, third_info );
+    T_eq_u32( options, RTEMS_INTERRUPT_SHARED );
+    T_eq_ptr( handler_routine, ThirdRoutine );
+    T_eq_ptr( handler_arg, &third_arg );
+  } else {
+    T_eq_ptr( info, entry_info );
+    T_eq_u32( options, ctx->options );
+    T_eq_ptr( handler_routine, ctx->entry_obj.handler );
+    T_eq_ptr( handler_arg, ctx->entry_obj.arg );
+  }
+
+  ctx->visited_entries = visited_entries + 1;
+}
+
+static void RtemsIntrReqEntryInstall_Pre_Vector_Prepare(
+  RtemsIntrReqEntryInstall_Context   *ctx,
+  RtemsIntrReqEntryInstall_Pre_Vector state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_Vector_Valid: {
+      /*
+       * While the ``vector`` parameter is associated with an interrupt vector.
+       */
+      ctx->vector = ctx->valid_vector;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Vector_Invalid: {
+      /*
+       * While the ``vector`` parameter is not associated with an interrupt
+       * vector.
+       */
+      ctx->vector = BSP_INTERRUPT_VECTOR_COUNT;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Vector_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Pre_Options_Prepare(
+  RtemsIntrReqEntryInstall_Context    *ctx,
+  RtemsIntrReqEntryInstall_Pre_Options state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_Options_Unique: {
+      /*
+       * While the ``options`` indicates that an unique entry shall be
+       * installed.
+       */
+      ctx->options = RTEMS_INTERRUPT_UNIQUE;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Options_Shared: {
+      /*
+       * While the ``options`` indicates that a shared entry shall be
+       * installed.
+       */
+      ctx->options = RTEMS_INTERRUPT_SHARED;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Options_Replace: {
+      /*
+       * While the ``options`` indicates that the entry handler routine shall
+       * be replaced.
+       */
+      ctx->options = RTEMS_INTERRUPT_REPLACE;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Options_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Pre_Entry_Prepare(
+  RtemsIntrReqEntryInstall_Context  *ctx,
+  RtemsIntrReqEntryInstall_Pre_Entry state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_Entry_Obj: {
+      /*
+       * While the ``entry`` parameter references an object of type
+       * rtems_interrupt_entry.
+       */
+      ctx->entry = &ctx->entry_obj;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Entry_Null: {
+      /*
+       * While the ``entry`` parameter is equal to NULL.
+       */
+      ctx->entry = NULL;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Entry_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Pre_Routine_Prepare(
+  RtemsIntrReqEntryInstall_Context    *ctx,
+  RtemsIntrReqEntryInstall_Pre_Routine state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_Routine_Valid: {
+      /*
+       * While the handler routine of the object referenced by the ``entry``
+       * parameter is valid.
+       */
+      rtems_interrupt_entry_initialize(
+        &ctx->entry_obj,
+        EntryRoutine,
+        &entry_arg,
+        entry_info
+      );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Routine_Null: {
+      /*
+       * While the handler routine of the object referenced by the ``entry``
+       * parameter is equal to NULL.
+       */
+      rtems_interrupt_entry_initialize(
+        &ctx->entry_obj,
+        NULL,
+        &entry_arg,
+        entry_info
+      );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Routine_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Pre_Init_Prepare(
+  RtemsIntrReqEntryInstall_Context *ctx,
+  RtemsIntrReqEntryInstall_Pre_Init state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_Init_Yes: {
+      /*
+       * While the service is initialized.
+       */
+      ctx->initialized = true;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Init_No: {
+      /*
+       * While the service is not initialized.
+       */
+      ctx->initialized = false;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Init_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Pre_ISR_Prepare(
+  RtemsIntrReqEntryInstall_Context *ctx,
+  RtemsIntrReqEntryInstall_Pre_ISR  state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_ISR_Yes: {
+      /*
+       * While rtems_interrupt_entry_install() is called from within interrupt
+       * context.
+       */
+      ctx->isr = true;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_ISR_No: {
+      /*
+       * While rtems_interrupt_entry_install() is not called from within
+       * interrupt context.
+       */
+      ctx->isr = false;
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_ISR_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Pre_Installed_Prepare(
+  RtemsIntrReqEntryInstall_Context      *ctx,
+  RtemsIntrReqEntryInstall_Pre_Installed state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Pre_Installed_None: {
+      /*
+       * While the no entry is installed at the interrupt vector specified by
+       * the ``vector`` parameter.
+       */
+      /* Nothing to do */
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Installed_Unique: {
+      /*
+       * While a unique entry is installed at the interrupt vector specified by
+       * the ``vector`` parameter.
+       */
+      Install( ctx, RTEMS_INTERRUPT_UNIQUE, EntryRoutine, &entry_arg );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Installed_Other: {
+      /*
+       * While at least one non-unique entry is installed at the interrupt
+       * vector specified by the ``vector`` parameter, while all entries
+       * installed at the interrupt vector specified by the ``vector``
+       * parameter have a handler routine which is not equal to the handler
+       * routine of the object referenced by the ``entry`` parameter, while all
+       * entries installed at the interrupt vector specified by the ``vector``
+       * parameter have a handler argument which is not equal to the handler
+       * argument of the object referenced by the ``entry`` parameter.
+       */
+      Install( ctx, RTEMS_INTERRUPT_SHARED, OtherRoutine, &other_arg );
+      InstallThird( ctx );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Installed_EqRoutine: {
+      /*
+       * While at least one non-unique entry is installed at the interrupt
+       * vector specified by the ``vector`` parameter, while at least one entry
+       * installed at the interrupt vector specified by the ``vector``
+       * parameter has a handler routine which is equal to the handler routine
+       * of the object referenced by the ``entry`` parameter, while all entries
+       * installed at the interrupt vector specified by the ``vector``
+       * parameter have a handler argument which is not equal to the handler
+       * argument of the object referenced by the ``entry`` parameter.
+       */
+      Install( ctx, RTEMS_INTERRUPT_SHARED, EntryRoutine, &other_arg );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Installed_EqArg: {
+      /*
+       * While at least one non-unique entry is installed at the interrupt
+       * vector specified by the ``vector`` parameter, while all entries
+       * installed at the interrupt vector specified by the ``vector``
+       * parameter have a handler routine which is not equal to the handler
+       * routine of the object referenced by the ``entry`` parameter, while at
+       * least one entry installed at the interrupt vector specified by the
+       * ``vector`` parameter has a handler argument which is equal to the
+       * handler argument of the object referenced by the ``entry`` parameter.
+       */
+      Install( ctx, RTEMS_INTERRUPT_SHARED, OtherRoutine, &other_arg );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Installed_Match: {
+      /*
+       * While at least one non-unique entry with a handler routine which is
+       * equal to the handler routine of the object referenced by the ``entry``
+       * parameter and with a handler argument which is equal to the handler
+       * argument of the object referenced by the ``entry`` parameter is
+       * installed at the interrupt vector specified by the ``vector``
+       * parameter.
+       */
+      Install( ctx, RTEMS_INTERRUPT_SHARED, EntryRoutine, &entry_arg );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Pre_Installed_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Post_Status_Check(
+  RtemsIntrReqEntryInstall_Context    *ctx,
+  RtemsIntrReqEntryInstall_Post_Status state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Post_Status_Ok: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_SUCCESSFUL.
+       */
+      T_rsc_success( ctx->status );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_InvAddr: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_INVALID_ADDRESS.
+       */
+      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_IncStat: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_INCORRECT_STATE.
+       */
+      T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_InvId: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_INVALID_ID.
+       */
+      T_rsc( ctx->status, RTEMS_INVALID_ID );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_InvNum: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_INVALID_NUMBER.
+       */
+      T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_CalledFromISR: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_CALLED_FROM_ISR.
+       */
+      T_rsc( ctx->status, RTEMS_CALLED_FROM_ISR );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_InUse: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_RESOURCE_IN_USE.
+       */
+      T_rsc( ctx->status, RTEMS_RESOURCE_IN_USE  );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_TooMany: {
+      /*
+       * The return status of rtems_interrupt_entry_install() shall be
+       * RTEMS_TOO_MANY.
+       */
+      T_rsc( ctx->status, RTEMS_TOO_MANY );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Status_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Post_IsEnabled_Check(
+  RtemsIntrReqEntryInstall_Context       *ctx,
+  RtemsIntrReqEntryInstall_Post_IsEnabled state
+)
+{
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Post_IsEnabled_Nop: {
+      /*
+       * The enabled status of the interrupt vector specified by ``vector``
+       * shall not be modified by the rtems_interrupt_entry_install() call.
+       */
+      if ( !ctx->interrupt_occurred ) {
+        T_eq( ctx->enabled_before, ctx->enabled_after );
+      }
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_IsEnabled_Yes: {
+      /*
+       * The interrupt vector specified by ``vector`` shall be enabled.
+       */
+      T_false( ctx->enabled_before );
+      T_true( ctx->enabled_after || ctx->interrupt_occurred );
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_IsEnabled_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Post_Installed_Check(
+  RtemsIntrReqEntryInstall_Context       *ctx,
+  RtemsIntrReqEntryInstall_Post_Installed state
+)
+{
+  rtems_status_code sc;
+
+  ctx->visited_entries = 0;
+  sc = rtems_interrupt_handler_iterate(
+    ctx->valid_vector,
+    VisitInstalled,
+    ctx
+  );
+  T_rsc_success( sc );
+
+  switch ( state ) {
+    case RtemsIntrReqEntryInstall_Post_Installed_No: {
+      /*
+       * The entry referenced by ``entry`` shall not be installed at the
+       * interrupt vector specified by ``vector``.
+       */
+      if ( ctx->other_installed && ctx->third_installed ) {
+        T_eq_u32( ctx->visited_entries, 2 );
+      } else if ( ctx->other_installed ) {
+        T_eq_u32( ctx->visited_entries, 1 );
+      } else {
+        T_eq_u32( ctx->visited_entries, 0 );
+      }
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Installed_Last: {
+      /*
+       * The entry referenced by ``entry`` shall be installed as the last entry
+       * at the interrupt vector specified by ``vector``.
+       */
+      if ( ctx->other_installed && ctx->third_installed ) {
+        T_eq_u32( ctx->visited_entries, 3 );
+      } else if ( ctx->other_installed ) {
+        T_eq_u32( ctx->visited_entries, 2 );
+      } else {
+        T_eq_u32( ctx->visited_entries, 1 );
+      }
+      break;
+    }
+
+    case RtemsIntrReqEntryInstall_Post_Installed_NA:
+      break;
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Setup(
+  RtemsIntrReqEntryInstall_Context *ctx
+)
+{
+  ctx->initialized_during_setup = bsp_interrupt_is_initialized();
+
+  /* Find a valid interrupt vector for this test */
+  for (
+    ctx->valid_vector = 0;
+    ctx->valid_vector < BSP_INTERRUPT_VECTOR_COUNT;
+    ++ctx->valid_vector
+  ) {
+    rtems_status_code          sc;
+    rtems_interrupt_attributes attr;
+
+    sc = rtems_interrupt_get_attributes( ctx->valid_vector, &attr );
+
+    if (
+      sc == RTEMS_SUCCESSFUL && attr.can_enable && attr.can_disable &&
+      attr.is_maskable &&
+      !HasInterruptVectorEntriesInstalled( ctx->valid_vector )
+    ) {
+      break;
+    }
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Setup_Wrap( void *arg )
+{
+  RtemsIntrReqEntryInstall_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsIntrReqEntryInstall_Setup( ctx );
+}
+
+static void RtemsIntrReqEntryInstall_Prepare(
+  RtemsIntrReqEntryInstall_Context *ctx
+)
+{
+  ctx->interrupt_occurred = false;
+  ctx->other_installed = false;
+  ctx->third_installed = false;
+}
+
+static void RtemsIntrReqEntryInstall_Action(
+  RtemsIntrReqEntryInstall_Context *ctx
+)
+{
+  if ( ctx->isr ) {
+    CallWithinISR( Action, ctx );
+  } else {
+    Action( ctx );
+  }
+}
+
+static void RtemsIntrReqEntryInstall_Cleanup(
+  RtemsIntrReqEntryInstall_Context *ctx
+)
+{
+  rtems_status_code sc;
+
+  if ( ctx->third_installed ) {
+    sc = rtems_interrupt_entry_remove( ctx->valid_vector, &ctx->third_entry );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->other_installed ) {
+    sc = rtems_interrupt_entry_remove( ctx->valid_vector, &ctx->other_entry );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->status == RTEMS_SUCCESSFUL ) {
+    sc = rtems_interrupt_entry_remove( ctx->valid_vector, ctx->entry );
+    T_rsc_success( sc );
+  }
+}
+
+typedef struct {
+  uint16_t Skip : 1;
+  uint16_t Pre_Vector_NA : 1;
+  uint16_t Pre_Options_NA : 1;
+  uint16_t Pre_Entry_NA : 1;
+  uint16_t Pre_Routine_NA : 1;
+  uint16_t Pre_Init_NA : 1;
+  uint16_t Pre_ISR_NA : 1;
+  uint16_t Pre_Installed_NA : 1;
+  uint16_t Post_Status : 4;
+  uint16_t Post_IsEnabled : 2;
+  uint16_t Post_Installed : 2;
+} RtemsIntrReqEntryInstall_Entry;
+
+static const RtemsIntrReqEntryInstall_Entry
+RtemsIntrReqEntryInstall_Entries[] = {
+  { 0, 0, 0, 0, 1, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_InvAddr,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_NA },
+  { 0, 0, 0, 0, 1, 0, 0, 1, RtemsIntrReqEntryInstall_Post_Status_InvAddr,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_NA,
+    RtemsIntrReqEntryInstall_Post_Installed_NA },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_IncStat,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_No },
+  { 0, 0, 0, 0, 0, 0, 0, 1, RtemsIntrReqEntryInstall_Post_Status_IncStat,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_NA,
+    RtemsIntrReqEntryInstall_Post_Installed_NA },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_InvAddr,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_No },
+  { 0, 0, 0, 0, 0, 0, 0, 1, RtemsIntrReqEntryInstall_Post_Status_InvId,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_NA,
+    RtemsIntrReqEntryInstall_Post_Installed_NA },
+  { 0, 0, 0, 0, 0, 0, 0, 1, RtemsIntrReqEntryInstall_Post_Status_InvAddr,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_NA,
+    RtemsIntrReqEntryInstall_Post_Installed_NA },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_CalledFromISR,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_No },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_InUse,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_No },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_InvNum,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_No },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_Ok,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_Last },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_Ok,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Yes,
+    RtemsIntrReqEntryInstall_Post_Installed_Last },
+  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsIntrReqEntryInstall_Post_Status_TooMany,
+    RtemsIntrReqEntryInstall_Post_IsEnabled_Nop,
+    RtemsIntrReqEntryInstall_Post_Installed_No }
+};
+
+static const uint8_t
+RtemsIntrReqEntryInstall_Map[] = {
+  7, 7, 7, 7, 7, 7, 11, 8, 8, 8, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4,
+  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7,
+  11, 8, 10, 10, 10, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4,
+  4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9,
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2,
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3,
+  3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+  3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+  5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1
+};
+
+static size_t RtemsIntrReqEntryInstall_Scope( void *arg, char *buf, size_t n )
+{
+  RtemsIntrReqEntryInstall_Context *ctx;
+
+  ctx = arg;
+
+  if ( ctx->in_action_loop ) {
+    return T_get_scope( RtemsIntrReqEntryInstall_PreDesc, buf, n, ctx->pcs );
+  }
+
+  return 0;
+}
+
+static T_fixture RtemsIntrReqEntryInstall_Fixture = {
+  .setup = RtemsIntrReqEntryInstall_Setup_Wrap,
+  .stop = NULL,
+  .teardown = NULL,
+  .scope = RtemsIntrReqEntryInstall_Scope,
+  .initial_context = &RtemsIntrReqEntryInstall_Instance
+};
+
+static inline RtemsIntrReqEntryInstall_Entry RtemsIntrReqEntryInstall_GetEntry(
+  size_t index
+)
+{
+  return RtemsIntrReqEntryInstall_Entries[
+    RtemsIntrReqEntryInstall_Map[ index ]
+  ];
+}
+
+/**
+ * @fn void T_case_body_RtemsIntrReqEntryInstall( void )
+ */
+T_TEST_CASE_FIXTURE(
+  RtemsIntrReqEntryInstall,
+  &RtemsIntrReqEntryInstall_Fixture
+)
+{
+  RtemsIntrReqEntryInstall_Context *ctx;
+  size_t index;
+
+  ctx = T_fixture_context();
+  ctx->in_action_loop = true;
+  index = 0;
+
+  for (
+    ctx->pcs[ 0 ] = RtemsIntrReqEntryInstall_Pre_Vector_Valid;
+    ctx->pcs[ 0 ] < RtemsIntrReqEntryInstall_Pre_Vector_NA;
+    ++ctx->pcs[ 0 ]
+  ) {
+    for (
+      ctx->pcs[ 1 ] = RtemsIntrReqEntryInstall_Pre_Options_Unique;
+      ctx->pcs[ 1 ] < RtemsIntrReqEntryInstall_Pre_Options_NA;
+      ++ctx->pcs[ 1 ]
+    ) {
+      for (
+        ctx->pcs[ 2 ] = RtemsIntrReqEntryInstall_Pre_Entry_Obj;
+        ctx->pcs[ 2 ] < RtemsIntrReqEntryInstall_Pre_Entry_NA;
+        ++ctx->pcs[ 2 ]
+      ) {
+        for (
+          ctx->pcs[ 3 ] = RtemsIntrReqEntryInstall_Pre_Routine_Valid;
+          ctx->pcs[ 3 ] < RtemsIntrReqEntryInstall_Pre_Routine_NA;
+          ++ctx->pcs[ 3 ]
+        ) {
+          for (
+            ctx->pcs[ 4 ] = RtemsIntrReqEntryInstall_Pre_Init_Yes;
+            ctx->pcs[ 4 ] < RtemsIntrReqEntryInstall_Pre_Init_NA;
+            ++ctx->pcs[ 4 ]
+          ) {
+            for (
+              ctx->pcs[ 5 ] = RtemsIntrReqEntryInstall_Pre_ISR_Yes;
+              ctx->pcs[ 5 ] < RtemsIntrReqEntryInstall_Pre_ISR_NA;
+              ++ctx->pcs[ 5 ]
+            ) {
+              for (
+                ctx->pcs[ 6 ] = RtemsIntrReqEntryInstall_Pre_Installed_None;
+                ctx->pcs[ 6 ] < RtemsIntrReqEntryInstall_Pre_Installed_NA;
+                ++ctx->pcs[ 6 ]
+              ) {
+                RtemsIntrReqEntryInstall_Entry entry;
+                size_t pcs[ 7 ];
+
+                entry = RtemsIntrReqEntryInstall_GetEntry( index );
+                ++index;
+
+                memcpy( pcs, ctx->pcs, sizeof( pcs ) );
+
+                if ( entry.Pre_Routine_NA ) {
+                  ctx->pcs[ 3 ] = RtemsIntrReqEntryInstall_Pre_Routine_NA;
+                }
+
+                if ( entry.Pre_Installed_NA ) {
+                  ctx->pcs[ 6 ] = RtemsIntrReqEntryInstall_Pre_Installed_NA;
+                }
+
+                RtemsIntrReqEntryInstall_Prepare( ctx );
+                RtemsIntrReqEntryInstall_Pre_Vector_Prepare(
+                  ctx,
+                  ctx->pcs[ 0 ]
+                );
+                RtemsIntrReqEntryInstall_Pre_Options_Prepare(
+                  ctx,
+                  ctx->pcs[ 1 ]
+                );
+                RtemsIntrReqEntryInstall_Pre_Entry_Prepare(
+                  ctx,
+                  ctx->pcs[ 2 ]
+                );
+                RtemsIntrReqEntryInstall_Pre_Routine_Prepare(
+                  ctx,
+                  ctx->pcs[ 3 ]
+                );
+                RtemsIntrReqEntryInstall_Pre_Init_Prepare(
+                  ctx,
+                  ctx->pcs[ 4 ]
+                );
+                RtemsIntrReqEntryInstall_Pre_ISR_Prepare( ctx, ctx->pcs[ 5 ] );
+                RtemsIntrReqEntryInstall_Pre_Installed_Prepare(
+                  ctx,
+                  ctx->pcs[ 6 ]
+                );
+                RtemsIntrReqEntryInstall_Action( ctx );
+                RtemsIntrReqEntryInstall_Post_Status_Check(
+                  ctx,
+                  entry.Post_Status
+                );
+                RtemsIntrReqEntryInstall_Post_IsEnabled_Check(
+                  ctx,
+                  entry.Post_IsEnabled
+                );
+                RtemsIntrReqEntryInstall_Post_Installed_Check(
+                  ctx,
+                  entry.Post_Installed
+                );
+                RtemsIntrReqEntryInstall_Cleanup( ctx );
+                memcpy( ctx->pcs, pcs, sizeof( ctx->pcs ) );
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}
+
+/** @} */
-- 
2.26.2





More information about the devel mailing list