diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-14 08:57:04 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-19 11:29:34 +0200 |
commit | 48d7a6858582560f763a51ed2ddb48fbeb079573 (patch) | |
tree | 8540ba8ec2220a2afafaa2f74bd605a41b4659b9 /rtemsspec | |
parent | spec: Add test header to test case item type (diff) | |
download | rtems-central-48d7a6858582560f763a51ed2ddb48fbeb079573.tar.bz2 |
spec: Unify test attribute keys
Diffstat (limited to 'rtemsspec')
-rw-r--r-- | rtemsspec/tests/spec-validation/tc.yml | 30 | ||||
-rw-r--r-- | rtemsspec/tests/spec-validation/tc2.yml | 30 | ||||
-rw-r--r-- | rtemsspec/tests/spec-validation/tc3.yml | 30 | ||||
-rw-r--r-- | rtemsspec/tests/spec-validation/tc4.yml | 22 | ||||
-rw-r--r-- | rtemsspec/tests/spec-validation/ts.yml | 11 | ||||
-rw-r--r-- | rtemsspec/validation.py | 54 |
6 files changed, 91 insertions, 86 deletions
diff --git a/rtemsspec/tests/spec-validation/tc.yml b/rtemsspec/tests/spec-validation/tc.yml index 682ac541..c6ff4862 100644 --- a/rtemsspec/tests/spec-validation/tc.yml +++ b/rtemsspec/tests/spec-validation/tc.yml @@ -1,5 +1,9 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: +copyrights: +- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: [] +test-actions: - action: | /* Test case action 0 code */ checks: @@ -32,23 +36,19 @@ actions: description: | Test case action 1 description. links: [] -brief: Test case brief description. -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -description: Test case description. -enabled-by: true -epilogue: | +test-brief: Test case brief description. +test-description: Test case description. +test-epilogue: | /* Test case epilogue code */ -fixture: null -includes: +test-fixture: null +test-header: null +test-includes: - a.h -links: [] -local-includes: +test-local-includes: - x.h -prologue: | +test-prologue: | /* Test case prologue code */ -support: | +test-support: | /* Test case support code */ -target: tc12.c -test-header: null +test-target: tc12.c type: test-case diff --git a/rtemsspec/tests/spec-validation/tc2.yml b/rtemsspec/tests/spec-validation/tc2.yml index 90be0eed..bbf884a3 100644 --- a/rtemsspec/tests/spec-validation/tc2.yml +++ b/rtemsspec/tests/spec-validation/tc2.yml @@ -1,5 +1,9 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: +copyrights: +- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: [] +test-actions: - action: | /* Test case 2 action 0 code */ checks: @@ -22,20 +26,16 @@ actions: description: | Test case 2 action 1 description. links: [] -brief: Test case 2 brief description. -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -description: Test case 2 description. -enabled-by: true -epilogue: null -fixture: test_case_2_fixture -includes: +test-brief: Test case 2 brief description. +test-description: Test case 2 description. +test-epilogue: null +test-fixture: test_case_2_fixture +test-header: null +test-includes: - b.h -links: [] -local-includes: +test-local-includes: - y.h -prologue: null -support: null -target: tc12.c -test-header: null +test-prologue: null +test-support: null +test-target: tc12.c type: test-case diff --git a/rtemsspec/tests/spec-validation/tc3.yml b/rtemsspec/tests/spec-validation/tc3.yml index e16a9329..8a51a180 100644 --- a/rtemsspec/tests/spec-validation/tc3.yml +++ b/rtemsspec/tests/spec-validation/tc3.yml @@ -1,5 +1,9 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: +copyrights: +- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: [] +test-actions: - action: | /* Test case 3 action 0 code */ checks: @@ -11,20 +15,16 @@ actions: description: | Test case 3 action 0 description. links: [] -brief: Test case 3 brief description. -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -description: Test case 3 description. -enabled-by: true -epilogue: null -fixture: null -includes: +test-brief: Test case 3 brief description. +test-description: Test case 3 description. +test-epilogue: null +test-fixture: null +test-header: null +test-includes: - c.h -links: [] -local-includes: +test-local-includes: - z.h -prologue: null -support: null -target: tc34.c -test-header: null +test-prologue: null +test-support: null +test-target: tc34.c type: test-case diff --git a/rtemsspec/tests/spec-validation/tc4.yml b/rtemsspec/tests/spec-validation/tc4.yml index 59ecaf8f..c05bfd30 100644 --- a/rtemsspec/tests/spec-validation/tc4.yml +++ b/rtemsspec/tests/spec-validation/tc4.yml @@ -1,18 +1,18 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: [] -brief: Test case 4 brief description. copyrights: - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -description: Test case 4 description. enabled-by: true -epilogue: | - /* Test case 4 epilogue code */ -fixture: null -includes: [] links: [] -local-includes: [] -prologue: null -support: null -target: tc34.c +test-actions: [] +test-brief: Test case 4 brief description. +test-description: Test case 4 description. +test-epilogue: | + /* Test case 4 epilogue code */ +test-fixture: null test-header: null +test-includes: [] +test-local-includes: [] +test-prologue: null +test-support: null +test-target: tc34.c type: test-case diff --git a/rtemsspec/tests/spec-validation/ts.yml b/rtemsspec/tests/spec-validation/ts.yml index 321a4721..ee89c4fc 100644 --- a/rtemsspec/tests/spec-validation/ts.yml +++ b/rtemsspec/tests/spec-validation/ts.yml @@ -5,10 +5,13 @@ copyrights: - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) description: The Blue Green description. enabled-by: true -includes: -- blue.h links: [] -local-includes: +test-code: | + /* Blue green code */ +test-description: The Blue Green description. +test-includes: +- blue.h +test-local-includes: - green.h -target: ts.c +test-target: ts.c type: test-suite diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py index 0ababc12..3e557020 100644 --- a/rtemsspec/validation.py +++ b/rtemsspec/validation.py @@ -103,12 +103,22 @@ class _TestItem: @property def includes(self) -> List[str]: """ Returns the list of includes. """ - return self._item["includes"] + return self._item["test-includes"] @property def local_includes(self) -> List[str]: """ Returns the list of local includes. """ - return self._item["local-includes"] + return self._item["test-local-includes"] + + @property + def brief(self) -> str: + """ Returns the substituted brief description. """ + return self.substitute_text(self["test-brief"]) + + @property + def description(self) -> str: + """ Returns the substituted description. """ + return self.substitute_text(self["test-description"]) @property def group_identifier(self) -> str: @@ -138,7 +148,7 @@ class _TestItem: content.add(["@brief Test Case", "", "@{"]) def _add_test_case_action_description(self, content: CContent) -> None: - actions = self["actions"] + actions = self["test-actions"] if actions: content.add("This test case performs the following actions:") for action in actions: @@ -151,7 +161,7 @@ class _TestItem: def _generate_test_case_actions(self) -> CContent: content = CContent() - for action in self["actions"]: + for action in self["test-actions"]: content.add(self.substitute_code(action["action"])) for check in action["checks"]: content.append(self.substitute_text(check["check"])) @@ -161,27 +171,27 @@ class _TestItem: test_case_to_suites: Dict[str, List["_TestItem"]]) -> None: """ Generates the content. """ self.add_test_case_description(content, test_case_to_suites) - content.add(self.substitute_code(self["support"])) + content.add(self.substitute_code(self["test-support"])) with content.function_block(f"void T_case_body_{self.ident}( void )"): - content.add_brief_description(self.substitute_text(self["brief"])) - content.wrap(self.substitute_text(self["description"])) + content.add_brief_description(self.brief) + content.wrap(self.description) self._add_test_case_action_description(content) content.gap = False params = [f"{self.ident}"] - fixture = self["fixture"] + fixture = self["test-fixture"] if fixture: params.append(f"&{fixture}") name = "T_TEST_CASE_FIXTURE" else: name = "T_TEST_CASE" with content.function("", name, params): - content.add(self.substitute_code(self["prologue"])) + content.add(self.substitute_code(self["test-prologue"])) self._text_mapper.reset_step() action_content = self._generate_test_case_actions() if self._text_mapper.steps > 0: content.add(f"T_plan({self._text_mapper.steps});") content.add(action_content) - content.add(self.substitute_code(self["epilogue"])) + content.add(self.substitute_code(self["test-epilogue"])) content.add("/** @} */") @@ -195,9 +205,9 @@ class _TestSuiteItem(_TestItem): _test_case_to_suites: Dict[str, List[_TestItem]]) -> None: with content.defgroup_block(self.group_identifier, self.name): content.add(["@ingroup RTEMSTestSuites", "", "@brief Test Suite"]) - content.wrap(self.substitute_text(self["description"])) + content.wrap(self.description) content.add("@{") - content.add(self.substitute_code(self["code"])) + content.add(self.substitute_code(self["test-code"])) content.add("/** @} */") @@ -269,14 +279,6 @@ class _TestDirectiveItem(_TestItem): """ Returns the test case context type. """ return f"{self._ident}_Context" - @property - def includes(self) -> List[str]: - return self._item["test-includes"] - - @property - def local_includes(self) -> List[str]: - return self._item["test-local-includes"] - def _add_pre_condition_descriptions(self, content: CContent) -> None: for condition in self["pre-conditions"]: content.add("static const char * const " @@ -536,8 +538,8 @@ class _TestDirectiveItem(_TestItem): else: with content.function_block( f"void T_case_body_{self.ident}( void )"): - content.add_brief_description(self["test-brief"]) - content.wrap(self["test-description"]) + content.add_brief_description(self.brief) + content.wrap(self.description) content.gap = False ret = "" name = "T_TEST_CASE_FIXTURE" @@ -592,8 +594,8 @@ class _TestDirectiveItem(_TestItem): _directive_add_enum(content, self._post_index_to_enum) content.add(self.substitute_code(header["code"])) with content.doxygen_block(): - content.add_brief_description(self["test-brief"]) - content.wrap(self["test-description"]) + content.add_brief_description(self.brief) + content.wrap(self.description) content.add_param_description(header["run-params"]) content.gap = False content.declare_function("void", f"{self.ident}_Run", @@ -745,7 +747,7 @@ def _gather_action(item: Item, source_files: Dict[str, _SourceFile], def _gather_test_case(item: Item, source_files: Dict[str, _SourceFile], _test_programs: List[_TestProgram]) -> None: - src = _get_source_file(item["target"], source_files) + src = _get_source_file(item["test-target"], source_files) src.add_test_case(item) @@ -756,7 +758,7 @@ def _gather_test_program(item: Item, _source_files: Dict[str, _SourceFile], def _gather_test_suite(item: Item, source_files: Dict[str, _SourceFile], _test_programs: List[_TestProgram]) -> None: - src = _get_source_file(item["target"], source_files) + src = _get_source_file(item["test-target"], source_files) src.add_test_suite(item) |