Skip to content

Commit eff7f4d

Browse files
gchwiercarlescufi
authored andcommitted
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 <[email protected]>
1 parent 8e7cda7 commit eff7f4d

File tree

1 file changed

+5
-0
lines changed
  • scripts/pylib/pytest-twister-harness/src/twister_harness

1 file changed

+5
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
import logging
6+
from pathlib import Path
67
from typing import Generator, Type
78

89
import pytest
@@ -13,6 +14,7 @@
1314
from twister_harness.twister_harness_config import DeviceConfig, TwisterHarnessConfig
1415
from twister_harness.helpers.shell import Shell
1516
from twister_harness.helpers.mcumgr import MCUmgr
17+
from twister_harness.helpers.utils import find_in_config
1618

1719
logger = logging.getLogger(__name__)
1820

@@ -58,6 +60,9 @@ def dut(request: pytest.FixtureRequest, device_object: DeviceAdapter) -> Generat
5860
def shell(dut: DeviceAdapter) -> Shell:
5961
"""Return ready to use shell interface"""
6062
shell = Shell(dut, timeout=20.0)
63+
if prompt := find_in_config(Path(dut.device_config.app_build_dir) / 'zephyr' / '.config',
64+
'CONFIG_SHELL_PROMPT_UART'):
65+
shell.prompt = prompt
6166
logger.info('Wait for prompt')
6267
if not shell.wait_for_prompt():
6368
pytest.fail('Prompt not found')

0 commit comments

Comments
 (0)