Skip to content

Commit b89a3d9

Browse files
committed
twister: count retries after failures or errors
When twister is set to retry any failures, count the number of retries and record the number in the json file. This will help us identify unstable tests or tests requiring attention. Signed-off-by: Anas Nashif <[email protected]>
1 parent 4f458ba commit b89a3d9

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

scripts/pylib/twister/twisterlib/reports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ def json_report(self, filename, version="NA"):
267267
if rom_size:
268268
suite["rom_size"] = rom_size
269269

270+
suite['retries'] = instance.retries
271+
270272
if instance.status in ["error", "failed"]:
271273
suite['status'] = instance.status
272274
suite["reason"] = instance.reason

scripts/pylib/twister/twisterlib/runner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@ def add_tasks_to_queue(self, pipeline, build_only=False, test_only=False, retry_
972972

973973
if instance.status not in no_retry_statuses:
974974
logger.debug(f"adding {instance.name}")
975+
if instance.status:
976+
instance.retries += 1
977+
975978
instance.status = None
976979
if test_only and instance.run:
977980
pipeline.put({"op": "run", "test": instance})

scripts/pylib/twister/twisterlib/testinstance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, testsuite, platform, outdir):
4040
self.handler = None
4141
self.outdir = outdir
4242
self.execution_time = 0
43+
self.retries = 0
4344

4445
self.name = os.path.join(platform.name, testsuite.name)
4546
self.run_id = self._get_run_id()

scripts/pylib/twister/twisterlib/testplan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def load_from_file(self, file, filter_platform=[]):
524524
if status in ["error", "failed"]:
525525
instance.status = None
526526
instance.reason = None
527+
instance.retries += 1
527528
# test marked as passed (built only) but can run when
528529
# --test-only is used. Reset status to capture new results.
529530
elif status == 'passed' and instance.run and self.options.test_only:

0 commit comments

Comments
 (0)