Skip to content

Commit a5ffd7f

Browse files
JordanYateskartben
authored andcommitted
scripts: twisterlib: extend testcase schema for reboots
Extend the testcase schema to provide a way to communicate that a given test is expected to reboot during execution. The generic harness takes that information and suppresses `already STARTED` warnings if the restart is expected. Signed-off-by: Jordan Yates <[email protected]>
1 parent a29c0af commit a5ffd7f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/develop/test/twister.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,11 @@ required_snippets: <list of needed snippets>
734734
- cdc-acm-console
735735
- user-snippet-example
736736
737+
expect_reboot: <True|False> (default False)
738+
Notify twister that the test scenario is expected to reboot while executing.
739+
When enabled, twister will suppress warnings about unexpected multiple runs
740+
of a testsuite or testcase.
741+
737742
The set of test scenarios that actually run depends on directives in the test scenario
738743
filed and options passed in on the command line. If there is any confusion,
739744
running with ``-v`` or examining the discard report

scripts/pylib/twister/twisterlib/harness.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def configure(self, instance):
9191
config = instance.testsuite.harness_config
9292
self.id = instance.testsuite.id
9393
self.run_id = instance.run_id
94+
self.expect_reboot = getattr(instance.testsuite, 'expect_reboot', False)
9495
if instance.testsuite.ignore_faults:
9596
self.fail_on_fault = False
9697

@@ -848,7 +849,7 @@ def start_suite(self, suite_name, phase='TS_START'):
848849
logger.debug(f"{phase}: unexpected Ztest suite '{suite_name}' is "
849850
f"not present among: {self.instance.testsuite.ztest_suite_names}")
850851
if suite_name in self.started_suites:
851-
if self.started_suites[suite_name]['count'] > 0:
852+
if self.started_suites[suite_name]['count'] > 0 and not self.expect_reboot:
852853
# Either the suite restarts itself or unexpected state transition.
853854
logger.warning(f"{phase}: already STARTED '{suite_name}':"
854855
f"{self.started_suites[suite_name]}")
@@ -878,7 +879,7 @@ def end_suite(self, suite_name, phase='TS_END', suite_status=None):
878879

879880
def start_case(self, tc_name, phase='TC_START'):
880881
if tc_name in self.started_cases:
881-
if self.started_cases[tc_name]['count'] > 0:
882+
if self.started_cases[tc_name]['count'] > 0 and not self.expect_reboot:
882883
logger.warning(f"{phase}: already STARTED case "
883884
f"'{tc_name}':{self.started_cases[tc_name]}")
884885
self.started_cases[tc_name]['count'] += 1

scripts/schemas/twister/testsuite-schema.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ schema;scenario-schema:
7070
"extra_sections":
7171
type: any
7272
required: false
73+
"expect_reboot":
74+
type: bool
75+
required: false
7376
"required_snippets":
7477
type: seq
7578
required: false

0 commit comments

Comments
 (0)