Skip to content

Commit

Permalink
trunner: add reboot property in yaml
Browse files Browse the repository at this point in the history
JIRA CI-303
  • Loading branch information
mateusz-bloch committed Jul 27, 2023
1 parent 972e3c9 commit c473f11
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions trunner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ def _parse_shell_command(self, config: dict):
cmd=parsed_cmd,
)

def _parse_reboot(self, config: dict) -> None:
reboot = config.get("reboot", self.test.should_reboot)

if not isinstance(reboot, bool):
raise ParserError(f"reboot must be a boolean value (true/false) not {reboot}")

self.test.should_reboot = reboot

def _parse_ignore(self, config: dict) -> None:
ignore = config.get("ignore", self.main.ignore)

Expand Down Expand Up @@ -248,6 +256,7 @@ def _parse_config(self, config: dict):
if self.test.ignore:
return

self._parse_reboot(config)
self._parse_shell_command(config)
self._parse_load(config)
self._parse_kwargs(config)
Expand Down
12 changes: 6 additions & 6 deletions trunner/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def run_tests(self, tests: Sequence[TestOptions]):
"""

fail, skip = 0, 0
# Reboot is required for the initial test.
tests[0].should_reboot = True

for idx, test in enumerate(tests):
result = TestResult(test.name)
Expand Down Expand Up @@ -191,18 +193,15 @@ def run_tests(self, tests: Sequence[TestOptions]):
def set_reboot_flag(tests, idx, result):
# If the test is successful and the next test doesn't require loading via
# the plo we don't want to reboot the entire device (to speed up the test execution).
# There are three exceptions to this rule:
# There are five exceptions to this rule:
# 0. The yaml config has been configured with the reboot parameter set to True.
# 1. Runner runs in the "nightly" mode when we are not concerned about slow execution.
# 2. The test has failed.
# 3. We have to enter the bootloader in order to load applications.
# 4. The test is skipped, but there should be a reboot.
if idx == len(tests) - 1:
return

tests[idx + 1].should_reboot = False

if result.is_skip():
tests[idx + 1].should_reboot = tests[idx].should_reboot

if (
result.is_fail()
or self.ctx.nightly
Expand All @@ -211,6 +210,7 @@ def set_reboot_flag(tests, idx, result):
and tests[idx + 1].bootloader is not None
and tests[idx + 1].bootloader.apps
)
or result.is_skip() and tests[idx].should_reboot
):
tests[idx + 1].should_reboot = True

Expand Down
2 changes: 1 addition & 1 deletion trunner/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class TestOptions:
target: Optional[str] = None
bootloader: Optional[BootloaderOptions] = None
shell: Optional[ShellOptions] = None
should_reboot: bool = True
should_reboot: bool = False
ignore: bool = False
nightly: bool = False
kwargs: Dict = field(default_factory=dict)

0 comments on commit c473f11

Please sign in to comment.