Skip to content

Commit 37db59c

Browse files
committed
test/linux: Test if kernel logs only known warn and errors
We know that out kernel logs some warnings and errors on startup. These are accepted. With this test we make sure that the kernel only logs these messages and nothing new.
1 parent d3c2203 commit 37db59c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_linux_pstore.py

+26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
1+
import re
2+
3+
14
def test_pstore_fs(shell):
25
"""
36
Test if the pstore filesystem exists.
47
"""
58

69
shell.run_check("test -d /sys/fs/pstore")
10+
11+
12+
def test_kernel_messages(shell, check):
13+
"""
14+
Test if the kernel only logs messages that we expect.
15+
"""
16+
17+
expected = [
18+
re.compile(r"^\[\s*\d+\.\d+\] spi_stm32 44009000\.spi: failed to request (tx|rx) dma channel"),
19+
re.compile(r"^\[\s*\d+\.\d+\] clk: failed to reparent ethck_k to pll4_p: -22"),
20+
re.compile(r"^\[\s*\d+\.\d+\] stm32-dwmac 5800a000\.ethernet switch: Adding VLAN ID 0 is not supported"),
21+
]
22+
23+
messages = shell.run_check("dmesg -l warn -l err -l crit -l alert -l emerg -k")
24+
25+
# Check if we do not have more messages than expected
26+
for message in messages:
27+
for e in expected:
28+
if e.match(message):
29+
break
30+
else:
31+
with check:
32+
raise AssertionError(f"Kernel warned '{message}', but we did not expect this.")

0 commit comments

Comments
 (0)