diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-07-27 14:54:13 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-07-27 15:29:32 +0200 |
commit | 55e17d23c133681cf4a6a24e5190216f5378f1e8 (patch) | |
tree | b836b35f5fee7732c18fc125fba07a3c80671e53 | |
parent | validation: Support N/A in the action transitions (diff) | |
download | rtems-central-55e17d23c133681cf4a6a24e5190216f5378f1e8.tar.bz2 |
validation: Add ability to skip action transitions
-rw-r--r-- | rtemsspec/tests/spec-validation/action2.yml | 24 | ||||
-rw-r--r-- | rtemsspec/tests/spec-validation/directive.yml | 1 | ||||
-rw-r--r-- | rtemsspec/tests/test_validation.py | 115 | ||||
-rw-r--r-- | rtemsspec/validation.py | 24 | ||||
-rw-r--r-- | spec/req/rtems/ident-local.yml | 1 | ||||
-rw-r--r-- | spec/req/rtems/ident.yml | 1 | ||||
-rw-r--r-- | spec/req/rtems/tasks/ident.yml | 1 | ||||
-rw-r--r-- | spec/spec/requirement-action-skip-reasons.yml | 27 | ||||
-rw-r--r-- | spec/spec/requirement-action-transition-post.yml | 10 | ||||
-rw-r--r-- | spec/spec/requirement-action.yml | 4 |
10 files changed, 160 insertions, 48 deletions
diff --git a/rtemsspec/tests/spec-validation/action2.yml b/rtemsspec/tests/spec-validation/action2.yml index a2a23345..a2b852eb 100644 --- a/rtemsspec/tests/spec-validation/action2.yml +++ b/rtemsspec/tests/spec-validation/action2.yml @@ -66,11 +66,19 @@ pre-conditions: /* Pre B Y */ text: | Pre B Y. + - name: Z + test-code: | + /* Pre B Z */ + text: | + Pre B Z. test-epilogue: | /* Pre B epilogue. */ test-prologue: | /* Pre B prologue. */ requirement-type: functional +skip-reasons: + SkipReason: | + Skip it due to some reason. test-action: | /* Action */ test-brief: | @@ -148,6 +156,22 @@ transition-map: A: N/A 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 rationale: null references: [] text: | diff --git a/rtemsspec/tests/spec-validation/directive.yml b/rtemsspec/tests/spec-validation/directive.yml index e8842fe3..2c8c20fe 100644 --- a/rtemsspec/tests/spec-validation/directive.yml +++ b/rtemsspec/tests/spec-validation/directive.yml @@ -152,6 +152,7 @@ pre-conditions: test-epilogue: null test-prologue: null requirement-type: functional +skip-reasons: {} test-action: | ctx->status = rtems_task_ident( ctx->name, ctx->node, ctx->id ); test-brief: Test rtems_task_ident() brief description. diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py index c9c4a9d1..459f7cc0 100644 --- a/rtemsspec/tests/test_validation.py +++ b/rtemsspec/tests/test_validation.py @@ -635,90 +635,91 @@ static const uint8_t ClassicTaskIdentification_TransitionMap[][ 2 ] = { }; static const struct { + uint8_t Skip : 1; uint8_t Pre_Name_NA : 1; uint8_t Pre_Node_NA : 1; uint8_t Pre_Id_NA : 1; } ClassicTaskIdentification_TransitionInfo[] = { { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { #if defined(RTEMS_MULTIPROCESSING) - 0, 0, 0 + 0, 0, 0, 0 #else - 0, 0, 0 + 0, 0, 0, 0 #endif }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 }, { #if defined(RTEMS_MULTIPROCESSING) - 0, 0, 0 + 0, 0, 0, 0 #else - 0, 0, 0 + 0, 0, 0, 0 #endif }, { - 0, 0, 0 + 0, 0, 0, 0 }, { - 0, 0, 0 + 0, 0, 0, 0 } }; @@ -774,6 +775,11 @@ T_TEST_CASE_FIXTURE( index += ( ClassicTaskIdentification_Pre_Id_NA - 1 ); } + if ( ClassicTaskIdentification_TransitionInfo[ index ].Skip ) { + ++index; + continue; + } + ClassicTaskIdentification_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] ); ClassicTaskIdentification_Pre_Node_Prepare( ctx, ctx->pcs[ 1 ] ); ClassicTaskIdentification_Pre_Id_Prepare( ctx, ctx->pcs[ 2 ] ); @@ -1049,6 +1055,7 @@ typedef enum { typedef enum { Action2_Pre_B_X, Action2_Pre_B_Y, + Action2_Pre_B_Z, Action2_Pre_B_NA } Action2_Pre_B; @@ -1193,7 +1200,8 @@ static const char * const Action2_PreDesc_A[] = { static const char * const Action2_PreDesc_B[] = { "X", - "Y" + "Y", + "Z" }; static const char * const * const Action2_PreDesc[] = { @@ -1241,6 +1249,11 @@ static void Action2_Pre_B_Prepare( Action2_Context *ctx, Action2_Pre_B state ) break; } + case Action2_Pre_B_Z: { + /* Pre B Z */ + break; + } + case Action2_Pre_B_NA: break; } @@ -1358,25 +1371,36 @@ static const uint8_t Action2_TransitionMap[][ 2 ] = { Action2_Post_B_X }, { Action2_Post_A_X, + Action2_Post_B_X + }, { + Action2_Post_A_X, Action2_Post_B_Y }, { Action2_Post_A_Y, Action2_Post_B_X + }, { + Action2_Post_A_Y, + Action2_Post_B_Y } }; static const struct { + uint8_t Skip : 1; uint8_t Pre_A_NA : 1; uint8_t Pre_B_NA : 1; } Action2_TransitionInfo[] = { { - 0, 0 + 0, 0, 0 }, { - 1, 0 + 0, 1, 0 }, { - 0, 0 + 0, 0, 0 + }, { + 0, 0, 0 + }, { + 0, 1, 0 }, { - 1, 0 + 1, 0, 0 } }; @@ -1416,6 +1440,11 @@ void Action2_Run( int *a, int b, int *c ) index += ( Action2_Pre_B_NA - 1 ); } + if ( Action2_TransitionInfo[ index ].Skip ) { + ++index; + continue; + } + Action2_Pre_A_Prepare( ctx, ctx->pcs[ 0 ] ); Action2_Pre_B_Prepare( ctx, ctx->pcs[ 1 ] ); /* Action */ diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py index f914143c..8dddec91 100644 --- a/rtemsspec/validation.py +++ b/rtemsspec/validation.py @@ -398,10 +398,20 @@ class _TestDirectiveItem(_TestItem): transition_map = [list() for _ in range(transition_count) ] # type: _TransitionMap for transition in self["transition-map"]: - post = tuple(self._post_state_to_index[index][ - transition["post-conditions"][self._post_index_to_name[index]]] - for index in range(self._post_condition_count)) - self._add_transitions(0, 0, transition, transition_map, [], post) + if isinstance(transition["post-conditions"], dict): + info = ["0"] + post_cond = tuple( + self._post_state_to_index[index][ + transition["post-conditions"][ + self._post_index_to_name[index]]] + for index in range(self._post_condition_count)) + else: + info = ["1"] + post_cond = tuple( + len(self._post_state_to_index[index]) - 1 + for index in range(self._post_condition_count)) + self._add_transitions(0, 0, transition, transition_map, info, + post_cond) return transition_map def _post_condition_enumerators(self, conditions: Any) -> str: @@ -448,9 +458,11 @@ class _TestDirectiveItem(_TestItem): map_elements.append("\n".join(map_enumerators)) info_elements.append("\n".join(info_enumerators)) content.append(["\n }, {\n".join(map_elements), " }", "};"]) - pre_bits = 2**max(math.ceil(math.log2(self._pre_condition_count)), 3) + pre_bits = 2**max(math.ceil(math.log2(self._pre_condition_count + 1)), + 3) content.add("static const struct {") with content.indent(): + content.append(f"uint{pre_bits}_t Skip : 1;") for condition in self["pre-conditions"]: content.append( f"uint{pre_bits}_t Pre_{condition['name']}_NA : 1;") @@ -458,6 +470,8 @@ class _TestDirectiveItem(_TestItem): content.append(["\n }, {\n".join(info_elements), " }", "};"]) def _add_action(self, content: CContent) -> None: + with content.condition(f"{self.ident}_TransitionInfo[ index ].Skip"): + content.append(["++index;", "continue;"]) content.add_blank_line() for index, enum in enumerate(self._pre_index_to_enum): content.append(f"{enum[0]}_Prepare( ctx, ctx->pcs[ {index} ] );") diff --git a/spec/req/rtems/ident-local.yml b/spec/req/rtems/ident-local.yml index 38bf9cdd..9bb542f9 100644 --- a/spec/req/rtems/ident-local.yml +++ b/spec/req/rtems/ident-local.yml @@ -83,6 +83,7 @@ pre-conditions: test-epilogue: null test-prologue: null requirement-type: functional +skip-reasons: {} test-action: | ctx->status = ( *ctx->action )( ctx->name, ctx->id ); test-brief: null diff --git a/spec/req/rtems/ident.yml b/spec/req/rtems/ident.yml index b56603bd..1a9bbfbc 100644 --- a/spec/req/rtems/ident.yml +++ b/spec/req/rtems/ident.yml @@ -136,6 +136,7 @@ pre-conditions: test-epilogue: null test-prologue: null requirement-type: functional +skip-reasons: {} test-action: | ctx->status = ( *ctx->action )( ctx->name, ctx->node, ctx->id ); test-brief: null diff --git a/spec/req/rtems/tasks/ident.yml b/spec/req/rtems/tasks/ident.yml index 0a8171df..3d2d6873 100644 --- a/spec/req/rtems/tasks/ident.yml +++ b/spec/req/rtems/tasks/ident.yml @@ -43,6 +43,7 @@ pre-conditions: test-epilogue: null test-prologue: null requirement-type: functional +skip-reasons: {} test-action: | if ( ctx->id != NULL ) { ctx->status = rtems_task_ident( RTEMS_SELF, 0xdeadbeef, ctx->id ); diff --git a/spec/spec/requirement-action-skip-reasons.yml b/spec/spec/requirement-action-skip-reasons.yml new file mode 100644 index 00000000..75be7ede --- /dev/null +++ b/spec/spec/requirement-action-skip-reasons.yml @@ -0,0 +1,27 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2020 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: + dict: + attributes: {} + description: | + This set of attributes specifies skip reasons used to justify why + transitions in the transition map are skipped. + generic-attributes: + description: | + The key defines the name of a skip reason. The name can be used in + :ref:`SpecTypeActionRequirementTransitionPostConditions` to skip the + corresponding transitions. The value shall give a reason why the + transitions are skipped. + key-spec-type: requirement-action-name + value-spec-type: str + mandatory-attributes: all +spec-name: Action Requirement Skip Reasons +spec-type: requirement-action-skip-reasons +type: spec diff --git a/spec/spec/requirement-action-transition-post.yml b/spec/spec/requirement-action-transition-post.yml index 7fca2f11..935484e3 100644 --- a/spec/spec/requirement-action-transition-post.yml +++ b/spec/spec/requirement-action-transition-post.yml @@ -22,6 +22,16 @@ spec-info: key-spec-type: requirement-action-name value-spec-type: requirement-action-name mandatory-attributes: all + str: + assert: + and: + - re: ^[A-Z][a-zA-Z0-9]+$ + - not: + eq: NA + description: | + It shall be the name of a skip reason. If a skip reason is given instead + of a listing of post-condition states, then this transition is skipped + and no test code runs for this transition. spec-name: Action Requirement Transition Post-Conditions spec-type: requirement-action-transition-post type: spec diff --git a/spec/spec/requirement-action.yml b/spec/spec/requirement-action.yml index 8eb7b7be..6afa7879 100644 --- a/spec/spec/requirement-action.yml +++ b/spec/spec/requirement-action.yml @@ -81,6 +81,7 @@ spec-example: | test-epilogue: null test-prologue: null requirement-type: functional + skip-reasons: {} test-action: | /* Call the function of the action */ test-brief: null @@ -137,6 +138,9 @@ spec-info: pre-conditions: description: null spec-type: requirement-action-condition-list + skip-reasons: + description: null + spec-type: requirement-action-skip-reasons test-action: description: | It shall be the test action code. |