[rtems-central commit] validation: Add default for transition map entries
Sebastian Huber
sebh at rtems.org
Wed Mar 17 17:37:29 UTC 2021
Module: rtems-central
Branch: master
Commit: bcbb588fd258705968de1dac155ba81603646a60
Changeset: http://git.rtems.org/rtems-central/commit/?id=bcbb588fd258705968de1dac155ba81603646a60
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Mar 12 10:21:40 2021 +0100
validation: Add default for transition map entries
---
rtemsspec/tests/spec-validation/action2.yml | 14 +++++---------
rtemsspec/validation.py | 20 ++++++++++++++++++--
spec/spec/requirement-action-transition-pre.yml | 7 +++++++
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/rtemsspec/tests/spec-validation/action2.yml b/rtemsspec/tests/spec-validation/action2.yml
index dcb8808..7836b0d 100644
--- a/rtemsspec/tests/spec-validation/action2.yml
+++ b/rtemsspec/tests/spec-validation/action2.yml
@@ -168,19 +168,15 @@ transition-map:
B:
- Y
- enabled-by: true
- post-conditions:
- A: X
- B: X
- pre-conditions:
- A:
- - X
- B:
- - Z
-- enabled-by: true
post-conditions: SkipReason
pre-conditions:
A:
- Y
B:
- Z
+- enabled-by: true
+ post-conditions:
+ A: X
+ B: X
+ pre-conditions: default
type: requirement
diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py
index 204e7c9..c38cfad 100644
--- a/rtemsspec/validation.py
+++ b/rtemsspec/validation.py
@@ -618,6 +618,18 @@ class _ActionRequirementTestItem(_TestItem):
" " + ", ".join(pre_cond_not_applicables),
trans_index))
+ def _add_default(self, trans_index: int, transition_map: _TransitionMap,
+ pre_cond_not_applicables: List[str],
+ post_cond: Tuple[int, ...]) -> None:
+ for transition in transition_map:
+ if not transition:
+ transition.append(
+ _Transition(
+ "1", post_cond,
+ " " + ", ".join(pre_cond_not_applicables +
+ ["0"] * self._pre_condition_count),
+ trans_index))
+
def _get_transition_map(self) -> _TransitionMap:
transition_count = 1
for condition in self["pre-conditions"]:
@@ -647,8 +659,12 @@ class _ActionRequirementTestItem(_TestItem):
post_cond = tuple(
len(self._post_state_to_index[index])
for index in range(self._post_condition_count))
- self._add_transitions(trans_index, 0, 0, transition,
- transition_map, info, post_cond)
+ if isinstance(transition["pre-conditions"], dict):
+ self._add_transitions(trans_index, 0, 0, transition,
+ transition_map, info, post_cond)
+ else:
+ assert transition["pre-conditions"] == "default"
+ self._add_default(trans_index, transition_map, info, post_cond)
return transition_map
def _post_condition_enumerators(self, conditions: Any) -> str:
diff --git a/spec/spec/requirement-action-transition-pre.yml b/spec/spec/requirement-action-transition-pre.yml
index 0da85c4..c33df7a 100644
--- a/spec/spec/requirement-action-transition-pre.yml
+++ b/spec/spec/requirement-action-transition-pre.yml
@@ -22,6 +22,13 @@ spec-info:
key-spec-type: requirement-action-name
value-spec-type: requirement-action-transition-pre-states
mandatory-attributes: all
+ str:
+ assert:
+ eq: default
+ description: |
+ If this name is specified instead of explicit pre-condition states,
+ then the post-condition states of this entry are used to define all
+ remaining transitions of the map.
spec-name: Action Requirement Transition Pre-Conditions
spec-type: requirement-action-transition-pre
type: spec
More information about the vc
mailing list