Skip to content

Commit dc16886

Browse files
gchwiernordicjm
authored andcommitted
[nrf fromtree] twister: Pass device flash timeout to pytest-harness.
Pass flashing timeout to pytest-harness and use them Signed-off-by: Grzegorz Chwierut <[email protected]> (cherry picked from commit 3923047)
1 parent 21c97d0 commit dc16886

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class HardwareAdapter(DeviceAdapter):
3030

3131
def __init__(self, device_config: DeviceConfig) -> None:
3232
super().__init__(device_config)
33-
self._flashing_timeout: float = self.base_timeout
33+
self._flashing_timeout: float = device_config.flash_timeout
3434
self._serial_connection: serial.Serial | None = None
3535
self._serial_pty_proc: subprocess.Popen | None = None
3636
self._serial_buffer: bytearray = bytearray()

scripts/pylib/pytest-twister-harness/src/twister_harness/plugin.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ def pytest_addoption(parser: pytest.Parser):
3636
type=float,
3737
default=60.0,
3838
help='Set base timeout (in seconds) used during monitoring if some '
39-
'operations are finished in a finite amount of time (e.g. waiting '
40-
'for flashing).'
39+
'operations are finished in a finite amount of time.'
40+
)
41+
twister_harness_group.addoption(
42+
'--flash-timeout',
43+
type=float,
44+
default=60.0,
45+
help='Set timeout for device flashing (in seconds).'
4146
)
4247
twister_harness_group.addoption(
4348
'--build-dir',

scripts/pylib/pytest-twister-harness/src/twister_harness/twister_harness_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DeviceConfig:
1919
type: str
2020
build_dir: Path
2121
base_timeout: float = 60.0 # [s]
22+
flash_timeout: float = 60.0 # [s]
2223
platform: str = ''
2324
serial: str = ''
2425
baud: int = 115200
@@ -65,6 +66,7 @@ def create(cls, config: pytest.Config) -> TwisterHarnessConfig:
6566
type=config.option.device_type,
6667
build_dir=_cast_to_path(config.option.build_dir),
6768
base_timeout=config.option.base_timeout,
69+
flash_timeout=config.option.flash_timeout,
6870
platform=config.option.platform,
6971
serial=config.option.device_serial,
7072
baud=config.option.device_serial_baud,

scripts/pylib/twister/twisterlib/harness.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ def _generate_parameters_for_hardware(self, handler: Handler):
386386
f'--device-serial-baud={hardware.baud}'
387387
])
388388

389+
if hardware.flash_timeout:
390+
command.append(f'--flash-timeout={hardware.flash_timeout}')
391+
389392
options = handler.options
390393
if runner := hardware.runner or options.west_runner:
391394
command.append(f'--runner={runner}')

0 commit comments

Comments
 (0)