[PATCH 2/2] validation: Tests for barrier manager

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Feb 5 15:13:03 UTC 2021


---
 .../testsuites/validation/validation-0.yml    |   4 +
 testsuites/validation/tc-barrier-create.c     | 745 ++++++++++++++++++
 testsuites/validation/tc-barrier-delete.c     | 451 +++++++++++
 testsuites/validation/tc-barrier-release.c    | 588 ++++++++++++++
 testsuites/validation/tc-barrier-wait.c       | 687 ++++++++++++++++
 5 files changed, 2475 insertions(+)
 create mode 100644 testsuites/validation/tc-barrier-create.c
 create mode 100644 testsuites/validation/tc-barrier-delete.c
 create mode 100644 testsuites/validation/tc-barrier-release.c
 create mode 100644 testsuites/validation/tc-barrier-wait.c

diff --git a/spec/build/testsuites/validation/validation-0.yml b/spec/build/testsuites/validation/validation-0.yml
index 7fc9519cd4..8d7bf8d533 100644
--- a/spec/build/testsuites/validation/validation-0.yml
+++ b/spec/build/testsuites/validation/validation-0.yml
@@ -12,7 +12,11 @@ ldflags: []
 links: []
 source:
 - testsuites/validation/tc-attr.c
+- testsuites/validation/tc-barrier-create.c
+- testsuites/validation/tc-barrier-delete.c
 - testsuites/validation/tc-barrier-ident.c
+- testsuites/validation/tc-barrier-release.c
+- testsuites/validation/tc-barrier-wait.c
 - testsuites/validation/tc-basedefs-pendant.c
 - testsuites/validation/tc-basedefs.c
 - testsuites/validation/tc-events.c
diff --git a/testsuites/validation/tc-barrier-create.c b/testsuites/validation/tc-barrier-create.c
new file mode 100644
index 0000000000..7f84b1d05b
--- /dev/null
+++ b/testsuites/validation/tc-barrier-create.c
@@ -0,0 +1,745 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsBarrierReqCreate
+ */
+
+/*
+ * 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 <rtems.h>
+#include <string.h>
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsBarrierReqCreate spec:/rtems/barrier/req/create
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+  RtemsBarrierReqCreate_Pre_Name_Valid,
+  RtemsBarrierReqCreate_Pre_Name_Invalid,
+  RtemsBarrierReqCreate_Pre_Name_NA
+} RtemsBarrierReqCreate_Pre_Name;
+
+typedef enum {
+  RtemsBarrierReqCreate_Pre_Class_Default,
+  RtemsBarrierReqCreate_Pre_Class_Manual,
+  RtemsBarrierReqCreate_Pre_Class_Auto,
+  RtemsBarrierReqCreate_Pre_Class_NA
+} RtemsBarrierReqCreate_Pre_Class;
+
+typedef enum {
+  RtemsBarrierReqCreate_Pre_MaxWait_Zero,
+  RtemsBarrierReqCreate_Pre_MaxWait_Positive,
+  RtemsBarrierReqCreate_Pre_MaxWait_NA
+} RtemsBarrierReqCreate_Pre_MaxWait;
+
+typedef enum {
+  RtemsBarrierReqCreate_Pre_Id_Valid,
+  RtemsBarrierReqCreate_Pre_Id_Null,
+  RtemsBarrierReqCreate_Pre_Id_NA
+} RtemsBarrierReqCreate_Pre_Id;
+
+typedef enum {
+  RtemsBarrierReqCreate_Post_Status_Ok,
+  RtemsBarrierReqCreate_Post_Status_InvName,
+  RtemsBarrierReqCreate_Post_Status_InvAddr,
+  RtemsBarrierReqCreate_Post_Status_InvNum,
+  RtemsBarrierReqCreate_Post_Status_TooMany,
+  RtemsBarrierReqCreate_Post_Status_NA
+} RtemsBarrierReqCreate_Post_Status;
+
+typedef enum {
+  RtemsBarrierReqCreate_Post_Id_Valid,
+  RtemsBarrierReqCreate_Post_Id_Invalid,
+  RtemsBarrierReqCreate_Post_Id_NA
+} RtemsBarrierReqCreate_Post_Id;
+
+typedef enum {
+  RtemsBarrierReqCreate_Post_Class_NoObj,
+  RtemsBarrierReqCreate_Post_Class_Manual,
+  RtemsBarrierReqCreate_Post_Class_Auto,
+  RtemsBarrierReqCreate_Post_Class_NA
+} RtemsBarrierReqCreate_Post_Class;
+
+/**
+ * @brief Test context for spec:/rtems/barrier/req/create test case.
+ */
+typedef struct {
+  rtems_id worker_id;
+
+  rtems_id id_value;
+
+  uint32_t release_done;
+
+  uint32_t release_expected;
+
+  rtems_name name;
+
+  rtems_attribute attribute_set;
+
+  uint32_t maximum_waiters;
+
+  rtems_id *id;
+
+  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;
+} RtemsBarrierReqCreate_Context;
+
+static RtemsBarrierReqCreate_Context
+  RtemsBarrierReqCreate_Instance;
+
+static const char * const RtemsBarrierReqCreate_PreDesc_Name[] = {
+  "Valid",
+  "Invalid",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqCreate_PreDesc_Class[] = {
+  "Default",
+  "Manual",
+  "Auto",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqCreate_PreDesc_MaxWait[] = {
+  "Zero",
+  "Positive",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqCreate_PreDesc_Id[] = {
+  "Valid",
+  "Null",
+  "NA"
+};
+
+static const char * const * const RtemsBarrierReqCreate_PreDesc[] = {
+  RtemsBarrierReqCreate_PreDesc_Name,
+  RtemsBarrierReqCreate_PreDesc_Class,
+  RtemsBarrierReqCreate_PreDesc_MaxWait,
+  RtemsBarrierReqCreate_PreDesc_Id,
+  NULL
+};
+
+#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
+
+#define INVALID_ID 0xffffffff
+
+typedef RtemsBarrierReqCreate_Context Context;
+
+typedef enum {
+  PRIO_NORMAL = 1,
+  PRIO_LOW
+} Priorities;
+
+static void Worker( rtems_task_argument arg )
+{
+  Context *ctx;
+
+  ctx = (Context *) arg;
+
+  while ( true ) {
+    rtems_status_code sc;
+    uint32_t          released;
+
+    ++ctx->release_done;
+
+    released = 0;
+    sc = rtems_barrier_release( ctx->id_value, &released );
+    T_rsc_success( sc );
+    T_eq_u32( released, 1 );
+  }
+}
+
+static void RtemsBarrierReqCreate_Pre_Name_Prepare(
+  RtemsBarrierReqCreate_Context *ctx,
+  RtemsBarrierReqCreate_Pre_Name state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Pre_Name_Valid: {
+      ctx->name = NAME;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Name_Invalid: {
+      ctx->name = 0;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Name_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Pre_Class_Prepare(
+  RtemsBarrierReqCreate_Context  *ctx,
+  RtemsBarrierReqCreate_Pre_Class state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Pre_Class_Default: {
+      /* Nothing to do */
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Class_Manual: {
+      ctx->attribute_set |= RTEMS_BARRIER_MANUAL_RELEASE;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Class_Auto: {
+      ctx->attribute_set |= RTEMS_BARRIER_AUTOMATIC_RELEASE;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Class_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Pre_MaxWait_Prepare(
+  RtemsBarrierReqCreate_Context    *ctx,
+  RtemsBarrierReqCreate_Pre_MaxWait state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Pre_MaxWait_Zero: {
+      ctx->maximum_waiters = 0;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_MaxWait_Positive: {
+      ctx->maximum_waiters = 1;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_MaxWait_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Pre_Id_Prepare(
+  RtemsBarrierReqCreate_Context *ctx,
+  RtemsBarrierReqCreate_Pre_Id   state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Pre_Id_Valid: {
+      ctx->id = &ctx->id_value;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Id_Null: {
+      ctx->id = NULL;
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Pre_Id_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Post_Status_Check(
+  RtemsBarrierReqCreate_Context    *ctx,
+  RtemsBarrierReqCreate_Post_Status state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Post_Status_Ok: {
+      T_rsc_success( ctx->status );
+      T_eq_ptr( ctx->id, &ctx->id_value );
+      T_ne_u32( ctx->id_value, INVALID_ID );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Status_InvName: {
+      T_rsc( ctx->status, RTEMS_INVALID_NAME );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Status_InvAddr: {
+      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Status_InvNum: {
+      T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Status_TooMany: {
+      T_rsc( ctx->status, RTEMS_TOO_MANY );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Status_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Post_Id_Check(
+  RtemsBarrierReqCreate_Context *ctx,
+  RtemsBarrierReqCreate_Post_Id  state
+)
+{
+  rtems_status_code sc;
+  rtems_id          id;
+
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Post_Id_Valid: {
+      id = 0;
+      sc = rtems_barrier_ident( NAME, &id );
+      T_rsc_success( sc );
+      T_eq_u32( id, ctx->id_value );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Id_Invalid: {
+      sc = rtems_barrier_ident( NAME, &id );
+      T_rsc( sc, RTEMS_INVALID_NAME );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Id_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Post_Class_Check(
+  RtemsBarrierReqCreate_Context   *ctx,
+  RtemsBarrierReqCreate_Post_Class state
+)
+{
+  rtems_status_code sc;
+
+  switch ( state ) {
+    case RtemsBarrierReqCreate_Post_Class_NoObj: {
+      /* Not applicable */
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Class_Manual: {
+      sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
+      T_rsc_success( sc );
+
+      ++ctx->release_expected;
+      T_eq_u32( ctx->release_done, ctx->release_expected );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Class_Auto: {
+      sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
+      T_rsc_success( sc );
+
+      T_eq_u32( ctx->release_done, ctx->release_expected );
+      break;
+    }
+
+    case RtemsBarrierReqCreate_Post_Class_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqCreate_Setup( RtemsBarrierReqCreate_Context *ctx )
+{
+  rtems_status_code sc;
+
+  memset( ctx, 0, sizeof( *ctx ) );
+  ctx->id_value = INVALID_ID;
+
+  sc = rtems_task_create(
+    rtems_build_name( 'W', 'O', 'R', 'K' ),
+    PRIO_LOW,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->worker_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
+  T_assert_rsc_success( sc );
+}
+
+static void RtemsBarrierReqCreate_Setup_Wrap( void *arg )
+{
+  RtemsBarrierReqCreate_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqCreate_Setup( ctx );
+}
+
+static void RtemsBarrierReqCreate_Teardown(
+  RtemsBarrierReqCreate_Context *ctx
+)
+{
+  rtems_status_code sc;
+
+  if ( ctx->worker_id != 0 ) {
+    sc = rtems_task_delete( ctx->worker_id );
+    T_rsc_success( sc );
+  }
+}
+
+static void RtemsBarrierReqCreate_Teardown_Wrap( void *arg )
+{
+  RtemsBarrierReqCreate_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqCreate_Teardown( ctx );
+}
+
+static size_t RtemsBarrierReqCreate_Scope( void *arg, char *buf, size_t n )
+{
+  RtemsBarrierReqCreate_Context *ctx;
+
+  ctx = arg;
+
+  if ( ctx->in_action_loop ) {
+    return T_get_scope( RtemsBarrierReqCreate_PreDesc, buf, n, ctx->pcs );
+  }
+
+  return 0;
+}
+
+static T_fixture RtemsBarrierReqCreate_Fixture = {
+  .setup = RtemsBarrierReqCreate_Setup_Wrap,
+  .stop = NULL,
+  .teardown = RtemsBarrierReqCreate_Teardown_Wrap,
+  .scope = RtemsBarrierReqCreate_Scope,
+  .initial_context = &RtemsBarrierReqCreate_Instance
+};
+
+static const uint8_t RtemsBarrierReqCreate_TransitionMap[][ 3 ] = {
+  {
+    RtemsBarrierReqCreate_Post_Status_Ok,
+    RtemsBarrierReqCreate_Post_Id_Valid,
+    RtemsBarrierReqCreate_Post_Class_Manual
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvAddr,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_Ok,
+    RtemsBarrierReqCreate_Post_Id_Valid,
+    RtemsBarrierReqCreate_Post_Class_Manual
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvAddr,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_Ok,
+    RtemsBarrierReqCreate_Post_Id_Valid,
+    RtemsBarrierReqCreate_Post_Class_Manual
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvAddr,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_Ok,
+    RtemsBarrierReqCreate_Post_Id_Valid,
+    RtemsBarrierReqCreate_Post_Class_Manual
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvAddr,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvNum,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvAddr,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_Ok,
+    RtemsBarrierReqCreate_Post_Id_Valid,
+    RtemsBarrierReqCreate_Post_Class_Auto
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvAddr,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }, {
+    RtemsBarrierReqCreate_Post_Status_InvName,
+    RtemsBarrierReqCreate_Post_Id_Invalid,
+    RtemsBarrierReqCreate_Post_Class_NoObj
+  }
+};
+
+static const struct {
+  uint8_t Skip : 1;
+  uint8_t Pre_Name_NA : 1;
+  uint8_t Pre_Class_NA : 1;
+  uint8_t Pre_MaxWait_NA : 1;
+  uint8_t Pre_Id_NA : 1;
+} RtemsBarrierReqCreate_TransitionInfo[] = {
+  {
+    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, 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, 0, 0, 0, 0
+  }, {
+    0, 0, 0, 0, 0
+  }, {
+    0, 0, 0, 0, 0
+  }, {
+    0, 0, 0, 0, 0
+  }, {
+    0, 0, 0, 0, 0
+  }
+};
+
+static void RtemsBarrierReqCreate_Action( RtemsBarrierReqCreate_Context *ctx )
+{
+  ctx->status = rtems_barrier_create(
+    ctx->name,
+    ctx->attribute_set,
+    ctx->maximum_waiters,
+    ctx->id
+  );
+}
+
+static void RtemsBarrierReqCreate_Cleanup( RtemsBarrierReqCreate_Context *ctx )
+{
+  if ( ctx->id_value != INVALID_ID ) {
+    rtems_status_code sc;
+
+    sc = rtems_barrier_delete( ctx->id_value );
+    T_rsc_success( sc );
+
+    ctx->id_value = INVALID_ID;
+  }
+}
+
+/**
+ * @fn void T_case_body_RtemsBarrierReqCreate( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsBarrierReqCreate, &RtemsBarrierReqCreate_Fixture )
+{
+  RtemsBarrierReqCreate_Context *ctx;
+  size_t index;
+
+  ctx = T_fixture_context();
+  ctx->in_action_loop = true;
+  index = 0;
+
+  for (
+    ctx->pcs[ 0 ] = RtemsBarrierReqCreate_Pre_Name_Valid;
+    ctx->pcs[ 0 ] < RtemsBarrierReqCreate_Pre_Name_NA;
+    ++ctx->pcs[ 0 ]
+  ) {
+    if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Name_NA ) {
+      ctx->pcs[ 0 ] = RtemsBarrierReqCreate_Pre_Name_NA;
+      index += ( RtemsBarrierReqCreate_Pre_Name_NA - 1 )
+        * RtemsBarrierReqCreate_Pre_Class_NA
+        * RtemsBarrierReqCreate_Pre_MaxWait_NA
+        * RtemsBarrierReqCreate_Pre_Id_NA;
+    }
+
+    for (
+      ctx->pcs[ 1 ] = RtemsBarrierReqCreate_Pre_Class_Default;
+      ctx->pcs[ 1 ] < RtemsBarrierReqCreate_Pre_Class_NA;
+      ++ctx->pcs[ 1 ]
+    ) {
+      if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Class_NA ) {
+        ctx->pcs[ 1 ] = RtemsBarrierReqCreate_Pre_Class_NA;
+        index += ( RtemsBarrierReqCreate_Pre_Class_NA - 1 )
+          * RtemsBarrierReqCreate_Pre_MaxWait_NA
+          * RtemsBarrierReqCreate_Pre_Id_NA;
+      }
+
+      for (
+        ctx->pcs[ 2 ] = RtemsBarrierReqCreate_Pre_MaxWait_Zero;
+        ctx->pcs[ 2 ] < RtemsBarrierReqCreate_Pre_MaxWait_NA;
+        ++ctx->pcs[ 2 ]
+      ) {
+        if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_MaxWait_NA ) {
+          ctx->pcs[ 2 ] = RtemsBarrierReqCreate_Pre_MaxWait_NA;
+          index += ( RtemsBarrierReqCreate_Pre_MaxWait_NA - 1 )
+            * RtemsBarrierReqCreate_Pre_Id_NA;
+        }
+
+        for (
+          ctx->pcs[ 3 ] = RtemsBarrierReqCreate_Pre_Id_Valid;
+          ctx->pcs[ 3 ] < RtemsBarrierReqCreate_Pre_Id_NA;
+          ++ctx->pcs[ 3 ]
+        ) {
+          if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Id_NA ) {
+            ctx->pcs[ 3 ] = RtemsBarrierReqCreate_Pre_Id_NA;
+            index += ( RtemsBarrierReqCreate_Pre_Id_NA - 1 );
+          }
+
+          if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Skip ) {
+            ++index;
+            continue;
+          }
+
+          RtemsBarrierReqCreate_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] );
+          RtemsBarrierReqCreate_Pre_Class_Prepare( ctx, ctx->pcs[ 1 ] );
+          RtemsBarrierReqCreate_Pre_MaxWait_Prepare( ctx, ctx->pcs[ 2 ] );
+          RtemsBarrierReqCreate_Pre_Id_Prepare( ctx, ctx->pcs[ 3 ] );
+          RtemsBarrierReqCreate_Action( ctx );
+          RtemsBarrierReqCreate_Post_Status_Check(
+            ctx,
+            RtemsBarrierReqCreate_TransitionMap[ index ][ 0 ]
+          );
+          RtemsBarrierReqCreate_Post_Id_Check(
+            ctx,
+            RtemsBarrierReqCreate_TransitionMap[ index ][ 1 ]
+          );
+          RtemsBarrierReqCreate_Post_Class_Check(
+            ctx,
+            RtemsBarrierReqCreate_TransitionMap[ index ][ 2 ]
+          );
+          RtemsBarrierReqCreate_Cleanup( ctx );
+          ++index;
+        }
+      }
+    }
+  }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-barrier-delete.c b/testsuites/validation/tc-barrier-delete.c
new file mode 100644
index 0000000000..f02ddadbce
--- /dev/null
+++ b/testsuites/validation/tc-barrier-delete.c
@@ -0,0 +1,451 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsBarrierReqDelete
+ */
+
+/*
+ * 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 <rtems.h>
+#include <string.h>
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsBarrierReqDelete spec:/rtems/barrier/req/delete
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+  RtemsBarrierReqDelete_Pre_Id_Valid,
+  RtemsBarrierReqDelete_Pre_Id_Invalid,
+  RtemsBarrierReqDelete_Pre_Id_NA
+} RtemsBarrierReqDelete_Pre_Id;
+
+typedef enum {
+  RtemsBarrierReqDelete_Post_Status_Ok,
+  RtemsBarrierReqDelete_Post_Status_InvId,
+  RtemsBarrierReqDelete_Post_Status_NA
+} RtemsBarrierReqDelete_Post_Status;
+
+typedef enum {
+  RtemsBarrierReqDelete_Post_Id_Valid,
+  RtemsBarrierReqDelete_Post_Id_Invalid,
+  RtemsBarrierReqDelete_Post_Id_NA
+} RtemsBarrierReqDelete_Post_Id;
+
+typedef enum {
+  RtemsBarrierReqDelete_Post_Flush_Yes,
+  RtemsBarrierReqDelete_Post_Flush_No,
+  RtemsBarrierReqDelete_Post_Flush_NA
+} RtemsBarrierReqDelete_Post_Flush;
+
+/**
+ * @brief Test context for spec:/rtems/barrier/req/delete test case.
+ */
+typedef struct {
+  rtems_id worker_id;
+
+  rtems_id barrier_id;
+
+  uint32_t wait_done;
+
+  uint32_t wait_expected;
+
+  rtems_id id;
+
+  rtems_status_code status;
+
+  /**
+   * @brief This member defines the pre-condition states for the next action.
+   */
+  size_t pcs[ 1 ];
+
+  /**
+   * @brief This member indicates if the test action loop is currently
+   *   executed.
+   */
+  bool in_action_loop;
+} RtemsBarrierReqDelete_Context;
+
+static RtemsBarrierReqDelete_Context
+  RtemsBarrierReqDelete_Instance;
+
+static const char * const RtemsBarrierReqDelete_PreDesc_Id[] = {
+  "Valid",
+  "Invalid",
+  "NA"
+};
+
+static const char * const * const RtemsBarrierReqDelete_PreDesc[] = {
+  RtemsBarrierReqDelete_PreDesc_Id,
+  NULL
+};
+
+#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
+
+typedef RtemsBarrierReqDelete_Context Context;
+
+typedef enum {
+  PRIO_HIGH = 1,
+  PRIO_NORMAL,
+  PRIO_LOW
+} Priorities;
+
+static void Worker( rtems_task_argument arg )
+{
+  Context *ctx;
+
+  ctx = (Context *) arg;
+
+  while ( true ) {
+    rtems_status_code   sc;
+    rtems_task_priority prio;
+
+    T_eq_u32( ctx->barrier_id, 0 );
+
+    sc = rtems_barrier_create(
+      NAME,
+      RTEMS_DEFAULT_ATTRIBUTES,
+      0,
+      &ctx->barrier_id
+    );
+    T_rsc_success( sc );
+
+    sc = rtems_barrier_wait(
+      ctx->barrier_id,
+      RTEMS_NO_TIMEOUT
+    );
+    T_rsc( sc, RTEMS_OBJECT_WAS_DELETED );
+
+    ++ctx->wait_done;
+
+    prio = 0;
+    sc = rtems_task_set_priority( RTEMS_SELF, PRIO_LOW, &prio );
+    T_rsc_success( sc );
+    T_eq_u32( prio, PRIO_HIGH );
+  }
+}
+
+static void RtemsBarrierReqDelete_Pre_Id_Prepare(
+  RtemsBarrierReqDelete_Context *ctx,
+  RtemsBarrierReqDelete_Pre_Id   state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqDelete_Pre_Id_Valid: {
+      ctx->id = ctx->barrier_id;
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Pre_Id_Invalid: {
+      ctx->id = 0;
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Pre_Id_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqDelete_Post_Status_Check(
+  RtemsBarrierReqDelete_Context    *ctx,
+  RtemsBarrierReqDelete_Post_Status state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqDelete_Post_Status_Ok: {
+      ctx->barrier_id = 0;
+      T_rsc_success( ctx->status );
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Post_Status_InvId: {
+      T_rsc( ctx->status, RTEMS_INVALID_ID );
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Post_Status_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqDelete_Post_Id_Check(
+  RtemsBarrierReqDelete_Context *ctx,
+  RtemsBarrierReqDelete_Post_Id  state
+)
+{
+  rtems_status_code sc;
+  rtems_id          id;
+
+  switch ( state ) {
+    case RtemsBarrierReqDelete_Post_Id_Valid: {
+      id = 0;
+      sc = rtems_barrier_ident( NAME, &id );
+      T_rsc_success( sc );
+      T_eq_u32( id, ctx->barrier_id );
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Post_Id_Invalid: {
+      sc = rtems_barrier_ident( NAME, &id );
+      T_rsc( sc, RTEMS_INVALID_NAME );
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Post_Id_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqDelete_Post_Flush_Check(
+  RtemsBarrierReqDelete_Context   *ctx,
+  RtemsBarrierReqDelete_Post_Flush state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqDelete_Post_Flush_Yes: {
+      ++ctx->wait_expected;
+      T_eq_u32( ctx->wait_done, ctx->wait_expected );
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Post_Flush_No: {
+      T_eq_u32( ctx->wait_done, ctx->wait_expected );
+      break;
+    }
+
+    case RtemsBarrierReqDelete_Post_Flush_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqDelete_Setup( RtemsBarrierReqDelete_Context *ctx )
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  memset( ctx, 0, sizeof( *ctx ) );
+
+  prio = 0;
+  sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
+  T_rsc_success( sc );
+  T_eq_u32( prio, PRIO_HIGH );
+
+  sc = rtems_task_create(
+    rtems_build_name( 'W', 'O', 'R', 'K' ),
+    PRIO_LOW,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->worker_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
+  T_assert_rsc_success( sc );
+}
+
+static void RtemsBarrierReqDelete_Setup_Wrap( void *arg )
+{
+  RtemsBarrierReqDelete_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqDelete_Setup( ctx );
+}
+
+static void RtemsBarrierReqDelete_Teardown(
+  RtemsBarrierReqDelete_Context *ctx
+)
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  prio = 0;
+  sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
+  T_rsc_success( sc );
+  T_eq_u32( prio, PRIO_NORMAL );
+
+  if ( ctx->worker_id != 0 ) {
+    sc = rtems_task_delete( ctx->worker_id );
+    T_rsc_success( sc );
+  }
+}
+
+static void RtemsBarrierReqDelete_Teardown_Wrap( void *arg )
+{
+  RtemsBarrierReqDelete_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqDelete_Teardown( ctx );
+}
+
+static size_t RtemsBarrierReqDelete_Scope( void *arg, char *buf, size_t n )
+{
+  RtemsBarrierReqDelete_Context *ctx;
+
+  ctx = arg;
+
+  if ( ctx->in_action_loop ) {
+    return T_get_scope( RtemsBarrierReqDelete_PreDesc, buf, n, ctx->pcs );
+  }
+
+  return 0;
+}
+
+static T_fixture RtemsBarrierReqDelete_Fixture = {
+  .setup = RtemsBarrierReqDelete_Setup_Wrap,
+  .stop = NULL,
+  .teardown = RtemsBarrierReqDelete_Teardown_Wrap,
+  .scope = RtemsBarrierReqDelete_Scope,
+  .initial_context = &RtemsBarrierReqDelete_Instance
+};
+
+static const uint8_t RtemsBarrierReqDelete_TransitionMap[][ 3 ] = {
+  {
+    RtemsBarrierReqDelete_Post_Status_Ok,
+    RtemsBarrierReqDelete_Post_Id_Invalid,
+    RtemsBarrierReqDelete_Post_Flush_Yes
+  }, {
+    RtemsBarrierReqDelete_Post_Status_InvId,
+    RtemsBarrierReqDelete_Post_Id_Valid,
+    RtemsBarrierReqDelete_Post_Flush_No
+  }
+};
+
+static const struct {
+  uint8_t Skip : 1;
+  uint8_t Pre_Id_NA : 1;
+} RtemsBarrierReqDelete_TransitionInfo[] = {
+  {
+    0, 0
+  }, {
+    0, 0
+  }
+};
+
+static void RtemsBarrierReqDelete_Prepare( RtemsBarrierReqDelete_Context *ctx )
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  prio = 0;
+  sc = rtems_task_set_priority( ctx->worker_id, PRIO_HIGH, &prio );
+  T_rsc_success( sc );
+  T_true( prio == PRIO_LOW || prio == PRIO_HIGH );
+}
+
+static void RtemsBarrierReqDelete_Action( RtemsBarrierReqDelete_Context *ctx )
+{
+  ctx->status = rtems_barrier_delete( ctx->id );
+}
+
+static void RtemsBarrierReqDelete_Cleanup( RtemsBarrierReqDelete_Context *ctx )
+{
+  if ( ctx->barrier_id != 0 ) {
+    rtems_status_code sc;
+
+    sc = rtems_barrier_delete( ctx->barrier_id );
+    T_rsc_success( sc );
+  }
+}
+
+/**
+ * @fn void T_case_body_RtemsBarrierReqDelete( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsBarrierReqDelete, &RtemsBarrierReqDelete_Fixture )
+{
+  RtemsBarrierReqDelete_Context *ctx;
+  size_t index;
+
+  ctx = T_fixture_context();
+  ctx->in_action_loop = true;
+  index = 0;
+
+  for (
+    ctx->pcs[ 0 ] = RtemsBarrierReqDelete_Pre_Id_Valid;
+    ctx->pcs[ 0 ] < RtemsBarrierReqDelete_Pre_Id_NA;
+    ++ctx->pcs[ 0 ]
+  ) {
+    if ( RtemsBarrierReqDelete_TransitionInfo[ index ].Pre_Id_NA ) {
+      ctx->pcs[ 0 ] = RtemsBarrierReqDelete_Pre_Id_NA;
+      index += ( RtemsBarrierReqDelete_Pre_Id_NA - 1 );
+    }
+
+    if ( RtemsBarrierReqDelete_TransitionInfo[ index ].Skip ) {
+      ++index;
+      continue;
+    }
+
+    RtemsBarrierReqDelete_Prepare( ctx );
+    RtemsBarrierReqDelete_Pre_Id_Prepare( ctx, ctx->pcs[ 0 ] );
+    RtemsBarrierReqDelete_Action( ctx );
+    RtemsBarrierReqDelete_Post_Status_Check(
+      ctx,
+      RtemsBarrierReqDelete_TransitionMap[ index ][ 0 ]
+    );
+    RtemsBarrierReqDelete_Post_Id_Check(
+      ctx,
+      RtemsBarrierReqDelete_TransitionMap[ index ][ 1 ]
+    );
+    RtemsBarrierReqDelete_Post_Flush_Check(
+      ctx,
+      RtemsBarrierReqDelete_TransitionMap[ index ][ 2 ]
+    );
+    RtemsBarrierReqDelete_Cleanup( ctx );
+    ++index;
+  }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-barrier-release.c b/testsuites/validation/tc-barrier-release.c
new file mode 100644
index 0000000000..7b1064c247
--- /dev/null
+++ b/testsuites/validation/tc-barrier-release.c
@@ -0,0 +1,588 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsBarrierReqRelease
+ */
+
+/*
+ * 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 <rtems.h>
+#include <string.h>
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsBarrierReqRelease \
+ *   spec:/rtems/barrier/req/release
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+  RtemsBarrierReqRelease_Pre_Barrier_NoObj,
+  RtemsBarrierReqRelease_Pre_Barrier_Manual,
+  RtemsBarrierReqRelease_Pre_Barrier_Auto,
+  RtemsBarrierReqRelease_Pre_Barrier_NA
+} RtemsBarrierReqRelease_Pre_Barrier;
+
+typedef enum {
+  RtemsBarrierReqRelease_Pre_Released_Valid,
+  RtemsBarrierReqRelease_Pre_Released_Null,
+  RtemsBarrierReqRelease_Pre_Released_NA
+} RtemsBarrierReqRelease_Pre_Released;
+
+typedef enum {
+  RtemsBarrierReqRelease_Pre_Waiting_Zero,
+  RtemsBarrierReqRelease_Pre_Waiting_Positive,
+  RtemsBarrierReqRelease_Pre_Waiting_NA
+} RtemsBarrierReqRelease_Pre_Waiting;
+
+typedef enum {
+  RtemsBarrierReqRelease_Post_Status_Ok,
+  RtemsBarrierReqRelease_Post_Status_InvId,
+  RtemsBarrierReqRelease_Post_Status_InvAddr,
+  RtemsBarrierReqRelease_Post_Status_NA
+} RtemsBarrierReqRelease_Post_Status;
+
+typedef enum {
+  RtemsBarrierReqRelease_Post_Released_Valid,
+  RtemsBarrierReqRelease_Post_Released_Unchanged,
+  RtemsBarrierReqRelease_Post_Released_NA
+} RtemsBarrierReqRelease_Post_Released;
+
+/**
+ * @brief Test context for spec:/rtems/barrier/req/release test case.
+ */
+typedef struct {
+  rtems_id worker_id;
+
+  rtems_id manual_release_id;
+
+  rtems_id auto_release_id;
+
+  uint32_t waiting_tasks;
+
+  uint32_t released_value;
+
+  rtems_id id;
+
+  uint32_t *released;
+
+  rtems_status_code status;
+
+  /**
+   * @brief This member defines the pre-condition states for the next action.
+   */
+  size_t pcs[ 3 ];
+
+  /**
+   * @brief This member indicates if the test action loop is currently
+   *   executed.
+   */
+  bool in_action_loop;
+} RtemsBarrierReqRelease_Context;
+
+static RtemsBarrierReqRelease_Context
+  RtemsBarrierReqRelease_Instance;
+
+static const char * const RtemsBarrierReqRelease_PreDesc_Barrier[] = {
+  "NoObj",
+  "Manual",
+  "Auto",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqRelease_PreDesc_Released[] = {
+  "Valid",
+  "Null",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqRelease_PreDesc_Waiting[] = {
+  "Zero",
+  "Positive",
+  "NA"
+};
+
+static const char * const * const RtemsBarrierReqRelease_PreDesc[] = {
+  RtemsBarrierReqRelease_PreDesc_Barrier,
+  RtemsBarrierReqRelease_PreDesc_Released,
+  RtemsBarrierReqRelease_PreDesc_Waiting,
+  NULL
+};
+
+#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
+
+#define EVENT_WAIT RTEMS_EVENT_0
+
+#define RELEASED_INVALID_VALUE 0xffffffff
+
+typedef RtemsBarrierReqRelease_Context Context;
+
+typedef enum {
+  PRIO_HIGH = 1,
+  PRIO_NORMAL
+} Priorities;
+
+static void SendEvents( rtems_id id, rtems_event_set events )
+{
+  rtems_status_code sc;
+
+  sc = rtems_event_send( id, events );
+  T_rsc_success( sc );
+}
+
+static void Worker( rtems_task_argument arg )
+{
+  Context *ctx;
+
+  ctx = (Context *) arg;
+
+  while ( true ) {
+    rtems_status_code sc;
+    rtems_event_set   events;
+
+    events = 0;
+    sc = rtems_event_receive(
+      RTEMS_ALL_EVENTS,
+      RTEMS_EVENT_ANY | RTEMS_WAIT,
+      RTEMS_NO_TIMEOUT,
+      &events
+    );
+    T_rsc_success( sc );
+
+    if ( ( events & EVENT_WAIT ) != 0 ) {
+      sc = rtems_barrier_wait( ctx->id, RTEMS_NO_TIMEOUT );
+      T_rsc_success( sc );
+    }
+  }
+}
+
+static void RtemsBarrierReqRelease_Pre_Barrier_Prepare(
+  RtemsBarrierReqRelease_Context    *ctx,
+  RtemsBarrierReqRelease_Pre_Barrier state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqRelease_Pre_Barrier_NoObj: {
+      ctx->id = 0xffffffff;
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Barrier_Manual: {
+      ctx->id = ctx->manual_release_id;
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Barrier_Auto: {
+      ctx->id = ctx->auto_release_id;
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Barrier_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqRelease_Pre_Released_Prepare(
+  RtemsBarrierReqRelease_Context     *ctx,
+  RtemsBarrierReqRelease_Pre_Released state
+)
+{
+  ctx->released_value = RELEASED_INVALID_VALUE;
+
+  switch ( state ) {
+    case RtemsBarrierReqRelease_Pre_Released_Valid: {
+      ctx->released = &ctx->released_value;
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Released_Null: {
+      ctx->released = NULL;
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Released_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqRelease_Pre_Waiting_Prepare(
+  RtemsBarrierReqRelease_Context    *ctx,
+  RtemsBarrierReqRelease_Pre_Waiting state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqRelease_Pre_Waiting_Zero: {
+      ctx->waiting_tasks = 0;
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Waiting_Positive: {
+      ctx->waiting_tasks = 1;
+      SendEvents( ctx->worker_id, EVENT_WAIT );
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Pre_Waiting_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqRelease_Post_Status_Check(
+  RtemsBarrierReqRelease_Context    *ctx,
+  RtemsBarrierReqRelease_Post_Status state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqRelease_Post_Status_Ok: {
+      T_rsc_success( ctx->status );
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Post_Status_InvId: {
+      T_rsc( ctx->status, RTEMS_INVALID_ID );
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Post_Status_InvAddr: {
+      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Post_Status_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqRelease_Post_Released_Check(
+  RtemsBarrierReqRelease_Context      *ctx,
+  RtemsBarrierReqRelease_Post_Released state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqRelease_Post_Released_Valid: {
+      T_eq_u32( ctx->released_value, ctx->waiting_tasks );
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Post_Released_Unchanged: {
+      T_eq_u32( ctx->released_value, RELEASED_INVALID_VALUE );
+      break;
+    }
+
+    case RtemsBarrierReqRelease_Post_Released_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqRelease_Setup( RtemsBarrierReqRelease_Context *ctx )
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  memset( ctx, 0, sizeof( *ctx ) );
+
+  prio = 0;
+  sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
+  T_rsc_success( sc );
+  T_eq_u32( prio, PRIO_HIGH );
+
+  sc = rtems_task_create(
+    rtems_build_name( 'W', 'O', 'R', 'K' ),
+    PRIO_HIGH,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->worker_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_task_start(
+    ctx->worker_id,
+    Worker,
+    (rtems_task_argument) ctx
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_barrier_create(
+    NAME,
+    RTEMS_BARRIER_MANUAL_RELEASE,
+    0,
+    &ctx->manual_release_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_barrier_create(
+    NAME,
+    RTEMS_BARRIER_AUTOMATIC_RELEASE,
+    2,
+    &ctx->auto_release_id
+  );
+  T_assert_rsc_success( sc );
+}
+
+static void RtemsBarrierReqRelease_Setup_Wrap( void *arg )
+{
+  RtemsBarrierReqRelease_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqRelease_Setup( ctx );
+}
+
+static void RtemsBarrierReqRelease_Teardown(
+  RtemsBarrierReqRelease_Context *ctx
+)
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  prio = 0;
+  sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
+  T_rsc_success( sc );
+  T_eq_u32( prio, PRIO_NORMAL );
+
+  if ( ctx->worker_id != 0 ) {
+    sc = rtems_task_delete( ctx->worker_id );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->manual_release_id != 0 ) {
+    sc = rtems_barrier_delete( ctx->manual_release_id );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->auto_release_id != 0 ) {
+    sc = rtems_barrier_delete( ctx->auto_release_id );
+    T_rsc_success( sc );
+  }
+}
+
+static void RtemsBarrierReqRelease_Teardown_Wrap( void *arg )
+{
+  RtemsBarrierReqRelease_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqRelease_Teardown( ctx );
+}
+
+static size_t RtemsBarrierReqRelease_Scope( void *arg, char *buf, size_t n )
+{
+  RtemsBarrierReqRelease_Context *ctx;
+
+  ctx = arg;
+
+  if ( ctx->in_action_loop ) {
+    return T_get_scope( RtemsBarrierReqRelease_PreDesc, buf, n, ctx->pcs );
+  }
+
+  return 0;
+}
+
+static T_fixture RtemsBarrierReqRelease_Fixture = {
+  .setup = RtemsBarrierReqRelease_Setup_Wrap,
+  .stop = NULL,
+  .teardown = RtemsBarrierReqRelease_Teardown_Wrap,
+  .scope = RtemsBarrierReqRelease_Scope,
+  .initial_context = &RtemsBarrierReqRelease_Instance
+};
+
+static const uint8_t RtemsBarrierReqRelease_TransitionMap[][ 2 ] = {
+  {
+    RtemsBarrierReqRelease_Post_Status_InvId,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvId,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvAddr,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvAddr,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_Ok,
+    RtemsBarrierReqRelease_Post_Released_Valid
+  }, {
+    RtemsBarrierReqRelease_Post_Status_Ok,
+    RtemsBarrierReqRelease_Post_Released_Valid
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvAddr,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvAddr,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_Ok,
+    RtemsBarrierReqRelease_Post_Released_Valid
+  }, {
+    RtemsBarrierReqRelease_Post_Status_Ok,
+    RtemsBarrierReqRelease_Post_Released_Valid
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvAddr,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }, {
+    RtemsBarrierReqRelease_Post_Status_InvAddr,
+    RtemsBarrierReqRelease_Post_Released_Unchanged
+  }
+};
+
+static const struct {
+  uint8_t Skip : 1;
+  uint8_t Pre_Barrier_NA : 1;
+  uint8_t Pre_Released_NA : 1;
+  uint8_t Pre_Waiting_NA : 1;
+} RtemsBarrierReqRelease_TransitionInfo[] = {
+  {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 0
+  }, {
+    0, 0, 0, 0
+  }, {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 0
+  }, {
+    0, 0, 0, 0
+  }, {
+    0, 0, 0, 1
+  }, {
+    0, 0, 0, 1
+  }
+};
+
+static void RtemsBarrierReqRelease_Action(
+  RtemsBarrierReqRelease_Context *ctx
+)
+{
+  ctx->status = rtems_barrier_release( ctx->id, ctx->released );
+}
+
+/**
+ * @fn void T_case_body_RtemsBarrierReqRelease( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsBarrierReqRelease, &RtemsBarrierReqRelease_Fixture )
+{
+  RtemsBarrierReqRelease_Context *ctx;
+  size_t index;
+
+  ctx = T_fixture_context();
+  ctx->in_action_loop = true;
+  index = 0;
+
+  for (
+    ctx->pcs[ 0 ] = RtemsBarrierReqRelease_Pre_Barrier_NoObj;
+    ctx->pcs[ 0 ] < RtemsBarrierReqRelease_Pre_Barrier_NA;
+    ++ctx->pcs[ 0 ]
+  ) {
+    if ( RtemsBarrierReqRelease_TransitionInfo[ index ].Pre_Barrier_NA ) {
+      ctx->pcs[ 0 ] = RtemsBarrierReqRelease_Pre_Barrier_NA;
+      index += ( RtemsBarrierReqRelease_Pre_Barrier_NA - 1 )
+        * RtemsBarrierReqRelease_Pre_Released_NA
+        * RtemsBarrierReqRelease_Pre_Waiting_NA;
+    }
+
+    for (
+      ctx->pcs[ 1 ] = RtemsBarrierReqRelease_Pre_Released_Valid;
+      ctx->pcs[ 1 ] < RtemsBarrierReqRelease_Pre_Released_NA;
+      ++ctx->pcs[ 1 ]
+    ) {
+      if ( RtemsBarrierReqRelease_TransitionInfo[ index ].Pre_Released_NA ) {
+        ctx->pcs[ 1 ] = RtemsBarrierReqRelease_Pre_Released_NA;
+        index += ( RtemsBarrierReqRelease_Pre_Released_NA - 1 )
+          * RtemsBarrierReqRelease_Pre_Waiting_NA;
+      }
+
+      for (
+        ctx->pcs[ 2 ] = RtemsBarrierReqRelease_Pre_Waiting_Zero;
+        ctx->pcs[ 2 ] < RtemsBarrierReqRelease_Pre_Waiting_NA;
+        ++ctx->pcs[ 2 ]
+      ) {
+        if ( RtemsBarrierReqRelease_TransitionInfo[ index ].Pre_Waiting_NA ) {
+          ctx->pcs[ 2 ] = RtemsBarrierReqRelease_Pre_Waiting_NA;
+          index += ( RtemsBarrierReqRelease_Pre_Waiting_NA - 1 );
+        }
+
+        if ( RtemsBarrierReqRelease_TransitionInfo[ index ].Skip ) {
+          ++index;
+          continue;
+        }
+
+        RtemsBarrierReqRelease_Pre_Barrier_Prepare( ctx, ctx->pcs[ 0 ] );
+        RtemsBarrierReqRelease_Pre_Released_Prepare( ctx, ctx->pcs[ 1 ] );
+        RtemsBarrierReqRelease_Pre_Waiting_Prepare( ctx, ctx->pcs[ 2 ] );
+        RtemsBarrierReqRelease_Action( ctx );
+        RtemsBarrierReqRelease_Post_Status_Check(
+          ctx,
+          RtemsBarrierReqRelease_TransitionMap[ index ][ 0 ]
+        );
+        RtemsBarrierReqRelease_Post_Released_Check(
+          ctx,
+          RtemsBarrierReqRelease_TransitionMap[ index ][ 1 ]
+        );
+        ++index;
+      }
+    }
+  }
+}
+
+/** @} */
diff --git a/testsuites/validation/tc-barrier-wait.c b/testsuites/validation/tc-barrier-wait.c
new file mode 100644
index 0000000000..83663cfed8
--- /dev/null
+++ b/testsuites/validation/tc-barrier-wait.c
@@ -0,0 +1,687 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsBarrierReqWait
+ */
+
+/*
+ * 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 <rtems.h>
+#include <string.h>
+
+#include <rtems/test.h>
+
+/**
+ * @defgroup RTEMSTestCaseRtemsBarrierReqWait spec:/rtems/barrier/req/wait
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+  RtemsBarrierReqWait_Pre_Barrier_NoObj,
+  RtemsBarrierReqWait_Pre_Barrier_Manual,
+  RtemsBarrierReqWait_Pre_Barrier_Auto,
+  RtemsBarrierReqWait_Pre_Barrier_NA
+} RtemsBarrierReqWait_Pre_Barrier;
+
+typedef enum {
+  RtemsBarrierReqWait_Pre_Timeout_Ticks,
+  RtemsBarrierReqWait_Pre_Timeout_Forever,
+  RtemsBarrierReqWait_Pre_Timeout_NA
+} RtemsBarrierReqWait_Pre_Timeout;
+
+typedef enum {
+  RtemsBarrierReqWait_Pre_Satisfy_Never,
+  RtemsBarrierReqWait_Pre_Satisfy_Wait,
+  RtemsBarrierReqWait_Pre_Satisfy_Release,
+  RtemsBarrierReqWait_Pre_Satisfy_Delete,
+  RtemsBarrierReqWait_Pre_Satisfy_NA
+} RtemsBarrierReqWait_Pre_Satisfy;
+
+typedef enum {
+  RtemsBarrierReqWait_Post_Status_Ok,
+  RtemsBarrierReqWait_Post_Status_InvId,
+  RtemsBarrierReqWait_Post_Status_Timeout,
+  RtemsBarrierReqWait_Post_Status_ObjDel,
+  RtemsBarrierReqWait_Post_Status_NoReturn,
+  RtemsBarrierReqWait_Post_Status_NA
+} RtemsBarrierReqWait_Post_Status;
+
+/**
+ * @brief Test context for spec:/rtems/barrier/req/wait test case.
+ */
+typedef struct {
+  rtems_id main_id;
+
+  rtems_id high_worker_id;
+
+  rtems_id low_worker_id;
+
+  rtems_id manual_release_id;
+
+  rtems_id auto_release_id;
+
+  rtems_id id;
+
+  rtems_interval timeout;
+
+  rtems_status_code status;
+
+  /**
+   * @brief This member defines the pre-condition states for the next action.
+   */
+  size_t pcs[ 3 ];
+
+  /**
+   * @brief This member indicates if the test action loop is currently
+   *   executed.
+   */
+  bool in_action_loop;
+} RtemsBarrierReqWait_Context;
+
+static RtemsBarrierReqWait_Context
+  RtemsBarrierReqWait_Instance;
+
+static const char * const RtemsBarrierReqWait_PreDesc_Barrier[] = {
+  "NoObj",
+  "Manual",
+  "Auto",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqWait_PreDesc_Timeout[] = {
+  "Ticks",
+  "Forever",
+  "NA"
+};
+
+static const char * const RtemsBarrierReqWait_PreDesc_Satisfy[] = {
+  "Never",
+  "Wait",
+  "Release",
+  "Delete",
+  "NA"
+};
+
+static const char * const * const RtemsBarrierReqWait_PreDesc[] = {
+  RtemsBarrierReqWait_PreDesc_Barrier,
+  RtemsBarrierReqWait_PreDesc_Timeout,
+  RtemsBarrierReqWait_PreDesc_Satisfy,
+  NULL
+};
+
+#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
+
+#define EVENT_CHECK_TIMER RTEMS_EVENT_0
+
+#define EVENT_WAIT RTEMS_EVENT_1
+
+#define EVENT_RELEASE RTEMS_EVENT_2
+
+#define EVENT_DELETE RTEMS_EVENT_3
+
+typedef RtemsBarrierReqWait_Context Context;
+
+typedef enum {
+  PRIO_HIGH = 1,
+  PRIO_NORMAL,
+  PRIO_LOW
+} Priorities;
+
+static void SendEvents( rtems_id id, rtems_event_set events )
+{
+  rtems_status_code sc;
+
+  sc = rtems_event_send( id, events );
+  T_rsc_success( sc );
+}
+
+static void Worker( rtems_task_argument arg )
+{
+  Context *ctx;
+
+  ctx = (Context *) arg;
+
+  while ( true ) {
+    rtems_status_code sc;
+    rtems_event_set   events;
+
+    events = 0;
+    sc = rtems_event_receive(
+      RTEMS_ALL_EVENTS,
+      RTEMS_EVENT_ANY | RTEMS_WAIT,
+      RTEMS_NO_TIMEOUT,
+      &events
+    );
+    T_rsc_success( sc );
+
+    if ( ( events & EVENT_CHECK_TIMER ) != 0 ) {
+      T_eq_int(
+        T_THREAD_TIMER_PENDING,
+        T_get_thread_timer_state( ctx->main_id )
+      );
+    }
+
+    if ( ( events & EVENT_WAIT ) != 0 ) {
+      sc = rtems_barrier_wait( ctx->id, RTEMS_NO_TIMEOUT );
+      T_rsc_success( sc );
+    }
+
+    if ( ( events & EVENT_RELEASE ) != 0 ) {
+      uint32_t released;
+
+      sc = rtems_barrier_release( ctx->id, &released );
+      T_rsc_success( sc );
+    }
+
+    if ( ( events & EVENT_DELETE ) != 0 ) {
+      rtems_attribute     attribute_set;
+      uint32_t            maximum_waiters;
+      rtems_id           *id;
+      rtems_task_priority prio;
+
+      if ( ctx->id == ctx->manual_release_id ) {
+        attribute_set = RTEMS_BARRIER_MANUAL_RELEASE;
+        maximum_waiters = 0;
+        id = &ctx->manual_release_id;
+      } else {
+        attribute_set = RTEMS_BARRIER_AUTOMATIC_RELEASE;
+        maximum_waiters = 2;
+        id = &ctx->auto_release_id;
+      }
+
+      prio = 0;
+      sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
+      T_rsc_success( sc );
+      T_eq_u32( prio, PRIO_LOW );
+
+      sc = rtems_barrier_delete( ctx->id );
+      T_rsc_success( sc );
+
+      sc = rtems_barrier_create( NAME, attribute_set, maximum_waiters, id );
+      T_rsc_success( sc );
+
+      sc = rtems_task_set_priority( RTEMS_SELF, prio, &prio );
+      T_rsc_success( sc );
+      T_eq_u32( prio, PRIO_HIGH );
+    }
+  }
+}
+
+static void RtemsBarrierReqWait_Pre_Barrier_Prepare(
+  RtemsBarrierReqWait_Context    *ctx,
+  RtemsBarrierReqWait_Pre_Barrier state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqWait_Pre_Barrier_NoObj: {
+      ctx->id = 0xffffffff;
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Barrier_Manual: {
+      ctx->id = ctx->manual_release_id;
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Barrier_Auto: {
+      ctx->id = ctx->auto_release_id;
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Barrier_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqWait_Pre_Timeout_Prepare(
+  RtemsBarrierReqWait_Context    *ctx,
+  RtemsBarrierReqWait_Pre_Timeout state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqWait_Pre_Timeout_Ticks: {
+      ctx->timeout = 2;
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Timeout_Forever: {
+      ctx->timeout = RTEMS_NO_TIMEOUT;
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Timeout_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqWait_Pre_Satisfy_Prepare(
+  RtemsBarrierReqWait_Context    *ctx,
+  RtemsBarrierReqWait_Pre_Satisfy state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqWait_Pre_Satisfy_Never: {
+      if ( ctx->timeout == RTEMS_NO_TIMEOUT ) {
+        SendEvents( ctx->low_worker_id, EVENT_CHECK_TIMER | EVENT_RELEASE );
+      }
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Satisfy_Wait: {
+      SendEvents( ctx->high_worker_id, EVENT_WAIT );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Satisfy_Release: {
+      SendEvents( ctx->low_worker_id, EVENT_RELEASE );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Satisfy_Delete: {
+      SendEvents( ctx->low_worker_id, EVENT_DELETE );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Pre_Satisfy_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqWait_Post_Status_Check(
+  RtemsBarrierReqWait_Context    *ctx,
+  RtemsBarrierReqWait_Post_Status state
+)
+{
+  switch ( state ) {
+    case RtemsBarrierReqWait_Post_Status_Ok: {
+      T_rsc_success( ctx->status );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Post_Status_InvId: {
+      T_rsc( ctx->status, RTEMS_INVALID_ID );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Post_Status_Timeout: {
+      T_rsc( ctx->status, RTEMS_TIMEOUT );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Post_Status_ObjDel: {
+      T_rsc( ctx->status, RTEMS_OBJECT_WAS_DELETED );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Post_Status_NoReturn: {
+      T_rsc_success( ctx->status );
+      break;
+    }
+
+    case RtemsBarrierReqWait_Post_Status_NA:
+      break;
+  }
+}
+
+static void RtemsBarrierReqWait_Setup( RtemsBarrierReqWait_Context *ctx )
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  memset( ctx, 0, sizeof( *ctx ) );
+  ctx->main_id = rtems_task_self();
+
+  prio = 0;
+  sc = rtems_task_set_priority( RTEMS_SELF, PRIO_NORMAL, &prio );
+  T_rsc_success( sc );
+  T_eq_u32( prio, PRIO_HIGH );
+
+  sc = rtems_task_create(
+    rtems_build_name( 'W', 'O', 'R', 'K' ),
+    PRIO_HIGH,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->high_worker_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_task_start(
+    ctx->high_worker_id,
+    Worker,
+    (rtems_task_argument) ctx
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_task_create(
+    rtems_build_name( 'W', 'O', 'R', 'K' ),
+    PRIO_LOW,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &ctx->low_worker_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_task_start(
+    ctx->low_worker_id,
+    Worker,
+    (rtems_task_argument) ctx
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_barrier_create(
+    NAME,
+    RTEMS_BARRIER_MANUAL_RELEASE,
+    0,
+    &ctx->manual_release_id
+  );
+  T_assert_rsc_success( sc );
+
+  sc = rtems_barrier_create(
+    NAME,
+    RTEMS_BARRIER_AUTOMATIC_RELEASE,
+    2,
+    &ctx->auto_release_id
+  );
+  T_assert_rsc_success( sc );
+}
+
+static void RtemsBarrierReqWait_Setup_Wrap( void *arg )
+{
+  RtemsBarrierReqWait_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqWait_Setup( ctx );
+}
+
+static void RtemsBarrierReqWait_Teardown( RtemsBarrierReqWait_Context *ctx )
+{
+  rtems_status_code   sc;
+  rtems_task_priority prio;
+
+  prio = 0;
+  sc = rtems_task_set_priority( RTEMS_SELF, PRIO_HIGH, &prio );
+  T_rsc_success( sc );
+  T_eq_u32( prio, PRIO_NORMAL );
+
+  if ( ctx->high_worker_id != 0 ) {
+    sc = rtems_task_delete( ctx->high_worker_id );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->low_worker_id != 0 ) {
+    sc = rtems_task_delete( ctx->low_worker_id );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->manual_release_id != 0 ) {
+    sc = rtems_barrier_delete( ctx->manual_release_id );
+    T_rsc_success( sc );
+  }
+
+  if ( ctx->auto_release_id != 0 ) {
+    sc = rtems_barrier_delete( ctx->auto_release_id );
+    T_rsc_success( sc );
+  }
+}
+
+static void RtemsBarrierReqWait_Teardown_Wrap( void *arg )
+{
+  RtemsBarrierReqWait_Context *ctx;
+
+  ctx = arg;
+  ctx->in_action_loop = false;
+  RtemsBarrierReqWait_Teardown( ctx );
+}
+
+static size_t RtemsBarrierReqWait_Scope( void *arg, char *buf, size_t n )
+{
+  RtemsBarrierReqWait_Context *ctx;
+
+  ctx = arg;
+
+  if ( ctx->in_action_loop ) {
+    return T_get_scope( RtemsBarrierReqWait_PreDesc, buf, n, ctx->pcs );
+  }
+
+  return 0;
+}
+
+static T_fixture RtemsBarrierReqWait_Fixture = {
+  .setup = RtemsBarrierReqWait_Setup_Wrap,
+  .stop = NULL,
+  .teardown = RtemsBarrierReqWait_Teardown_Wrap,
+  .scope = RtemsBarrierReqWait_Scope,
+  .initial_context = &RtemsBarrierReqWait_Instance
+};
+
+static const uint8_t RtemsBarrierReqWait_TransitionMap[][ 1 ] = {
+  {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_InvId
+  }, {
+    RtemsBarrierReqWait_Post_Status_Timeout
+  }, {
+    RtemsBarrierReqWait_Post_Status_NA
+  }, {
+    RtemsBarrierReqWait_Post_Status_Ok
+  }, {
+    RtemsBarrierReqWait_Post_Status_ObjDel
+  }, {
+    RtemsBarrierReqWait_Post_Status_NoReturn
+  }, {
+    RtemsBarrierReqWait_Post_Status_NA
+  }, {
+    RtemsBarrierReqWait_Post_Status_Ok
+  }, {
+    RtemsBarrierReqWait_Post_Status_ObjDel
+  }, {
+    RtemsBarrierReqWait_Post_Status_Timeout
+  }, {
+    RtemsBarrierReqWait_Post_Status_Ok
+  }, {
+    RtemsBarrierReqWait_Post_Status_Ok
+  }, {
+    RtemsBarrierReqWait_Post_Status_ObjDel
+  }, {
+    RtemsBarrierReqWait_Post_Status_NoReturn
+  }, {
+    RtemsBarrierReqWait_Post_Status_Ok
+  }, {
+    RtemsBarrierReqWait_Post_Status_Ok
+  }, {
+    RtemsBarrierReqWait_Post_Status_ObjDel
+  }
+};
+
+static const struct {
+  uint8_t Skip : 1;
+  uint8_t Pre_Barrier_NA : 1;
+  uint8_t Pre_Timeout_NA : 1;
+  uint8_t Pre_Satisfy_NA : 1;
+} RtemsBarrierReqWait_TransitionInfo[] = {
+  {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 1, 1
+  }, {
+    0, 0, 0, 0
+  }, {
+    1, 0, 0, 0
+  }, {
+    0, 0, 0, 0
+  }, {
+    0, 0, 0, 0
+  }, {
+    0, 0, 0, 0
+  }, {
+    1, 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
+  }
+};
+
+static void RtemsBarrierReqWait_Action( RtemsBarrierReqWait_Context *ctx )
+{
+  ctx->status = rtems_barrier_wait( ctx->id, ctx->timeout );
+}
+
+/**
+ * @fn void T_case_body_RtemsBarrierReqWait( void )
+ */
+T_TEST_CASE_FIXTURE( RtemsBarrierReqWait, &RtemsBarrierReqWait_Fixture )
+{
+  RtemsBarrierReqWait_Context *ctx;
+  size_t index;
+
+  ctx = T_fixture_context();
+  ctx->in_action_loop = true;
+  index = 0;
+
+  for (
+    ctx->pcs[ 0 ] = RtemsBarrierReqWait_Pre_Barrier_NoObj;
+    ctx->pcs[ 0 ] < RtemsBarrierReqWait_Pre_Barrier_NA;
+    ++ctx->pcs[ 0 ]
+  ) {
+    if ( RtemsBarrierReqWait_TransitionInfo[ index ].Pre_Barrier_NA ) {
+      ctx->pcs[ 0 ] = RtemsBarrierReqWait_Pre_Barrier_NA;
+      index += ( RtemsBarrierReqWait_Pre_Barrier_NA - 1 )
+        * RtemsBarrierReqWait_Pre_Timeout_NA
+        * RtemsBarrierReqWait_Pre_Satisfy_NA;
+    }
+
+    for (
+      ctx->pcs[ 1 ] = RtemsBarrierReqWait_Pre_Timeout_Ticks;
+      ctx->pcs[ 1 ] < RtemsBarrierReqWait_Pre_Timeout_NA;
+      ++ctx->pcs[ 1 ]
+    ) {
+      if ( RtemsBarrierReqWait_TransitionInfo[ index ].Pre_Timeout_NA ) {
+        ctx->pcs[ 1 ] = RtemsBarrierReqWait_Pre_Timeout_NA;
+        index += ( RtemsBarrierReqWait_Pre_Timeout_NA - 1 )
+          * RtemsBarrierReqWait_Pre_Satisfy_NA;
+      }
+
+      for (
+        ctx->pcs[ 2 ] = RtemsBarrierReqWait_Pre_Satisfy_Never;
+        ctx->pcs[ 2 ] < RtemsBarrierReqWait_Pre_Satisfy_NA;
+        ++ctx->pcs[ 2 ]
+      ) {
+        if ( RtemsBarrierReqWait_TransitionInfo[ index ].Pre_Satisfy_NA ) {
+          ctx->pcs[ 2 ] = RtemsBarrierReqWait_Pre_Satisfy_NA;
+          index += ( RtemsBarrierReqWait_Pre_Satisfy_NA - 1 );
+        }
+
+        if ( RtemsBarrierReqWait_TransitionInfo[ index ].Skip ) {
+          ++index;
+          continue;
+        }
+
+        RtemsBarrierReqWait_Pre_Barrier_Prepare( ctx, ctx->pcs[ 0 ] );
+        RtemsBarrierReqWait_Pre_Timeout_Prepare( ctx, ctx->pcs[ 1 ] );
+        RtemsBarrierReqWait_Pre_Satisfy_Prepare( ctx, ctx->pcs[ 2 ] );
+        RtemsBarrierReqWait_Action( ctx );
+        RtemsBarrierReqWait_Post_Status_Check(
+          ctx,
+          RtemsBarrierReqWait_TransitionMap[ index ][ 0 ]
+        );
+        ++index;
+      }
+    }
+  }
+}
+
+/** @} */
-- 
2.26.2



More information about the devel mailing list