Skip to content

Commit c0dbcda

Browse files
nashifkartben
authored andcommitted
twister: error on invalid platforms
In case of unknown platforms in filters such as plaform_allow, integration_plaforms or platform_exclude, report an error and exit. Signed-off-by: Anas Nashif <[email protected]>
1 parent 256a514 commit c0dbcda

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

scripts/pylib/twister/twisterlib/testplan.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -614,27 +614,15 @@ def add_testsuites(self, testsuite_filter=None):
614614
)
615615

616616
# convert to fully qualified names
617-
_integration = []
618-
_platform_allow = []
619-
_platform_exclude = []
620-
for _ip in suite.integration_platforms:
621-
if _ip in self.platform_names:
622-
_integration.append(self.get_platform(_ip).name)
623-
else:
624-
logger.error(f"Platform {_ip} not found in the list of platforms")
625-
suite.integration_platforms = _integration
626-
for _pe in suite.platform_exclude:
627-
if _pe in self.platform_names:
628-
_platform_exclude.append(self.get_platform(_pe).name)
629-
else:
630-
logger.error(f"Platform {_pe} not found in the list of platforms")
631-
suite.platform_exclude = _platform_exclude
632-
for _pa in suite.platform_allow:
633-
if _pa in self.platform_names:
634-
_platform_allow.append(self.get_platform(_pa).name)
635-
else:
636-
logger.error(f"Platform {_pa} not found in the list of platforms")
637-
suite.platform_allow = _platform_allow
617+
suite.integration_platforms = self.verify_platforms_existence(
618+
suite.integration_platforms,
619+
f"integration_platforms in {suite.name}")
620+
suite.platform_exclude = self.verify_platforms_existence(
621+
suite.platform_exclude,
622+
f"platform_exclude in {suite.name}")
623+
suite.platform_allow = self.verify_platforms_existence(
624+
suite.platform_allow,
625+
f"platform_allow in {suite.name}")
638626

639627
if suite.harness in ['ztest', 'test']:
640628
if subcases is None:
@@ -1261,12 +1249,16 @@ def verify_platforms_existence(self, platform_names_to_verify, log_info=""):
12611249
as platform_allow or integration_platforms options) is correct. If not -
12621250
log and raise error.
12631251
"""
1252+
_platforms = []
12641253
for platform in platform_names_to_verify:
12651254
if platform in self.platform_names:
1266-
continue
1255+
p = self.get_platform(platform)
1256+
if p:
1257+
_platforms.append(p.name)
12671258
else:
12681259
logger.error(f"{log_info} - unrecognized platform - {platform}")
12691260
sys.exit(2)
1261+
return _platforms
12701262

12711263
def create_build_dir_links(self):
12721264
"""

0 commit comments

Comments
 (0)