Skip to content

Commit

Permalink
pytest: add "--skip-flash" option
Browse files Browse the repository at this point in the history
The pytest is always trying to flash when running on real HW
(--device-type=hardware). On ARM64 Cortex-A platform like RPI5 there no way
to implement flashing through pytest framework now: the Zephyr binary has
to be stored on SD-card and loaded by bootloader.

Add "--skip-flash" option which still will allow to run pytest with shell
interface manually after platform is booted and shell is ready.

Signed-off-by: Grygorii Strashko <[email protected]>
Acked-by: Dmytro Firsov <[email protected]>
  • Loading branch information
Grygorii Strashko committed Jun 18, 2024
1 parent 6da4e8b commit 7bad218
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def launch(self) -> None:
self._start_reader_thread()
self.connect()

if self.device_config.type == 'hardware':
if not self.device_config.skip_flash and self.device_config.type == 'hardware':
# On hardware, flash after connecting to COM port, otherwise some messages
# from target can be lost.
self._flash_and_run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def pytest_addoption(parser: pytest.Parser):
choices=('function', 'class', 'module', 'package', 'session'),
help='The scope for which `dut` and `shell` fixtures are shared.'
)
twister_harness_group.addoption(
'--skip-flash',
default=False,
help='Skip flashing.',
action='store_true',
)


def pytest_configure(config: pytest.Config):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DeviceConfig:
pre_script: Path | None = None
post_script: Path | None = None
post_flash_script: Path | None = None
skip_flash: bool = False


@dataclass
Expand Down Expand Up @@ -61,6 +62,7 @@ def create(cls, config: pytest.Config) -> TwisterHarnessConfig:
pre_script=_cast_to_path(config.option.pre_script),
post_script=_cast_to_path(config.option.post_script),
post_flash_script=_cast_to_path(config.option.post_flash_script),
skip_flash=config.option.skip_flash,
)

devices.append(device_from_cli)
Expand Down

0 comments on commit 7bad218

Please sign in to comment.