Skip to content

Commit 0b76fd9

Browse files
dcpleungnashif
authored andcommitted
tests: logging/dictionary: pytest only looks at last output
There are instances where on hardware tests would result in multiple dictionary logging blocks. This is usually due to flashing and running via twister in separate steps. Once flashing is done, the device starts running and sending logging string to output, but twister is not ready to read them, thus leaving the strings in the host's UART buffer. Then twister starts its testing run by resetting the device which results in another dictionary logging block to show up. So the pytest script has to be updated to only look at the last dictionay logging block. Signed-off-by: Daniel Leung <[email protected]>
1 parent ea109ce commit 0b76fd9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/subsys/logging/dictionary/pytest/test_logging_dictionary.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ def process_logs(dut: DeviceAdapter, build_dir):
4343
# timeout earlier with per-test timeout.
4444
handler_output = dut.readlines_until(regex = '.*##ZLOGV1##[0-9]+', timeout = 600.0)
4545

46-
encoded_logs = handler_output[-1]
46+
# Join all the output lines together
47+
handler_output = ''.join(ho.strip() for ho in handler_output)
48+
49+
# Find the last dictionary logging block and extract it
50+
ridx = handler_output.rfind("##ZLOGV1##")
51+
encoded_logs = handler_output[ridx:]
4752

4853
encoded_log_file = os.path.join(build_dir, "encoded.log")
4954
with open(encoded_log_file, 'w', encoding='utf-8') as fp:

0 commit comments

Comments
 (0)