diff options
Diffstat (limited to 'rtemsspec')
-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 |
4 files changed, 116 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} ] );") |