[rtems-central commit] validation: Allow N/A for post-condition states

Sebastian Huber sebh at rtems.org
Wed Mar 17 17:37:29 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Mar 12 16:12:21 2021 +0100

validation: Allow N/A for post-condition states

---

 rtemsspec/tests/spec-validation/action2.yml         |  2 +-
 rtemsspec/tests/test_validation.py                  |  4 ++--
 rtemsspec/validation.py                             |  7 ++++---
 .../requirement-action-transition-post-state.yml    | 21 +++++++++++++++++++++
 spec/spec/requirement-action-transition-post.yml    |  4 ++--
 5 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/rtemsspec/tests/spec-validation/action2.yml b/rtemsspec/tests/spec-validation/action2.yml
index 7836b0d..626d8a7 100644
--- a/rtemsspec/tests/spec-validation/action2.yml
+++ b/rtemsspec/tests/spec-validation/action2.yml
@@ -162,7 +162,7 @@ transition-map:
 - enabled-by: true
   post-conditions:
     A: Y
-    B: X
+    B: N/A
   pre-conditions:
     A: N/A
     B:
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py
index 8b75fe2..b64b0cf 100644
--- a/rtemsspec/tests/test_validation.py
+++ b/rtemsspec/tests/test_validation.py
@@ -2190,7 +2190,7 @@ static const uint8_t Action2_TransitionMap[][ 2 ] = {
     Action2_Post_B_Y
   }, {
     Action2_Post_A_Y,
-    Action2_Post_B_X
+    Action2_Post_B_NA
   }, {
     Action2_Post_A_X,
     Action2_Post_B_X
@@ -2199,7 +2199,7 @@ static const uint8_t Action2_TransitionMap[][ 2 ] = {
     Action2_Post_B_Y
   }, {
     Action2_Post_A_Y,
-    Action2_Post_B_X
+    Action2_Post_B_NA
   }, {
     Action2_Post_A_NA,
     Action2_Post_B_NA
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 683656f..77450fb 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -473,8 +473,9 @@ _TransitionMap = List[List[_Transition]]
 def _state_to_index(conditions: List[Any]) -> Tuple[Dict[str, int], ...]:
     return tuple(
         dict((state["name"], index)
-             for index, state in enumerate(condition["states"]))
-        for condition in conditions)
+             for index, state in enumerate(condition["states"] + [{
+                 "name": "N/A"
+             }])) for condition in conditions)
 
 
 def _condition_index_to_enum(prefix: str,
@@ -652,7 +653,7 @@ class _ActionRequirementTestItem(_TestItem):
             else:
                 info = ["1"]
                 post_cond = tuple(
-                    len(self._post_state_to_index[index])
+                    len(self._post_state_to_index[index]) - 1
                     for index in range(self._post_condition_count))
             if isinstance(transition["pre-conditions"], dict):
                 self._add_transitions(trans_index, 0, 0, transition,
diff --git a/spec/spec/requirement-action-transition-post-state.yml b/spec/spec/requirement-action-transition-post-state.yml
new file mode 100644
index 0000000..0b31062
--- /dev/null
+++ b/spec/spec/requirement-action-transition-post-state.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: spec-member
+  uid: root
+spec-description: null
+spec-example: null
+spec-info:
+  str:
+    assert:
+      or:
+      - re: ^[A-Z][a-zA-Z0-9]+$
+      - eq: N/A
+    description: |
+      It shall be the name of a state of the corresponding post-condition or
+      ``N/A`` if the post-condition is not applicable.
+spec-name: Action Requirement Transition Post-Condition State
+spec-type: requirement-action-transition-post-state
+type: spec
diff --git a/spec/spec/requirement-action-transition-post.yml b/spec/spec/requirement-action-transition-post.yml
index 935484e..fd8b9f1 100644
--- a/spec/spec/requirement-action-transition-post.yml
+++ b/spec/spec/requirement-action-transition-post.yml
@@ -18,9 +18,9 @@ spec-info:
         There shall be exactly one generic attribute key for each
         post-condition.  The key name shall be the post-condition name.  The
         value of each generic attribute shall be the state of the
-        post-condition.
+        post-condition or ``N/A`` if the post-condition is not applicable.
       key-spec-type: requirement-action-name
-      value-spec-type: requirement-action-name
+      value-spec-type: requirement-action-transition-post-state
     mandatory-attributes: all
   str:
     assert:



More information about the vc mailing list