Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromtree] twister: Pass device flash timeout to pytest-harness. #1994

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HardwareAdapter(DeviceAdapter):

def __init__(self, device_config: DeviceConfig) -> None:
super().__init__(device_config)
self._flashing_timeout: float = self.base_timeout
self._flashing_timeout: float = device_config.flash_timeout
self._serial_connection: serial.Serial | None = None
self._serial_pty_proc: subprocess.Popen | None = None
self._serial_buffer: bytearray = bytearray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ def pytest_addoption(parser: pytest.Parser):
type=float,
default=60.0,
help='Set base timeout (in seconds) used during monitoring if some '
'operations are finished in a finite amount of time (e.g. waiting '
'for flashing).'
'operations are finished in a finite amount of time.'
)
twister_harness_group.addoption(
'--flash-timeout',
type=float,
default=60.0,
help='Set timeout for device flashing (in seconds).'
)
twister_harness_group.addoption(
'--build-dir',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DeviceConfig:
type: str
build_dir: Path
base_timeout: float = 60.0 # [s]
flash_timeout: float = 60.0 # [s]
platform: str = ''
serial: str = ''
baud: int = 115200
Expand Down Expand Up @@ -65,6 +66,7 @@ def create(cls, config: pytest.Config) -> TwisterHarnessConfig:
type=config.option.device_type,
build_dir=_cast_to_path(config.option.build_dir),
base_timeout=config.option.base_timeout,
flash_timeout=config.option.flash_timeout,
platform=config.option.platform,
serial=config.option.device_serial,
baud=config.option.device_serial_baud,
Expand Down
3 changes: 3 additions & 0 deletions scripts/pylib/twister/twisterlib/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ def _generate_parameters_for_hardware(self, handler: Handler):
f'--device-serial-baud={hardware.baud}'
])

if hardware.flash_timeout:
command.append(f'--flash-timeout={hardware.flash_timeout}')

options = handler.options
if runner := hardware.runner or options.west_runner:
command.append(f'--runner={runner}')
Expand Down
Loading