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 24, 2023
1 parent 6c0ba39 commit 1cbc7ed
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
10 changes: 10 additions & 0 deletions trunner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ConfigParser:
class MainConfig:
targets: Optional[Set] = None
type: Optional[str] = None
reboot: bool = False
ignore: bool = False
nightly: bool = False

Expand Down Expand Up @@ -169,6 +170,14 @@ def _parse_shell_command(self, config: dict):
cmd=parsed_cmd,
)

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

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

self.test.reboot = reboot

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

Expand Down Expand Up @@ -248,6 +257,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
2 changes: 1 addition & 1 deletion trunner/target/armv7a9.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def flash_dut(self):
def build_test(self, test: TestOptions) -> Callable[[], Optional[TestResult]]:
builder = HarnessBuilder()

if test.should_reboot:
if test.reboot:
builder.add(RebooterHarness(self.rebooter))

if test.shell is not None:
Expand Down
4 changes: 2 additions & 2 deletions trunner/target/armv7m7.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def flash_dut(self):
def build_test(self, test: TestOptions) -> Callable[[], Optional[TestResult]]:
builder = HarnessBuilder()

if test.should_reboot:
if test.reboot:
builder.add(RebooterHarness(self.rebooter, hard=False))

if test.bootloader is not None:
Expand Down Expand Up @@ -114,6 +114,6 @@ class IMXRT117xEvkTarget(IMXTarget):

def build_test(self, test: TestOptions) -> Callable[[], Optional[TestResult]]:
# FIXME due to https://github.com/phoenix-rtos/phoenix-rtos-project/issues/580 always reboot
test.should_reboot = True
test.reboot = True

return super().build_test(test)
2 changes: 1 addition & 1 deletion trunner/target/emulated.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def flash_dut(self):
def build_test(self, test: TestOptions) -> Callable[[], Optional[TestResult]]:
builder = HarnessBuilder()

if test.should_reboot:
if test.reboot:
builder.add(RebooterHarness(self.rebooter))

if test.shell is not None:
Expand Down
11 changes: 6 additions & 5 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].reboot = True

for idx, test in enumerate(tests):
result = TestResult(test.name)
Expand Down Expand Up @@ -191,17 +193,16 @@ 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 four 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.
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
tests[idx + 1].reboot = tests[idx].reboot

if (
result.is_fail()
Expand All @@ -212,7 +213,7 @@ def set_reboot_flag(tests, idx, result):
and tests[idx + 1].bootloader.apps
)
):
tests[idx + 1].should_reboot = True
tests[idx + 1].reboot = True

set_reboot_flag(tests, idx, result)

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
reboot: bool = False
ignore: bool = False
nightly: bool = False
kwargs: Dict = field(default_factory=dict)

0 comments on commit 1cbc7ed

Please sign in to comment.