1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2016, Google Inc.
4 # U-Boot Verified Boot Test
7 This tests U-Boot logging. It uses the 'log test' command with various options
8 and checks that the output is correct.
13 @pytest.mark.buildconfigspec('cmd_log')
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
20 fmt: Format to use for 'log format'
21 expected_output: Expected output from the 'log rec' command
23 output = cons.run_command('log format %s' % fmt)
25 output = cons.run_command('log rec arch notice file.c 123 func msg')
26 assert output == expected_output
29 with cons.log.section('format'):
30 pad = int(u_boot_console.config.buildconfig.get('config_logf_func_pad'))
31 padding = ' ' * (pad - len('func'))
33 run_with_format('all', f'NOTICE.arch,file.c:123-{padding}func() msg')
34 output = cons.run_command('log format')
35 assert output == 'Log format: clFLfm'
37 run_with_format('fm', f'{padding}func() msg')
38 run_with_format('clfm', f'NOTICE.arch,{padding}func() msg')
39 run_with_format('FLfm', f'file.c:123-{padding}func() msg')
40 run_with_format('lm', 'NOTICE. msg')
41 run_with_format('m', 'msg')
43 @pytest.mark.buildconfigspec('debug_uart')
44 @pytest.mark.boardspec('sandbox')
45 def test_log_dropped(u_boot_console):
46 """Test dropped 'log' message when debug_uart is activated"""
50 output = cons.get_spawn_output().replace('\r', '')
51 assert (not 'debug: main' in output)