From fe5a5edfc8c288ff77794c9e19f3a305a72da208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katarzyna=20Gi=C4=85d=C5=82a?= Date: Tue, 23 Apr 2024 15:54:01 +0200 Subject: [PATCH] twister: harness: pytest: Check exist of the runner_params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pytest harness in Twister tries to get custom parameters to the pytest harnesses. It is required although those do not exist (e.g. Twister uses devices without hw map). This change checks if the custom parameters to the pytest harnesses exists. Fixes #71817 Signed-off-by: Katarzyna Giądła --- .../src/twister_harness/device/hardware_adapter.py | 5 +++-- scripts/pylib/twister/twisterlib/harness.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py b/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py index ef25d58cd7d..21d9c7378e4 100644 --- a/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py +++ b/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py @@ -66,8 +66,9 @@ class HardwareAdapter(DeviceAdapter): extra_args: list[str] = [] runner = self.device_config.runner base_args.extend(['--runner', runner]) - for param in self.device_config.runner_params: - extra_args.append(param) + if self.device_config.runner_params: + for param in self.device_config.runner_params: + extra_args.append(param) if board_id := self.device_config.id: if runner == 'pyocd': extra_args.append('--board-id') diff --git a/scripts/pylib/twister/twisterlib/harness.py b/scripts/pylib/twister/twisterlib/harness.py index b65fa7cfada..d299c98c8e6 100644 --- a/scripts/pylib/twister/twisterlib/harness.py +++ b/scripts/pylib/twister/twisterlib/harness.py @@ -382,8 +382,9 @@ class Pytest(Harness): if runner := hardware.runner or options.west_runner: command.append(f'--runner={runner}') - for param in hardware.runner_params: - command.append(f'--runner-params={param}') + if hardware.runner_params: + for param in hardware.runner_params: + command.append(f'--runner-params={param}') if options.west_flash and options.west_flash != []: command.append(f'--west-flash-extra-args={options.west_flash}')