Skip to content

Commit c2d011f

Browse files
tguenthkartben
authored andcommitted
twister: fix shell prompt detection with VT100 colors disabled
Device adapter strips all whitespace from output lines causing test failures when matching default shell prompt "uart:~$ " with trailing space. Update _handle_device_output to only strip line endings (\r\n) while preserving whitespace required for prompt detection. A testcase sample.pytest.shell.no_vt100 was added to verify prompt matching works with CONFIG_SHELL_VT100_COLORS disabled. Signed-off-by: Thomas Günther <[email protected]>
1 parent 7faafda commit c2d011f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

samples/subsys/testsuite/pytest/shell/testcase.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,17 @@ tests:
1212
- test_framework
1313
- pytest
1414
- shell
15+
sample.pytest.shell.vt100_colors_off:
16+
filter: CONFIG_SERIAL and dt_chosen_enabled("zephyr,shell-uart")
17+
min_ram: 40
18+
harness: pytest
19+
extra_configs:
20+
- arch:posix:CONFIG_NATIVE_UART_0_ON_STDINOUT=y
21+
- CONFIG_SHELL_VT100_COLORS=n
22+
integration_platforms:
23+
- native_sim
24+
- qemu_cortex_m3
25+
tags:
26+
- test_framework
27+
- pytest
28+
- shell

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def _handle_device_output(self) -> None:
240240
with open(self.handler_log_path, 'a+') as log_file:
241241
while self.is_device_running():
242242
if self.is_device_connected():
243-
output = self._read_device_output().decode(errors='replace').strip()
243+
output = self._read_device_output().decode(errors='replace').rstrip("\r\n")
244244
if output:
245245
self._device_read_queue.put(output)
246246
log_file.write(f'{output}\n')

0 commit comments

Comments
 (0)