Skip to content

Commit

Permalink
twister: fix shell prompt detection with VT100 colors disabled
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tguenth authored and kartben committed Jan 17, 2025
1 parent 7faafda commit c2d011f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions samples/subsys/testsuite/pytest/shell/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,17 @@ tests:
- test_framework
- pytest
- shell
sample.pytest.shell.vt100_colors_off:
filter: CONFIG_SERIAL and dt_chosen_enabled("zephyr,shell-uart")
min_ram: 40
harness: pytest
extra_configs:
- arch:posix:CONFIG_NATIVE_UART_0_ON_STDINOUT=y
- CONFIG_SHELL_VT100_COLORS=n
integration_platforms:
- native_sim
- qemu_cortex_m3
tags:
- test_framework
- pytest
- shell
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def _handle_device_output(self) -> None:
with open(self.handler_log_path, 'a+') as log_file:
while self.is_device_running():
if self.is_device_connected():
output = self._read_device_output().decode(errors='replace').strip()
output = self._read_device_output().decode(errors='replace').rstrip("\r\n")
if output:
self._device_read_queue.put(output)
log_file.write(f'{output}\n')
Expand Down

0 comments on commit c2d011f

Please sign in to comment.