[rtems-central commit] validation: Move actions to separate functions

Sebastian Huber sebh at rtems.org
Thu Feb 4 13:26:58 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Feb  4 10:51:12 2021 +0100

validation: Move actions to separate functions

---

 rtemsspec/tests/spec-validation/tc7.yml        |  30 +++++
 rtemsspec/tests/test_validation.py             | 156 ++++++++++++++++++++++---
 rtemsspec/validation.py                        |  75 ++++++------
 spec/rtems/attr/val/attr.yml                   |   6 +-
 spec/rtems/basedefs/val/basedefs.yml           |   3 +-
 spec/rtems/event/val/event-constant.yml        |  69 +++++++++--
 spec/rtems/event/val/events.yml                |   6 +-
 spec/rtems/mode/val/modes.yml                  |   4 +-
 spec/rtems/option/val/options.yml              |   4 +-
 spec/testsuites/validation/c-library.yml       |   9 +-
 spec/testsuites/validation/classic-barrier.yml |  10 +-
 11 files changed, 295 insertions(+), 77 deletions(-)

diff --git a/rtemsspec/tests/spec-validation/tc7.yml b/rtemsspec/tests/spec-validation/tc7.yml
new file mode 100644
index 0000000..bdcf1e0
--- /dev/null
+++ b/rtemsspec/tests/spec-validation/tc7.yml
@@ -0,0 +1,30 @@
+SPDX-License-Identifier: CC-BY-SA-6.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links: []
+test-actions:
+- action: |
+   /* ${step} */
+  checks: []
+  description: |
+    Action.
+  links: []
+test-brief: null
+test-context: []
+test-context-support: null
+test-description: null
+test-header:
+  code: null
+  includes: []
+  local-includes: []
+  run-params: []
+  target: tc7.h
+test-includes: []
+test-local-includes: []
+test-setup: null
+test-stop: null
+test-support: null
+test-target: tc34.c
+test-teardown: null
+type: test-case
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 93242cb..7269a0e 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -858,22 +858,35 @@ T_TEST_CASE_FIXTURE( Directive, &Directive_Fixture )
 
 /* Test case support code */
 
-/**
- * @fn void T_case_body_Tc( void )
- */
-T_TEST_CASE( Tc )
+static void Tc_Action_0( void *ctx )
 {
-  T_plan( 125 );
-
   /* Test case action 0 code */
   /* Test case action 0 check 0 code: Accounts for 123 test plan steps */
   /* Test case action 0 check 1 code; step 123 */
+}
 
+static void Tc_Action_1( void *ctx )
+{
   /* Test case action 1 code */
   /* Test case action 1 check 0 code; step 124 */
   /* Test case action 1 check 1 code */
 }
 
+/**
+ * @fn void T_case_body_Tc( void )
+ */
+T_TEST_CASE( Tc )
+{
+  void *ctx;
+
+  ctx = T_fixture_context();
+
+  T_plan( 125 );
+
+  Tc_Action_0( ctx );
+  Tc_Action_1( ctx );
+}
+
 /** @} */
 
 /**
@@ -939,18 +952,31 @@ static T_fixture Tc2_Fixture = {
   .initial_context = &Tc2_Instance
 };
 
-/**
- * @fn void T_case_body_Tc2( void )
- */
-T_TEST_CASE_FIXTURE( Tc2, &Tc2_Fixture )
+static void Tc2_Action_0( Tc2_Context *ctx )
 {
   /* Test case 2 action 0 code */
   /* Test case 2 action 0 check 0 code */
   /* Test case 2 action 0 check 1 code */
+}
 
+static void Tc2_Action_1( Tc2_Context *ctx )
+{
   /* Test case 2 action 1 code */
 }
 
+/**
+ * @fn void T_case_body_Tc2( void )
+ */
+T_TEST_CASE_FIXTURE( Tc2, &Tc2_Fixture )
+{
+  Tc2_Context *ctx;
+
+  ctx = T_fixture_context();
+
+  Tc2_Action_0( ctx );
+  Tc2_Action_1( ctx );
+}
+
 /** @} */
 """
         assert content == src.read()
@@ -965,10 +991,11 @@ T_TEST_CASE_FIXTURE( Tc2, &Tc2_Fixture )
  * @ingroup RTEMSTestCaseTc4
  * @ingroup RTEMSTestCaseTc5
  * @ingroup RTEMSTestCaseTc6
+ * @ingroup RTEMSTestCaseTc7
  */
 
 /*
- * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2020, 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
@@ -1232,15 +1259,24 @@ T_TEST_CASE_FIXTURE( Rtm, &Rtm_Fixture )
  * @{
  */
 
+static void Tc3_Action_0( void *ctx )
+{
+  /* Test case 3 action 0 code */
+  /* Test case 3 action 0 check 0 code; step 0 */
+}
+
 /**
  * @fn void T_case_body_Tc3( void )
  */
 T_TEST_CASE( Tc3 )
 {
+  void *ctx;
+
+  ctx = T_fixture_context();
+
   T_plan( 1 );
 
-  /* Test case 3 action 0 code */
-  /* Test case 3 action 0 check 0 code; step 0 */
+  Tc3_Action_0( ctx );
 }
 
 /** @} */
@@ -1262,6 +1298,9 @@ T_TEST_CASE( Tc3 )
  */
 T_TEST_CASE( Tc4 )
 {
+  void *ctx;
+
+  ctx = T_fixture_context();
 }
 
 /** @} */
@@ -1292,14 +1331,49 @@ T_TEST_CASE( Tc4 )
  * @{
  */
 
-static void Tc5_Wrap( int *a, int b, int *c )
-{
-  T_plan( 2 );
+/**
+ * @brief Test context for spec:/tc5 test case.
+ */
+typedef struct {
+  /**
+   * @brief This member contains a copy of the corresponding Tc5_Run()
+   *   parameter.
+   */
+  int *a;
+
+  /**
+   * @brief This member contains a copy of the corresponding Tc5_Run()
+   *   parameter.
+   */
+  int b;
+
+  /**
+   * @brief This member contains a copy of the corresponding Tc5_Run()
+   *   parameter.
+   */
+  int *c;
+} Tc5_Context;
+
+static Tc5_Context
+  Tc5_Instance;
 
+static T_fixture Tc5_Fixture = {
+  .setup = NULL,
+  .stop = NULL,
+  .teardown = NULL,
+  .scope = NULL,
+  .initial_context = &Tc5_Instance
+};
+
+static void Tc5_Action_0( Tc5_Context *ctx )
+{
   /* Test case action 0 code */
   /* Test case action 0 check 0 code */
   /* Test case action 0 check 1 code; step 0 */
+}
 
+static void Tc5_Action_1( Tc5_Context *ctx )
+{
   /* Test case action 1 code */
   /* Test case action 1 check 0 code; step 1 */
   /* Test case action 1 check 1 code */
@@ -1309,8 +1383,19 @@ static T_fixture_node Tc5_Node;
 
 void Tc5_Run( int *a, int b, int *c )
 {
-  T_push_fixture( &Tc5_Node, &T_empty_fixture );
-  Tc5_Wrap( a, b, c );
+  Tc5_Context *ctx;
+
+  ctx = T_push_fixture( &Tc5_Node, &Tc5_Fixture );
+
+  ctx->a = a;
+  ctx->b = b;
+  ctx->c = c;
+
+  T_plan( 2 );
+
+  Tc5_Action_0( ctx );
+  Tc5_Action_1( ctx );
+
   T_pop_fixture();
 }
 
@@ -1326,6 +1411,41 @@ void Tc5_Run( int *a, int b, int *c )
 
 void Tc6_Run( void )
 {
+  void *ctx;
+}
+
+/** @} */
+
+/**
+ * @defgroup RTEMSTestCaseTc7 spec:/tc7
+ *
+ * @ingroup RTEMSTestSuiteTs
+ *
+ * This test case performs the following actions:
+ *
+ * - Action.
+ *
+ * @{
+ */
+
+static void Tc7_Action_0( void *ctx )
+{
+  /* 0 */
+}
+
+static T_fixture_node Tc7_Node;
+
+void Tc7_Run( void )
+{
+  void *ctx;
+
+  ctx = T_push_fixture( &Tc7_Node, &T_empty_fixture );
+
+  T_plan( 1 );
+
+  Tc7_Action_0( ctx );
+
+  T_pop_fixture();
 }
 
 /** @} */
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 33724c2..ea263d8 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -188,13 +188,18 @@ class _TestItem:
                                  initial_indent="  - ",
                                  subsequent_indent="    ")
 
-    def _generate_test_case_actions(self) -> CContent:
-        content = CContent()
-        for action in self["test-actions"]:
-            content.add(self.substitute_code(action["action"]))
-            for check in action["checks"]:
-                content.append(self.substitute_text(check["check"]))
-        return content
+    def _add_test_case_actions(self, content: CContent) -> CContent:
+        actions = CContent()
+        for index, action in enumerate(self["test-actions"]):
+            method = f"{self._ident}_Action_{index}"
+            actions.gap = False
+            actions.call_function(None, method, ["ctx"])
+            params = [f"{self.context} *ctx"]
+            with content.function("static void", method, params):
+                content.add(self.substitute_code(action["action"]))
+                for check in action["checks"]:
+                    content.append(self.substitute_text(check["check"]))
+        return actions
 
     def _get_run_params(self, header: Optional[Dict[str, Any]]) -> List[str]:
         if not header:
@@ -280,11 +285,18 @@ class _TestItem:
 
     def add_default_context_members(self, content: CContent) -> None:
         """ Adds the default context members to the content """
+        for param in self._get_run_params(self["test-header"]):
+            content.add_description_block(
+                "This member contains a copy of the corresponding "
+                f"{self.ident}_Run() parameter.", None)
+            content.add(f"{param.strip()};")
 
     def add_context(self, content: CContent) -> str:
         """ Adds the context to the content. """
         content.add(self.substitute_code(self["test-context-support"]))
-        if not self["test-context"]:
+        if not self["test-context"] and (
+                not self["test-header"]
+                or not self["test-header"]["run-params"]):
             return "NULL"
         with content.doxygen_block():
             content.add_brief_description(
@@ -355,22 +367,29 @@ class _TestItem:
         """ Generates the content. """
         self.add_test_case_description(content, test_case_to_suites)
         fixture = self._add_context_and_fixture(content)
+        content.add(self.substitute_code(self["test-support"]))
         self._mapper.reset()
-        actions = self._generate_test_case_actions()
+        actions = self._add_test_case_actions(content)
         header = self["test-header"]
+        prologue = CContent()
+        prologue.add([f"{self.context} *ctx;"])
+        epilogue = CContent()
         if header:
             self.generate_header(base_directory, header)
-            if self._mapper.steps > 0 and not fixture:
-                fixture = "T_empty_fixture"
-        content.add(self.substitute_code(self["test-support"]))
-        if header:
+            ret = "void"
+            name = f"{self.ident}_Run"
             params = self._get_run_params(header)
+            if self._mapper.steps > 0 and not fixture:
+                fixture = "&T_empty_fixture"
             if fixture:
-                ret = "static void"
-                name = f"{self.ident}_Wrap"
-            else:
-                ret = "void"
-                name = f"{self.ident}_Run"
+                content.add(f"static T_fixture_node {self.ident}_Node;")
+                prologue.call_function("ctx =", "T_push_fixture",
+                                       [f"&{self.ident}_Node", fixture])
+                prologue.add([
+                    f"ctx->{param['name']} = {param['name']};"
+                    for param in header["run-params"]
+                ])
+                epilogue.add("T_pop_fixture();")
             align = True
         else:
             ret = ""
@@ -380,26 +399,18 @@ class _TestItem:
                 name = "T_TEST_CASE_FIXTURE"
             else:
                 name = "T_TEST_CASE"
+            prologue.add("ctx = T_fixture_context();")
             align = False
             with content.function_block(
                     f"void T_case_body_{self.ident}( void )"):
                 pass
             content.gap = False
         with content.function(ret, name, params, align=align):
+            content.add(prologue)
             if self._mapper.steps > 0:
                 content.add(f"T_plan( {self._mapper.steps} );")
             content.add(actions)
-        if header and fixture:
-            run = f"{self.ident}_Run"
-            content.add(f"static T_fixture_node {self.ident}_Node;")
-            with content.function("void", run, params, align=align):
-                content.call_function(None, "T_push_fixture",
-                                      [f"&{self.ident}_Node", f"&{fixture}"])
-                content.gap = False
-                content.call_function(
-                    None, name,
-                    [param["name"] for param in header["run-params"]])
-                content.append("T_pop_fixture();")
+            content.add(epilogue)
         content.add("/** @} */")
 
 
@@ -501,11 +512,7 @@ class _ActionRequirementTestItem(_TestItem):
         content.add("};")
 
     def add_default_context_members(self, content: CContent) -> None:
-        for param in self._get_run_params(self["test-header"]):
-            content.add_description_block(
-                "This member contains a copy of the corresponding "
-                f"{self.ident}_Run() parameter.", None)
-            content.add(f"{param.strip()};")
+        super().add_default_context_members(content)
         content.add_description_block(
             "This member defines the pre-condition states "
             "for the next action.", None)
diff --git a/spec/rtems/attr/val/attr.yml b/spec/rtems/attr/val/attr.yml
index 3acd56e..1e2b58a 100644
--- a/spec/rtems/attr/val/attr.yml
+++ b/spec/rtems/attr/val/attr.yml
@@ -5,8 +5,6 @@ enabled-by: true
 links: []
 test-actions:
 - action: |
-    rtems_attribute attributes;
-
     /* No action */
   checks:
   - check: |
@@ -202,6 +200,8 @@ test-actions:
     Validate the default attribute constants.
   links: []
 - action: |
+    rtems_attribute attributes;
+
     attributes = 0;
     attributes |= RTEMS_BARRIER_AUTOMATIC_RELEASE;
     attributes |= RTEMS_BINARY_SEMAPHORE;
@@ -229,6 +229,8 @@ test-actions:
     Calculate the bitwise or of all non-default attribute constants.
   links: []
 - action: |
+    rtems_attribute attributes;
+
     attributes = 0;
     attributes |= RTEMS_BINARY_SEMAPHORE;
     attributes |= RTEMS_COUNTING_SEMAPHORE;
diff --git a/spec/rtems/basedefs/val/basedefs.yml b/spec/rtems/basedefs/val/basedefs.yml
index e0844a4..797cc5e 100644
--- a/spec/rtems/basedefs/val/basedefs.yml
+++ b/spec/rtems/basedefs/val/basedefs.yml
@@ -6,6 +6,7 @@ links: []
 test-actions:
 - action: |
     int alias_result;
+
     alias_result = ori_func( 3 ) + alias_func( 5 );
   checks:
   - check: |
@@ -107,7 +108,7 @@ test-actions:
 - action: |
     char unaligned_var = 'c';
     char aligned_var RTEMS_ALIGNED( 8 ) = 'd';
-    alias_result = ori_func( 3 ) + alias_func( 5 );
+
     (void) unaligned_var;
   checks:
   - check: |
diff --git a/spec/rtems/event/val/event-constant.yml b/spec/rtems/event/val/event-constant.yml
index c181731..1b76d81 100644
--- a/spec/rtems/event/val/event-constant.yml
+++ b/spec/rtems/event/val/event-constant.yml
@@ -5,19 +5,20 @@ enabled-by: true
 links: []
 test-actions:
 - action: |
-    rtems_status_code sc;
-    rtems_event_set   out;
-
     /* No action */
   checks:
   - check: |
-      T_step_eq_u32( ${step}, event, ( (rtems_event_set) 1 ) << number );
+      T_step_eq_u32(
+        ${step},
+        ctx->event,
+        ( (rtems_event_set) 1 ) << ctx->number
+      );
     description: |
       Check that the event constant is equal to the event number bit in the
       event set.
     links: []
   - check: |
-      T_step_eq_u32( ${step}, event & RTEMS_PENDING_EVENTS, 0 );
+      T_step_eq_u32( ${step}, ctx->event & RTEMS_PENDING_EVENTS, 0 );
     description: |
       Check that the event number bit of the event constant is not set in
       RTEMS_PENDING_EVENTS.
@@ -26,6 +27,9 @@ test-actions:
     Validate the event constant.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_receive(
       RTEMS_PENDING_EVENTS,
@@ -48,6 +52,9 @@ test-actions:
     Get all pending events of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_system_receive(
       RTEMS_PENDING_EVENTS,
@@ -70,6 +77,9 @@ test-actions:
     Get all pending events of the system event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_receive(
       RTEMS_ALL_EVENTS,
@@ -92,6 +102,9 @@ test-actions:
     Receive all pending events of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_system_receive(
       RTEMS_ALL_EVENTS,
@@ -114,7 +127,9 @@ test-actions:
     Receive all pending events of the system event set of the executing task.
   links: []
 - action: |
-    sc = rtems_event_send( RTEMS_SELF, event );
+    rtems_status_code sc;
+
+    sc = rtems_event_send( RTEMS_SELF, ctx->event );
   checks:
   - check: |
       T_step_rsc_success( ${step}, sc );
@@ -125,6 +140,9 @@ test-actions:
     Send the event to the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_receive(
       RTEMS_PENDING_EVENTS,
@@ -139,7 +157,7 @@ test-actions:
       Check that the directive call was successful.
     links: []
   - check: |
-      T_step_eq_u32( ${step}, out, event );
+      T_step_eq_u32( ${step}, out, ctx->event );
     description: |
       Check that the pending event is equal to the event sent by a previous
       action.
@@ -148,6 +166,9 @@ test-actions:
     Get all pending events of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_system_receive(
       RTEMS_PENDING_EVENTS,
@@ -170,6 +191,9 @@ test-actions:
     Get all pending events of the system event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = 0;
     sc = rtems_event_receive(
       RTEMS_ALL_EVENTS,
@@ -184,7 +208,7 @@ test-actions:
       Check that the directive call was successful.
     links: []
   - check: |
-      T_step_eq_u32( ${step}, out, event );
+      T_step_eq_u32( ${step}, out, ctx->event );
     description: |
       Check that the received event is equal to the event sent by a previous
       action.
@@ -193,6 +217,9 @@ test-actions:
     Receive any event of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_system_receive(
       RTEMS_ALL_EVENTS,
@@ -215,7 +242,9 @@ test-actions:
     Receive any event of the system event set of the executing task.
   links: []
 - action: |
-    sc = rtems_event_system_send( RTEMS_SELF, event );
+    rtems_status_code sc;
+
+    sc = rtems_event_system_send( RTEMS_SELF, ctx->event );
   checks:
   - check: |
       T_step_rsc_success( ${step}, sc );
@@ -226,6 +255,9 @@ test-actions:
     Send the event to the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_receive(
       RTEMS_PENDING_EVENTS,
@@ -248,6 +280,9 @@ test-actions:
     Get all pending events of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_system_receive(
       RTEMS_PENDING_EVENTS,
@@ -262,7 +297,7 @@ test-actions:
       Check that the directive call was successful.
     links: []
   - check: |
-      T_step_eq_u32( ${step}, out, event );
+      T_step_eq_u32( ${step}, out, ctx->event );
     description: |
       Check that the pending event is equal to the event sent by a previous
       action.
@@ -271,6 +306,9 @@ test-actions:
     Get all pending events of the system event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_receive(
       RTEMS_ALL_EVENTS,
@@ -293,6 +331,9 @@ test-actions:
     Receive any event of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = 0;
     sc = rtems_event_system_receive(
       RTEMS_ALL_EVENTS,
@@ -307,7 +348,7 @@ test-actions:
       Check that the directive call was successful.
     links: []
   - check: |
-      T_step_eq_u32( ${step}, out, event );
+      T_step_eq_u32( ${step}, out, ctx->event );
     description: |
       Check that the received event is equal to the event sent by a previous
       action.
@@ -316,6 +357,9 @@ test-actions:
     Receive any event of the system event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_receive(
       RTEMS_PENDING_EVENTS,
@@ -338,6 +382,9 @@ test-actions:
     Get all pending events of the Classic event set of the executing task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_event_set   out;
+
     out = RTEMS_ALL_EVENTS;
     sc = rtems_event_system_receive(
       RTEMS_PENDING_EVENTS,
diff --git a/spec/rtems/event/val/events.yml b/spec/rtems/event/val/events.yml
index 9ab5ed9..43578af 100644
--- a/spec/rtems/event/val/events.yml
+++ b/spec/rtems/event/val/events.yml
@@ -5,8 +5,7 @@ enabled-by: true
 links: []
 test-actions:
 - action: |
-    rtems_event_set all;
-    int             i;
+    int i;
 
     for ( i = 0; i < 32; ++i ) {
       ${event-constant:/test-run}( events[ i ], i );
@@ -17,6 +16,9 @@ test-actions:
     Run the event constant and number test for all 32 event constants.
   links: []
 - action: |
+    rtems_event_set all;
+    int             i;
+
     all = 0;
 
     for ( i = 0; i < 32; ++i ) {
diff --git a/spec/rtems/mode/val/modes.yml b/spec/rtems/mode/val/modes.yml
index 2462948..e1d71a2 100644
--- a/spec/rtems/mode/val/modes.yml
+++ b/spec/rtems/mode/val/modes.yml
@@ -5,8 +5,6 @@ enabled-by: true
 links: []
 test-actions:
 - action: |
-    rtems_mode modes;
-
     /* No action */
   checks:
   - check: |
@@ -183,6 +181,8 @@ test-actions:
     Validate the task mode mask constants except RTEMS_INTERRUPT_MASK.
   links: []
 - action: |
+    rtems_mode modes;
+
     modes = 0;
     modes |= 0xff;
     modes |= RTEMS_ASR_MASK;
diff --git a/spec/rtems/option/val/options.yml b/spec/rtems/option/val/options.yml
index 82acee9..a69530e 100644
--- a/spec/rtems/option/val/options.yml
+++ b/spec/rtems/option/val/options.yml
@@ -5,8 +5,6 @@ enabled-by: true
 links: []
 test-actions:
 - action: |
-    rtems_option options;
-
     /* No action */
   checks:
   - check: |
@@ -64,6 +62,8 @@ test-actions:
     Validate the default option constants.
   links: []
 - action: |
+    rtems_option options;
+
     options = 0;
     options |= RTEMS_EVENT_ANY;
     options |= RTEMS_NO_WAIT;
diff --git a/spec/testsuites/validation/c-library.yml b/spec/testsuites/validation/c-library.yml
index bf4ae4a..4514917 100644
--- a/spec/testsuites/validation/c-library.yml
+++ b/spec/testsuites/validation/c-library.yml
@@ -6,8 +6,6 @@ links: []
 test-actions:
 - action: |
     void *p;
-    int s;
-    int d;
 
     p = aligned_alloc(128, 4);
   checks:
@@ -25,6 +23,8 @@ test-actions:
     Allocate four bytes with an alignment of 128 bytes with aligned_alloc().
   links: []
 - action: |
+    void *p;
+
     p = rtems_malloc(4);
   checks:
   - check: |
@@ -36,6 +36,8 @@ test-actions:
     Allocate four bytes with rtems_malloc().
   links: []
 - action: |
+    int d;
+
     d = 1;
     memset(&d, 0, sizeof(d));
   checks:
@@ -48,6 +50,9 @@ test-actions:
     Set an integer variable to one and then to zero with memset().
   links: []
 - action: |
+    int s;
+    int d;
+
     s = 1;
     d = 2;
     memcpy(&d, &s, sizeof(d));
diff --git a/spec/testsuites/validation/classic-barrier.yml b/spec/testsuites/validation/classic-barrier.yml
index dc76338..1471bda 100644
--- a/spec/testsuites/validation/classic-barrier.yml
+++ b/spec/testsuites/validation/classic-barrier.yml
@@ -6,8 +6,6 @@ links: []
 test-actions:
 - action: |
     rtems_status_code sc;
-    rtems_id          id;
-    TestsuitesValidationClassicBarrier_Context *ctx = T_fixture_context();
 
     ctx->id = 0xffffffff;
     sc = rtems_barrier_create(
@@ -27,6 +25,9 @@ test-actions:
     release barrier object for one task.
   links: []
 - action: |
+    rtems_status_code sc;
+    rtems_id          id;
+
     id = 0xffffffff;
     sc = rtems_barrier_ident(name, &id);
   checks:
@@ -46,7 +47,8 @@ test-actions:
     object by its name.
   links: []
 - action: |
-    uint32_t released;
+    rtems_status_code sc;
+    uint32_t          released;
 
     released = 1;
     sc = rtems_barrier_release(ctx->id, &released);
@@ -65,6 +67,8 @@ test-actions:
     Set the count of released tasks to one and release the barrier.
   links: []
 - action: |
+    rtems_status_code sc;
+
     sc = rtems_barrier_wait(ctx->id, RTEMS_NO_TIMEOUT);
   checks:
   - check: |



More information about the vc mailing list