Skip to content

Commit b77c08e

Browse files
SmithCharthnez
andcommitted
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. Co-authored-by: Leonard Göhrs <[email protected]>
1 parent 294dbba commit b77c08e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_linux_pstore.py

+29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
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+
This test will ignore some harmless messages that can happen during normal operation.
17+
"""
18+
19+
expected = {
20+
"spi_stm32 44009000.spi: failed to request tx dma channel",
21+
"spi_stm32 44009000.spi: failed to request rx dma channel",
22+
"clk: failed to reparent ethck_k to pll4_p: -22",
23+
"stm32-dwmac 5800a000.ethernet switch: Adding VLAN ID 0 is not supported",
24+
}
25+
26+
allowed = {
27+
# The following messages can happen during other tests and are harmless
28+
"sd 0:0:0:0: [sda] No Caching mode page found",
29+
"sd 0:0:0:0: [sda] Assuming drive cache: write through",
30+
}
31+
32+
messages = shell.run_check("dmesg -l warn -l err -l crit -l alert -l emerg -k")
33+
messages = set(re.sub(r"^\[\s*\d+\.\d+\] ", "", m) for m in messages)
34+
35+
assert messages - allowed == expected

0 commit comments

Comments
 (0)