test_log.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2016, Google Inc.
  3. #
  4. # U-Boot Verified Boot Test
  5. """
  6. This tests U-Boot logging. It uses the 'log test' command with various options
  7. and checks that the output is correct.
  8. """
  9. import pytest
  10. @pytest.mark.buildconfigspec('cmd_log')
  11. def test_log_format(u_boot_console):
  12. """Test the 'log format' and 'log rec' commands"""
  13. def run_with_format(fmt, expected_output):
  14. """Set up the log format and then write a log record
  15. Args:
  16. fmt: Format to use for 'log format'
  17. expected_output: Expected output from the 'log rec' command
  18. """
  19. output = cons.run_command('log format %s' % fmt)
  20. assert output == ''
  21. output = cons.run_command('log rec arch notice file.c 123 func msg')
  22. assert output == expected_output
  23. cons = u_boot_console
  24. with cons.log.section('format'):
  25. run_with_format('all', 'NOTICE.arch,file.c:123-func() msg')
  26. output = cons.run_command('log format')
  27. assert output == 'Log format: clFLfm'
  28. run_with_format('fm', 'func() msg')
  29. run_with_format('clfm', 'NOTICE.arch,func() msg')
  30. run_with_format('FLfm', 'file.c:123-func() msg')
  31. run_with_format('lm', 'NOTICE. msg')
  32. run_with_format('m', 'msg')
  33. @pytest.mark.buildconfigspec('debug_uart')
  34. @pytest.mark.boardspec('sandbox')
  35. def test_log_dropped(u_boot_console):
  36. """Test dropped 'log' message when debug_uart is activated"""
  37. cons = u_boot_console
  38. cons.restart_uboot()
  39. output = cons.get_spawn_output().replace('\r', '')
  40. assert (not 'debug: main' in output)