Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 5f0e0c8 | 2017-12-04 13:48:30 -0700 | [diff] [blame] | 2 | # Copyright (c) 2016, Google Inc. |
| 3 | # |
Simon Glass | 5f0e0c8 | 2017-12-04 13:48:30 -0700 | [diff] [blame] | 4 | # U-Boot Verified Boot Test |
| 5 | |
| 6 | """ |
| 7 | This tests U-Boot logging. It uses the 'log test' command with various options |
| 8 | and checks that the output is correct. |
| 9 | """ |
| 10 | |
| 11 | import pytest |
| 12 | |
Tom Rini | 686dc7e | 2018-05-25 08:28:45 -0400 | [diff] [blame] | 13 | @pytest.mark.buildconfigspec('cmd_log') |
Simon Glass | 32e9b16 | 2017-12-28 13:14:21 -0700 | [diff] [blame] | 14 | def test_log_format(u_boot_console): |
| 15 | """Test the 'log format' and 'log rec' commands""" |
| 16 | def run_with_format(fmt, expected_output): |
| 17 | """Set up the log format and then write a log record |
| 18 | |
| 19 | Args: |
| 20 | fmt: Format to use for 'log format' |
| 21 | expected_output: Expected output from the 'log rec' command |
| 22 | """ |
| 23 | output = cons.run_command('log format %s' % fmt) |
| 24 | assert output == '' |
| 25 | output = cons.run_command('log rec arch notice file.c 123 func msg') |
| 26 | assert output == expected_output |
| 27 | |
| 28 | cons = u_boot_console |
| 29 | with cons.log.section('format'): |
| 30 | run_with_format('all', 'NOTICE.arch,file.c:123-func() msg') |
| 31 | output = cons.run_command('log format') |
| 32 | assert output == 'Log format: clFLfm' |
| 33 | |
| 34 | run_with_format('fm', 'func() msg') |
| 35 | run_with_format('clfm', 'NOTICE.arch,func() msg') |
| 36 | run_with_format('FLfm', 'file.c:123-func() msg') |
| 37 | run_with_format('lm', 'NOTICE. msg') |
| 38 | run_with_format('m', 'msg') |
Patrick Delaunay | 053156d | 2020-11-27 11:20:55 +0100 | [diff] [blame] | 39 | |
| 40 | @pytest.mark.buildconfigspec('debug_uart') |
| 41 | @pytest.mark.boardspec('sandbox') |
| 42 | def test_log_dropped(u_boot_console): |
| 43 | """Test dropped 'log' message when debug_uart is activated""" |
| 44 | |
| 45 | cons = u_boot_console |
| 46 | cons.restart_uboot() |
| 47 | output = cons.get_spawn_output().replace('\r', '') |
| 48 | assert 'sandbox: starting...' in output |
| 49 | assert (not 'debug: main' in output) |