[rtems commit] validation: Use individual names for ident tests

Sebastian Huber sebh at rtems.org
Wed Mar 30 06:54:48 UTC 2022


Module:    rtems
Branch:    master
Commit:    c2d7376f0686a663e65e03dcc3922fa2c85cb530
Changeset: http://git.rtems.org/rtems/commit/?id=c2d7376f0686a663e65e03dcc3922fa2c85cb530

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Mar 29 16:31:25 2022 +0200

validation: Use individual names for ident tests

Make the task configuration reusable.

Update #3716.

---

 spec/build/testsuites/validation/libvalidation.yml |  1 +
 testsuites/validation/tc-barrier-ident.c           |  5 +-
 testsuites/validation/tc-message-ident.c           |  5 +-
 testsuites/validation/tc-part-ident.c              |  5 +-
 testsuites/validation/tc-ratemon-ident.c           |  5 +-
 testsuites/validation/tc-sem-ident.c               |  5 +-
 testsuites/validation/tc-task-ident.c              | 27 ++--------
 testsuites/validation/tc-timer-ident.c             |  5 +-
 testsuites/validation/tc-userext-ident.c           |  5 +-
 testsuites/validation/tr-object-ident-local.c      | 10 +++-
 testsuites/validation/tr-object-ident-local.h      |  9 ++--
 testsuites/validation/tr-object-ident.c            | 10 +++-
 testsuites/validation/tr-object-ident.h            |  9 ++--
 testsuites/validation/tx-default-task-config.c     | 61 ++++++++++++++++++++++
 testsuites/validation/tx-support.h                 |  9 ++++
 15 files changed, 130 insertions(+), 41 deletions(-)

diff --git a/spec/build/testsuites/validation/libvalidation.yml b/spec/build/testsuites/validation/libvalidation.yml
index 37603f1..1ea1976 100644
--- a/spec/build/testsuites/validation/libvalidation.yml
+++ b/spec/build/testsuites/validation/libvalidation.yml
@@ -12,6 +12,7 @@ install-path: null
 links: []
 source:
 - testsuites/validation/tx-call-within-isr.c
+- testsuites/validation/tx-default-task-config.c
 - testsuites/validation/tx-interrupt.c
 - testsuites/validation/tx-io-relax.c
 - testsuites/validation/tx-memory-alloc.c
diff --git a/testsuites/validation/tc-barrier-ident.c b/testsuites/validation/tc-barrier-ident.c
index 71e7051..dcb4a1c 100644
--- a/testsuites/validation/tc-barrier-ident.c
+++ b/testsuites/validation/tc-barrier-ident.c
@@ -71,6 +71,8 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'B', 'A', 'R', 'R' )
+
 static rtems_status_code ClassicBarrierIdentAction(
   rtems_name name,
   rtems_id  *id
@@ -89,7 +91,7 @@ static void RtemsBarrierValIdent_Action_0( void )
   rtems_id          id_local_object;
 
   sc = rtems_barrier_create(
-    ClassicObjectLocalIdentName,
+    NAME_LOCAL_OBJECT,
     RTEMS_DEFAULT_ATTRIBUTES,
     1,
     &id_local_object
@@ -98,6 +100,7 @@ static void RtemsBarrierValIdent_Action_0( void )
 
   RtemsReqIdentLocal_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicBarrierIdentAction
   );
 
diff --git a/testsuites/validation/tc-message-ident.c b/testsuites/validation/tc-message-ident.c
index 74759b5..70e7d53 100644
--- a/testsuites/validation/tc-message-ident.c
+++ b/testsuites/validation/tc-message-ident.c
@@ -71,10 +71,12 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'M', 'E', 'S', 'Q' )
+
 static RTEMS_MESSAGE_QUEUE_BUFFER( 1 ) ClassicMessageIdentBuffers[ 1 ];
 
 static rtems_message_queue_config ClassicObjectIdentConfig = {
-  .name = ClassicObjectIdentName,
+  .name = NAME_LOCAL_OBJECT,
   .maximum_pending_messages = RTEMS_ARRAY_SIZE( ClassicMessageIdentBuffers ),
   .maximum_message_size = 1,
   .storage_area = ClassicMessageIdentBuffers,
@@ -108,6 +110,7 @@ static void RtemsMessageValIdent_Action_0( void )
 
   RtemsReqIdent_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicMessageIdentAction
   );
 
diff --git a/testsuites/validation/tc-part-ident.c b/testsuites/validation/tc-part-ident.c
index 926c205..fccdf96 100644
--- a/testsuites/validation/tc-part-ident.c
+++ b/testsuites/validation/tc-part-ident.c
@@ -71,6 +71,8 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'P', 'A', 'R', 'T' )
+
 static rtems_status_code ClassicPartIdentAction(
   rtems_name name,
   uint32_t   node,
@@ -91,7 +93,7 @@ static void RtemsPartValIdent_Action_0( void )
   rtems_id                                               id_local_object;
 
   sc = rtems_partition_create(
-    ClassicObjectIdentName,
+    NAME_LOCAL_OBJECT,
     area,
     sizeof( area ),
     sizeof( area ),
@@ -102,6 +104,7 @@ static void RtemsPartValIdent_Action_0( void )
 
   RtemsReqIdent_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicPartIdentAction
   );
 
diff --git a/testsuites/validation/tc-ratemon-ident.c b/testsuites/validation/tc-ratemon-ident.c
index 1126fca..beeb0bf 100644
--- a/testsuites/validation/tc-ratemon-ident.c
+++ b/testsuites/validation/tc-ratemon-ident.c
@@ -71,6 +71,8 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'R', 'A', 'T', 'E' )
+
 static rtems_status_code ClassicRatemonIdentAction(
   rtems_name name,
   rtems_id  *id
@@ -89,13 +91,14 @@ static void RtemsRatemonValIdent_Action_0( void )
   rtems_id          id_local_object;
 
   sc = rtems_rate_monotonic_create(
-    ClassicObjectLocalIdentName,
+    NAME_LOCAL_OBJECT,
     &id_local_object
   );
   T_assert_rsc_success( sc );
 
   RtemsReqIdentLocal_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicRatemonIdentAction
   );
 
diff --git a/testsuites/validation/tc-sem-ident.c b/testsuites/validation/tc-sem-ident.c
index 183680f..3014113 100644
--- a/testsuites/validation/tc-sem-ident.c
+++ b/testsuites/validation/tc-sem-ident.c
@@ -71,6 +71,8 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'S', 'E', 'M', 'A' )
+
 static rtems_status_code ClassicSemIdentAction(
   rtems_name name,
   uint32_t   node,
@@ -90,7 +92,7 @@ static void RtemsSemValIdent_Action_0( void )
   rtems_id          id_local_object;
 
   sc = rtems_semaphore_create(
-    ClassicObjectIdentName,
+    NAME_LOCAL_OBJECT,
     0,
     RTEMS_DEFAULT_ATTRIBUTES,
     0,
@@ -100,6 +102,7 @@ static void RtemsSemValIdent_Action_0( void )
 
   RtemsReqIdent_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicSemIdentAction
   );
 
diff --git a/testsuites/validation/tc-task-ident.c b/testsuites/validation/tc-task-ident.c
index a61b903..c4247f2 100644
--- a/testsuites/validation/tc-task-ident.c
+++ b/testsuites/validation/tc-task-ident.c
@@ -53,7 +53,7 @@
 #endif
 
 #include "tr-object-ident.h"
-#include "ts-config.h"
+#include "tx-support.h"
 
 #include <rtems/test.h>
 
@@ -147,28 +147,6 @@ static rtems_status_code ClassicTaskIdentAction(
   return rtems_task_ident( name, node, id );
 }
 
-#define TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
-
-#define MAX_TLS_SIZE RTEMS_ALIGN_UP( 64, RTEMS_TASK_STORAGE_ALIGNMENT )
-
-RTEMS_ALIGNED( RTEMS_TASK_STORAGE_ALIGNMENT )
-static char ClassicTaskIdentStorage[
-  RTEMS_TASK_STORAGE_SIZE(
-    MAX_TLS_SIZE + TEST_MINIMUM_STACK_SIZE,
-    TASK_ATTRIBUTES
-  )
-];
-
-static const rtems_task_config ClassicTaskIdentConfig = {
-  .name = ClassicObjectIdentName,
-  .initial_priority = 1,
-  .storage_area = ClassicTaskIdentStorage,
-  .storage_size = sizeof( ClassicTaskIdentStorage ),
-  .maximum_thread_local_storage_size = MAX_TLS_SIZE,
-  .initial_modes = RTEMS_DEFAULT_MODES,
-  .attributes = TASK_ATTRIBUTES
-};
-
 static void RtemsTaskReqIdent_Pre_Name_Prepare(
   RtemsTaskReqIdent_Context *ctx,
   RtemsTaskReqIdent_Pre_Name state
@@ -237,7 +215,7 @@ static void RtemsTaskReqIdent_Setup( RtemsTaskReqIdent_Context *ctx )
   rtems_status_code sc;
 
   sc = rtems_task_construct(
-    &ClassicTaskIdentConfig,
+    &DefaultTaskConfig,
     &ctx->id_local_object
   );
   T_assert_rsc_success( sc );
@@ -278,6 +256,7 @@ static void RtemsTaskReqIdent_Action( RtemsTaskReqIdent_Context *ctx )
   } else {
     RtemsReqIdent_Run(
       ctx->id_local_object,
+      DefaultTaskConfig.name,
       ClassicTaskIdentAction
     );
   }
diff --git a/testsuites/validation/tc-timer-ident.c b/testsuites/validation/tc-timer-ident.c
index 5f121fc..bdee3d8 100644
--- a/testsuites/validation/tc-timer-ident.c
+++ b/testsuites/validation/tc-timer-ident.c
@@ -71,6 +71,8 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'T', 'I', 'M', 'R' )
+
 static rtems_status_code ClassicTimerIdentAction(
   rtems_name name,
   rtems_id  *id
@@ -89,13 +91,14 @@ static void RtemsTimerValIdent_Action_0( void )
   rtems_id          id_local_object;
 
   sc = rtems_timer_create(
-    ClassicObjectLocalIdentName,
+    NAME_LOCAL_OBJECT,
     &id_local_object
   );
   T_assert_rsc_success( sc );
 
   RtemsReqIdentLocal_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicTimerIdentAction
   );
 
diff --git a/testsuites/validation/tc-userext-ident.c b/testsuites/validation/tc-userext-ident.c
index d2adcb3..2ece528 100644
--- a/testsuites/validation/tc-userext-ident.c
+++ b/testsuites/validation/tc-userext-ident.c
@@ -71,6 +71,8 @@
  * @{
  */
 
+#define NAME_LOCAL_OBJECT rtems_build_name( 'U', 'E', 'X', 'T' )
+
 static rtems_status_code ClassicUserExtIdentAction(
   rtems_name name,
   rtems_id  *id
@@ -90,7 +92,7 @@ static void RtemsUserextValIdent_Action_0( void )
   rtems_id                            id_local_object;
 
   sc = rtems_extension_create(
-    ClassicObjectLocalIdentName,
+    NAME_LOCAL_OBJECT,
     &table,
     &id_local_object
   );
@@ -98,6 +100,7 @@ static void RtemsUserextValIdent_Action_0( void )
 
   RtemsReqIdentLocal_Run(
     id_local_object,
+    NAME_LOCAL_OBJECT,
     ClassicUserExtIdentAction
   );
 
diff --git a/testsuites/validation/tr-object-ident-local.c b/testsuites/validation/tr-object-ident-local.c
index 5ca8c08..1b3943f 100644
--- a/testsuites/validation/tr-object-ident-local.c
+++ b/testsuites/validation/tr-object-ident-local.c
@@ -94,6 +94,12 @@ typedef struct {
    * @brief This member contains a copy of the corresponding
    *   RtemsReqIdentLocal_Run() parameter.
    */
+  rtems_name name_local_object;
+
+  /**
+   * @brief This member contains a copy of the corresponding
+   *   RtemsReqIdentLocal_Run() parameter.
+   */
   rtems_status_code ( *action )( rtems_name, rtems_id * );
 
   struct {
@@ -166,7 +172,7 @@ static void RtemsReqIdentLocal_Pre_Name_Prepare(
        * While the ``name`` parameter is associated with an active object of
        * the specified class .
        */
-      ctx->name = ClassicObjectLocalIdentName;
+      ctx->name = ctx->name_local_object;
       break;
     }
 
@@ -346,6 +352,7 @@ static T_fixture_node RtemsReqIdentLocal_Node;
 
 void RtemsReqIdentLocal_Run(
   rtems_id             id_local_object,
+  rtems_name           name_local_object,
   rtems_status_code ( *action )( rtems_name, rtems_id * )
 )
 {
@@ -353,6 +360,7 @@ void RtemsReqIdentLocal_Run(
 
   ctx = &RtemsReqIdentLocal_Instance;
   ctx->id_local_object = id_local_object;
+  ctx->name_local_object = name_local_object;
   ctx->action = action;
 
   ctx = T_push_fixture( &RtemsReqIdentLocal_Node, &RtemsReqIdentLocal_Fixture );
diff --git a/testsuites/validation/tr-object-ident-local.h b/testsuites/validation/tr-object-ident-local.h
index 13f6a09..83ad7e7 100644
--- a/testsuites/validation/tr-object-ident-local.h
+++ b/testsuites/validation/tr-object-ident-local.h
@@ -89,19 +89,20 @@ typedef enum {
   RtemsReqIdentLocal_Post_Id_NA
 } RtemsReqIdentLocal_Post_Id;
 
-#define ClassicObjectLocalIdentName \
-  rtems_build_name( 'I', 'D', 'N', 'T' )
-
 /**
  * @brief Runs the parameterized test case.
  *
  * @param id_local_object is the identifier of an active object of the class
- *   under test with the name ClassicObjectLocalIdentName.
+ *   under test.
+ *
+ * @param name_local_object is the name of the active object of the class under
+ *   test.
  *
  * @param action is the action handler.
  */
 void RtemsReqIdentLocal_Run(
   rtems_id             id_local_object,
+  rtems_name           name_local_object,
   rtems_status_code ( *action )( rtems_name, rtems_id * )
 );
 
diff --git a/testsuites/validation/tr-object-ident.c b/testsuites/validation/tr-object-ident.c
index fac8767..438c1f3 100644
--- a/testsuites/validation/tr-object-ident.c
+++ b/testsuites/validation/tr-object-ident.c
@@ -99,6 +99,12 @@ typedef struct {
    * @brief This member contains a copy of the corresponding
    *   RtemsReqIdent_Run() parameter.
    */
+  rtems_name name_local_object;
+
+  /**
+   * @brief This member contains a copy of the corresponding
+   *   RtemsReqIdent_Run() parameter.
+   */
   rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * );
 
   struct {
@@ -182,7 +188,7 @@ static void RtemsReqIdent_Pre_Name_Prepare(
        * While the ``name`` parameter is associated with an active object of
        * the specified class .
        */
-      ctx->name = ClassicObjectIdentName;
+      ctx->name = ctx->name_local_object;
       break;
     }
 
@@ -450,6 +456,7 @@ static T_fixture_node RtemsReqIdent_Node;
 
 void RtemsReqIdent_Run(
   rtems_id             id_local_object,
+  rtems_name           name_local_object,
   rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * )
 )
 {
@@ -457,6 +464,7 @@ void RtemsReqIdent_Run(
 
   ctx = &RtemsReqIdent_Instance;
   ctx->id_local_object = id_local_object;
+  ctx->name_local_object = name_local_object;
   ctx->action = action;
 
   ctx = T_push_fixture( &RtemsReqIdent_Node, &RtemsReqIdent_Fixture );
diff --git a/testsuites/validation/tr-object-ident.h b/testsuites/validation/tr-object-ident.h
index 2404665..7917562 100644
--- a/testsuites/validation/tr-object-ident.h
+++ b/testsuites/validation/tr-object-ident.h
@@ -101,19 +101,20 @@ typedef enum {
   RtemsReqIdent_Post_Id_NA
 } RtemsReqIdent_Post_Id;
 
-#define ClassicObjectIdentName \
-  rtems_build_name( 'I', 'D', 'N', 'T' )
-
 /**
  * @brief Runs the parameterized test case.
  *
  * @param id_local_object is the identifier of an active object of the class
- *   under test with the name ClassicObjectIdentName.
+ *   under test.
+ *
+ * @param name_local_object is the name of the active object of the class under
+ *   test.
  *
  * @param action is the action handler.
  */
 void RtemsReqIdent_Run(
   rtems_id             id_local_object,
+  rtems_name           name_local_object,
   rtems_status_code ( *action )( rtems_name, uint32_t, rtems_id * )
 );
 
diff --git a/testsuites/validation/tx-default-task-config.c b/testsuites/validation/tx-default-task-config.c
new file mode 100644
index 0000000..59a0fd0
--- /dev/null
+++ b/testsuites/validation/tx-default-task-config.c
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestSuites
+ *
+ * @brief This source file contains the definition of ::DefaultTaskConfig.
+ */
+
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tx-support.h"
+#include "ts-config.h"
+
+#define TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
+
+RTEMS_ALIGNED( RTEMS_TASK_STORAGE_ALIGNMENT )
+static char DefaultTaskStorage[
+  RTEMS_TASK_STORAGE_SIZE(
+    TEST_MAXIMUM_TLS_SIZE + TEST_MINIMUM_STACK_SIZE,
+    TASK_ATTRIBUTES
+  )
+];
+
+const rtems_task_config DefaultTaskConfig = {
+  .name = rtems_build_name( 'D', 'T', 'S', 'K' ),
+  .initial_priority = 1,
+  .storage_area = DefaultTaskStorage,
+  .storage_size = sizeof( DefaultTaskStorage ),
+  .maximum_thread_local_storage_size = TEST_MAXIMUM_TLS_SIZE,
+  .initial_modes = RTEMS_DEFAULT_MODES,
+  .attributes = TASK_ATTRIBUTES
+};
diff --git a/testsuites/validation/tx-support.h b/testsuites/validation/tx-support.h
index b647551..592067c 100644
--- a/testsuites/validation/tx-support.h
+++ b/testsuites/validation/tx-support.h
@@ -590,6 +590,15 @@ static inline void ISRLockWaitForOthers(
 
 void *IdleBody( uintptr_t ignored );
 
+/**
+ * @brief This task configurations may be used to construct a task during
+ *   tests.
+ *
+ * Only one task shall use this configuration at a time, otherwise two tasks
+ * would share a stack.
+ */
+extern const rtems_task_config DefaultTaskConfig;
+
 /** @} */
 
 #ifdef __cplusplus



More information about the vc mailing list