Skip to content

Commit 3194f75

Browse files
gopiotrnashif
authored andcommitted
twister: log error for non-existing platform call
Changes will log error message in following three situations: 1. Platform name pass in --platform option does not exist. 2. During using --all option, platform from platform_allow list does not exist. 3. During using --integration option, platform from integration_platforms list does not exist. Fixes #31868 Signed-off-by: Piotr Golyzniak <[email protected]>
1 parent ecff028 commit 3194f75

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

scripts/pylib/twister/twisterlib.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2770,6 +2770,7 @@ def __init__(self, board_root_list=[], testcase_roots=[], outdir=None):
27702770
self.testcases = {}
27712771
self.quarantine = {}
27722772
self.platforms = []
2773+
self.platform_names = []
27732774
self.selected_platforms = []
27742775
self.filtered_platforms = []
27752776
self.default_platforms = []
@@ -3012,6 +3013,8 @@ def add_configurations(self):
30123013
logger.error("E: %s: can't load: %s" % (file, e))
30133014
self.load_errors += 1
30143015

3016+
self.platform_names = [p.name for p in self.platforms]
3017+
30153018
def get_all_tests(self):
30163019
tests = []
30173020
for _, tc in self.testcases.items():
@@ -3131,7 +3134,7 @@ def load_quarantine(self, file):
31313134
quarantine_list = []
31323135
for quar_dict in quarantine_yaml:
31333136
if quar_dict['platforms'][0] == "all":
3134-
plat = [p.name for p in self.platforms]
3137+
plat = self.platform_names
31353138
else:
31363139
plat = quar_dict['platforms']
31373140
comment = quar_dict.get('comment', "NA")
@@ -3217,6 +3220,7 @@ def apply_filters(self, **kwargs):
32173220
emulation_platforms = True
32183221

32193222
if platform_filter:
3223+
self.verify_platforms_existence(platform_filter, f"platform_filter")
32203224
platforms = list(filter(lambda p: p.name in platform_filter, self.platforms))
32213225
elif emu_filter:
32223226
platforms = list(filter(lambda p: p.simulation != 'na', self.platforms))
@@ -3234,6 +3238,8 @@ def apply_filters(self, **kwargs):
32343238
if tc.build_on_all and not platform_filter:
32353239
platform_scope = self.platforms
32363240
elif tc.integration_platforms and self.integration:
3241+
self.verify_platforms_existence(
3242+
tc.integration_platforms, f"{tc_name} - integration_platforms")
32373243
platform_scope = list(filter(lambda item: item.name in tc.integration_platforms, \
32383244
self.platforms))
32393245
else:
@@ -3244,6 +3250,8 @@ def apply_filters(self, **kwargs):
32443250
# If there isn't any overlap between the platform_allow list and the platform_scope
32453251
# we set the scope to the platform_allow list
32463252
if tc.platform_allow and not platform_filter and not integration:
3253+
self.verify_platforms_existence(
3254+
tc.platform_allow, f"{tc_name} - platform_allow")
32473255
a = set(platform_scope)
32483256
b = set(filter(lambda item: item.name in tc.platform_allow, self.platforms))
32493257
c = a.intersection(b)
@@ -3856,6 +3864,19 @@ def get_testcase(self, identifier):
38563864
results.append(tc)
38573865
return results
38583866

3867+
def verify_platforms_existence(self, platform_names_to_verify, log_info=""):
3868+
"""
3869+
Verify if platform name (passed by --platform option, or in yaml file
3870+
as platform_allow or integration_platforms options) is correct. If not -
3871+
log error.
3872+
"""
3873+
for platform in platform_names_to_verify:
3874+
if platform in self.platform_names:
3875+
break
3876+
else:
3877+
logger.error(f"{log_info} - unrecognized platform - {platform}")
3878+
3879+
38593880
class CoverageTool:
38603881
""" Base class for every supported coverage tool
38613882
"""

0 commit comments

Comments
 (0)