From eff7f4d56a3f4b2d619ddb71e3ba1a9660dfd6f5 Mon Sep 17 00:00:00 2001 From: Grzegorz Chwierut Date: Mon, 15 Jul 2024 11:50:40 +0200 Subject: [PATCH] twister: pytest: Use configured shell prompt in pytest-harness Read CONFIG_SHELL_PROMPT_UART from config file and use them in shell fixture in pytest-harness package. Signed-off-by: Grzegorz Chwierut --- .../pytest-twister-harness/src/twister_harness/fixtures.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/pylib/pytest-twister-harness/src/twister_harness/fixtures.py b/scripts/pylib/pytest-twister-harness/src/twister_harness/fixtures.py index a4819ca20c1..c4c15d4b855 100644 --- a/scripts/pylib/pytest-twister-harness/src/twister_harness/fixtures.py +++ b/scripts/pylib/pytest-twister-harness/src/twister_harness/fixtures.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 import logging +from pathlib import Path from typing import Generator, Type import pytest @@ -13,6 +14,7 @@ from twister_harness.device.factory import DeviceFactory from twister_harness.twister_harness_config import DeviceConfig, TwisterHarnessConfig from twister_harness.helpers.shell import Shell from twister_harness.helpers.mcumgr import MCUmgr +from twister_harness.helpers.utils import find_in_config logger = logging.getLogger(__name__) @@ -58,6 +60,9 @@ def dut(request: pytest.FixtureRequest, device_object: DeviceAdapter) -> Generat def shell(dut: DeviceAdapter) -> Shell: """Return ready to use shell interface""" shell = Shell(dut, timeout=20.0) + if prompt := find_in_config(Path(dut.device_config.app_build_dir) / 'zephyr' / '.config', + 'CONFIG_SHELL_PROMPT_UART'): + shell.prompt = prompt logger.info('Wait for prompt') if not shell.wait_for_prompt(): pytest.fail('Prompt not found')