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