[rtems-central commit] validation: Add test cleanup

Sebastian Huber sebh at rtems.org
Thu Aug 20 14:13:13 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Aug  4 09:04:40 2020 +0200

validation: Add test cleanup

---

 rtemsspec/tests/spec-validation/action2.yml   | 2 ++
 rtemsspec/tests/spec-validation/directive.yml | 1 +
 rtemsspec/tests/test_validation.py            | 6 ++++++
 rtemsspec/validation.py                       | 2 ++
 spec/req/rtems/ident-local.yml                | 1 +
 spec/req/rtems/ident.yml                      | 1 +
 spec/req/rtems/tasks/ident.yml                | 1 +
 spec/spec/requirement-action.yml              | 7 +++++++
 8 files changed, 21 insertions(+)

diff --git a/rtemsspec/tests/spec-validation/action2.yml b/rtemsspec/tests/spec-validation/action2.yml
index 9a56d81..4cb5e6a 100644
--- a/rtemsspec/tests/spec-validation/action2.yml
+++ b/rtemsspec/tests/spec-validation/action2.yml
@@ -85,6 +85,8 @@ test-action: |
   /* Action */
 test-brief: |
   Test brief.
+test-cleanup: |
+  /* Cleanup */
 test-context:
 - brief: |
     Context member brief.
diff --git a/rtemsspec/tests/spec-validation/directive.yml b/rtemsspec/tests/spec-validation/directive.yml
index 47eef2e..333a47f 100644
--- a/rtemsspec/tests/spec-validation/directive.yml
+++ b/rtemsspec/tests/spec-validation/directive.yml
@@ -158,6 +158,7 @@ skip-reasons: {}
 test-action: |
   ctx->status = rtems_task_ident( ctx->name, ctx->node, ctx->id );
 test-brief: Test rtems_task_ident() brief description.
+test-cleanup: null
 test-context:
 - brief: |
     Brief context member description.
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 76b9c63..a1b3979 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -1426,6 +1426,11 @@ static void Action2_Action( Action2_Context *ctx )
   /* Action */
 }
 
+static void Action2_Cleanup( Action2_Context *ctx )
+{
+  /* Cleanup */
+}
+
 static T_fixture_node Action2_Node;
 
 void Action2_Run( int *a, int b, int *c )
@@ -1479,6 +1484,7 @@ void Action2_Run( int *a, int b, int *c )
         ctx,
         Action2_TransitionMap[ index ][ 1 ]
       );
+      Action2_Cleanup( ctx );
       ++index;
     }
   }
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 20c6911..c93ed96 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -495,6 +495,7 @@ class _TestDirectiveItem(_TestItem):
                 f"{enum[0]}_Check(", "  ctx,",
                 f"  {transition_map}[ index ][ {index} ]", ");"
             ])
+        self._add_call(content, "test-cleanup", "Cleanup")
         content.append("++index;")
 
     def _add_for_loops(self, content: CContent, index: int) -> None:
@@ -650,6 +651,7 @@ class _TestDirectiveItem(_TestItem):
         self._add_transition_map(content)
         self._add_function(content, "test-prepare", "Prepare")
         self._add_function(content, "test-action", "Action")
+        self._add_function(content, "test-cleanup", "Cleanup")
         self._add_test_case(content, header)
         content.add("/** @} */")
 
diff --git a/spec/req/rtems/ident-local.yml b/spec/req/rtems/ident-local.yml
index 5df8819..a6ef3a8 100644
--- a/spec/req/rtems/ident-local.yml
+++ b/spec/req/rtems/ident-local.yml
@@ -89,6 +89,7 @@ skip-reasons: {}
 test-action: |
   ctx->status = ( *ctx->action )( ctx->name, ctx->id );
 test-brief: null
+test-cleanup: null
 test-context:
 - brief: null
   description: null
diff --git a/spec/req/rtems/ident.yml b/spec/req/rtems/ident.yml
index b95fcef..978bd5f 100644
--- a/spec/req/rtems/ident.yml
+++ b/spec/req/rtems/ident.yml
@@ -142,6 +142,7 @@ skip-reasons: {}
 test-action: |
   ctx->status = ( *ctx->action )( ctx->name, ctx->node, ctx->id );
 test-brief: null
+test-cleanup: null
 test-context:
 - brief: null
   description: null
diff --git a/spec/req/rtems/tasks/ident.yml b/spec/req/rtems/tasks/ident.yml
index 61e26aa..c9b4c1f 100644
--- a/spec/req/rtems/tasks/ident.yml
+++ b/spec/req/rtems/tasks/ident.yml
@@ -56,6 +56,7 @@ test-action: |
     );
   }
 test-brief: null
+test-cleanup: null
 test-context:
 - brief: null
   description: null
diff --git a/spec/spec/requirement-action.yml b/spec/spec/requirement-action.yml
index aacef50..093ef67 100644
--- a/spec/spec/requirement-action.yml
+++ b/spec/spec/requirement-action.yml
@@ -85,6 +85,7 @@ spec-example: |
   test-action: |
     /* Call the function of the action */
   test-brief: null
+  test-cleanup: null
   test-context:
   - brief: null
     description: null
@@ -151,6 +152,12 @@ spec-info:
           If the value is present, then it shall be the test case brief
           description.
         spec-type: optional-str
+      test-cleanup:
+        description: |
+          If the value is present, then it shall be the test cleanup code.  The
+          code is placed in the test action loop body after the test
+          post-condition checks.
+        spec-type: optional-str
       test-context:
         description: null
         spec-type: requirement-action-test-context-list



More information about the vc mailing list