twister: support defining testcases in yaml file

Some complex testsuite use macros and other mean to define testcases
which makes them unparseable. This ends up in a descripency between the
testplan and the test results.

Allow adding the testcases into the yaml and use those instead of
parsing the C files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2022-03-26 07:57:46 -04:00
commit 8e805596d5
2 changed files with 23 additions and 5 deletions

View file

@ -2068,12 +2068,14 @@ Tests should reference the category and subsystem with a dot as a separator.
def parse_subcases(self, test_path):
subcases, ztest_suite_names = self.scan_path(test_path)
for sub in subcases:
name = "{}.{}".format(self.id, sub)
self.add_testcase(name)
# if testcases are provided as part of the yaml, skip this step.
if not self.testcases:
for sub in subcases:
name = "{}.{}".format(self.id, sub)
self.add_testcase(name)
if not subcases:
self.add_testcase(self.id)
if not subcases:
self.add_testcase(self.id)
self.ztest_suite_names = ztest_suite_names
@ -3018,6 +3020,7 @@ class TestPlan(DisablePyTestCollectionMixin):
"arch_exclude": {"type": "set"},
"extra_sections": {"type": "list", "default": []},
"integration_platforms": {"type": "list", "default": []},
"testcases": {"type": "list", "default": []},
"platform_exclude": {"type": "set"},
"platform_allow": {"type": "set"},
"toolchain_exclude": {"type": "set"},
@ -3405,6 +3408,11 @@ class TestPlan(DisablePyTestCollectionMixin):
ts.integration_platforms = ts_dict["integration_platforms"]
ts.seed = ts_dict["seed"]
testcases = ts_dict.get("testcases", [])
if testcases:
for tc in testcases:
ts.add_testcase(name=f"{name}.{tc}")
ts.parse_subcases(ts_path)
if testsuite_filter:

View file

@ -43,6 +43,11 @@ mapping:
required: false
sequence:
- type: str
"testcases":
type: seq
required: false
sequence:
- type: str
"harness":
type: str
required: false
@ -153,6 +158,11 @@ mapping:
"arch_allow":
type: str
required: false
"testcases":
type: seq
required: false
sequence:
- type: str
"build_only":
type: bool
required: false