twister: fix platform filter when loading plan from file

if alias or shorthand name is provided on the command line, we need
convert this to complete target name for the filters to work.

Fixes #80332

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2024-10-23 21:28:35 -04:00 committed by Henrik Brix Andersen
parent 625246f241
commit e90559f0da
2 changed files with 13 additions and 3 deletions

View file

@ -230,11 +230,21 @@ class TestPlan:
# Get list of connected hardware and filter tests to only be run on connected hardware.
# If the platform does not exist in the hardware map or was not specified by --platform,
# just skip it.
connected_list = self.options.platform
connected_list = []
excluded_list = []
for _cp in self.options.platform:
if _cp in self.platform_names:
connected_list.append(self.get_platform(_cp).name)
if self.options.exclude_platform:
for excluded in self.options.exclude_platform:
for _p in self.options.exclude_platform:
if _p in self.platform_names:
excluded_list.append(self.get_platform(_p).name)
for excluded in excluded_list:
if excluded in connected_list:
connected_list.remove(excluded)
self.load_from_file(last_run, filter_platform=connected_list)
self.selected_platforms = set(p.platform.name for p in self.instances.values())
else:

View file

@ -594,7 +594,7 @@ TESTDATA_4 = [
(None, None, 'load_tests.json', None, '0/4',
TwisterRuntimeError, set(['lt-p1', 'lt-p3', 'lt-p4', 'lt-p2']), []),
('suffix', None, None, True, '2/4',
None, set(['ts-p4', 'ts-p2', 'ts-p3']), [2, 4]),
None, set(['ts-p4', 'ts-p2', 'ts-p1', 'ts-p3']), [2, 4]),
]
@pytest.mark.parametrize(