From be6822a8b6d3350530159ffa71cfdefb3ffc4f25 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 30 Nov 2024 07:46:54 -0500 Subject: [PATCH] twister: do not create overlays/run_id for filtered cases Avoid creating directories and files for instances that are filtered. Signed-off-by: Anas Nashif --- scripts/pylib/twister/twisterlib/testinstance.py | 5 ++++- scripts/pylib/twister/twisterlib/testplan.py | 5 +++++ scripts/tests/twister_blackbox/test_report.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/pylib/twister/twisterlib/testinstance.py b/scripts/pylib/twister/twisterlib/testinstance.py index fcfc7562345386..7c3f340cbb7386 100644 --- a/scripts/pylib/twister/twisterlib/testinstance.py +++ b/scripts/pylib/twister/twisterlib/testinstance.py @@ -79,7 +79,7 @@ def __init__(self, testsuite, platform, outdir): source_dir_rel, testsuite.name ) - self.run_id = self._get_run_id() + self.run_id = None self.domains = None # Instance need to use sysbuild if a given suite or a platform requires it self.sysbuild = testsuite.sysbuild or platform.sysbuild @@ -90,6 +90,9 @@ def __init__(self, testsuite, platform, outdir): self.filters = [] self.filter_type = None + def setup_run_id(self): + self.run_id = self._get_run_id() + def record(self, recording, fname_csv="recording.csv"): if recording: if self.recording is None: diff --git a/scripts/pylib/twister/twisterlib/testplan.py b/scripts/pylib/twister/twisterlib/testplan.py index 336307f0c0bfcc..c3030141fecccc 100755 --- a/scripts/pylib/twister/twisterlib/testplan.py +++ b/scripts/pylib/twister/twisterlib/testplan.py @@ -1206,6 +1206,11 @@ def apply_filters(self, **kwargs): self.add_instances(instance_list) for _, case in self.instances.items(): + # Do not create files for filtered instances + if case.status == TwisterStatus.FILTER: + continue + # set run_id for each unfiltered instance + case.setup_run_id() case.create_overlay(case.platform, self.options.enable_asan, self.options.enable_ubsan, diff --git a/scripts/tests/twister_blackbox/test_report.py b/scripts/tests/twister_blackbox/test_report.py index bac6ddbbbfa0b8..c2ed41f2747ded 100644 --- a/scripts/tests/twister_blackbox/test_report.py +++ b/scripts/tests/twister_blackbox/test_report.py @@ -174,7 +174,7 @@ def test_platform_reports(self, capfd, out_path, test_path, test_platforms, file pytest.fail(f"Unsupported file type: '{path}'") for f_platform in test_platforms: - platform_path = os.path.join(out_path, f_platform.replace("/", "_")) + platform_path = os.path.join(out_path, f_platform.replace("/", "_") + ".json", ) assert os.path.exists(platform_path), f'file not found {f_platform}' assert str(sys_exit.value) == '0'