[PATCH 16/18] test: py: Add a test for log filter-*
Sean Anderson
seanga2 at gmail.com
Tue Oct 6 21:16:08 CEST 2020
This exercises a few success and failure modes of the log filter-*
commands.
Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---
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
More information about the U-Boot
mailing list