From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Anderson Date: Tue, 6 Oct 2020 15:16:08 -0400 Subject: [PATCH 16/18] test: py: Add a test for log filter-* In-Reply-To: <20201006191610.761899-1-seanga2@gmail.com> References: <20201006191610.761899-1-seanga2@gmail.com> Message-ID: <20201006191610.761899-17-seanga2@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This exercises a few success and failure modes of the log filter-* commands. Signed-off-by: Sean Anderson --- test/py/tests/test_log.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py index f191c84c02..87c0c21575 100644 --- a/test/py/tests/test_log.py +++ b/test/py/tests/test_log.py @@ -154,3 +154,42 @@ def test_log_format(u_boot_console): run_with_format('FLfm', 'file.c:123-func() msg') run_with_format('lm', 'NOTICE. msg') run_with_format('m', 'msg') + + at pytest.mark.buildconfigspec('cmd_log') +def test_log_filter(u_boot_console): + c = u_boot_console + + # Test invalid options + assert 'rc:1' in c.run_command('log filter-add -AD; echo rc:$?') + assert 'rc:1' in c.run_command('log filter-add -l1 -L1; echo rc:$?') + assert 'rc:1' in c.run_command('log filter-add -l1 -L1; echo rc:$?') + assert 'rc:1' in c.run_command('log filter-add -lfoo; echo rc:$?') + assert 'rc:1' in c.run_command('log filter-add -cfoo; echo rc:$?') + assert 'rc:1' in c.run_command('log filter-add -ccore -ccore -ccore -ccore -ccore -ccore; echo rc:$?') + + # Test filters + assert c.run_command('log format m') == '' + filt1 = c.run_command('log filter-add -p') + assert c.run_command('log rec mmc warning file 123 func msg') == 'msg' + filt2 = c.run_command('log filter-add -p -DL warning -cmmc -cspi -ffile') + assert c.run_command('log rec mmc warning file 123 func msg') == '' + assert c.run_command('log rec spi warning file 123 func msg') == '' + assert c.run_command('log rec arch warning file 123 func msg') == 'msg' + assert c.run_command('log rec mmc warning file2 123 func msg') == 'msg' + assert c.run_command('log rec mmc err file 123 func msg') == 'msg' + + # "Test" filter-list; ignore the header + resp = c.run_command('log filter-list')[:-1] + assert filt1 in resp + assert filt2 in resp + assert 'allow' in resp + assert 'deny' in resp + assert '>=WARNING' in resp + assert '<=IO' in resp + assert 'mmc' in resp + assert 'spi' in resp + assert 'file' in resp + + # Ensure removal works + assert c.run_command('log filter-remove ' + filt2) == '' + assert c.run_command('log rec mmc warning file 123 func msg') == 'msg' -- 2.28.0