Skip to content

Commit

Permalink
[nrf fromtree] twister: Pass device flash timeout to pytest-harness.
Browse files Browse the repository at this point in the history
Pass flashing timeout to pytest-harness and use them

Signed-off-by: Grzegorz Chwierut <[email protected]>
(cherry picked from commit 3923047)
  • Loading branch information
gchwier committed Sep 3, 2024
1 parent 7b78fdc commit b695be9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
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

0 comments on commit b695be9

Please sign in to comment.