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 <thomas.guenther@limatica.com>
This commit is contained in:
parent
7faafda9e7
commit
c2d011f366
2 changed files with 15 additions and 1 deletions
|
@ -12,3 +12,17 @@ tests:
|
||||||
- test_framework
|
- test_framework
|
||||||
- pytest
|
- pytest
|
||||||
- shell
|
- 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
|
||||||
|
|
|
@ -240,7 +240,7 @@ class DeviceAdapter(abc.ABC):
|
||||||
with open(self.handler_log_path, 'a+') as log_file:
|
with open(self.handler_log_path, 'a+') as log_file:
|
||||||
while self.is_device_running():
|
while self.is_device_running():
|
||||||
if self.is_device_connected():
|
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:
|
if output:
|
||||||
self._device_read_queue.put(output)
|
self._device_read_queue.put(output)
|
||||||
log_file.write(f'{output}\n')
|
log_file.write(f'{output}\n')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue