]>
git.ipfire.org Git - people/ms/u-boot.git/blob - test/py/tests/test_log.py
1 # Copyright (c) 2016, Google Inc.
3 # SPDX-License-Identifier: GPL-2.0+
5 # U-Boot Verified Boot Test
8 This tests U-Boot logging. It uses the 'log test' command with various options
9 and checks that the output is correct.
14 LOGL_FIRST
, LOGL_WARNING
, LOGL_INFO
= (0, 4, 6)
16 @pytest.mark
.buildconfigspec('log')
17 def test_log(u_boot_console
):
18 """Test that U-Boot logging works correctly."""
19 def check_log_entries(lines
, mask
, max_level
=LOGL_INFO
):
20 """Check that the expected log records appear in the output
23 lines: iterator containing lines to check
24 mask: bit mask to select which lines to check for:
25 bit 0: standard log line
27 max_level: maximum log level to expect in the output
29 for i
in range(max_level
):
31 assert 'log_run() log %d' % i
== lines
.next()
33 assert 'func() _log %d' % i
== lines
.next()
35 def run_test(testnum
):
36 """Run a particular test number (the 'log test' command)
39 testnum: Test number to run
41 iterator containing the lines output from the command
44 with cons
.log
.section('basic'):
45 output
= u_boot_console
.run_command('log test %d' % testnum
)
46 split
= output
.replace('\r', '').splitlines()
48 assert 'test %d' % testnum
== lines
.next()
53 check_log_entries(lines
, 3)
57 check_log_entries(lines
, 3)
64 check_log_entries(lines
, 2)
68 assert next(lines
, None) == None
72 check_log_entries(lines
, 2)
76 check_log_entries(lines
, 3)
80 check_log_entries(lines
, 3, LOGL_WARNING
)
84 check_log_entries(lines
, 3)
88 check_log_entries(lines
, 3)
90 # TODO(sjg@chromium.org): Consider structuring this as separate tests