Skip to content

Commit 098aeac

Browse files
committed
Add test_linux_watchdog: Test if the watchdog resets the device
Signed-off-by: Chris Fiege <[email protected]>
1 parent 28cd0b8 commit 098aeac

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/test_linux_hardware.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import json
22

3+
from pexpect import TIMEOUT
4+
5+
from lxatacstrategy import Status
6+
37

48
def test_linux_i2c_bus_0_eeprom(shell):
59
"""
@@ -80,3 +84,35 @@ def test_sensors(shell, record_property):
8084
assert "cpu_thermal-virtual-0" in data
8185
record_property("cpu_thermal-virtual-0", data["cpu_thermal-virtual-0"]["temp1"]["temp1_input"])
8286
assert 10 <= data["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] <= 70
87+
88+
89+
def test_linux_watchdog(strategy):
90+
"""
91+
Check if the system reboots, if we stop feeding the watchdog.
92+
93+
The watchdog is handled by systemd, so stopping systemd should reboot the DUT.
94+
"""
95+
96+
try:
97+
strategy.target.deactivate(strategy.shell)
98+
99+
# systemd should be feeding the watchdog. let's kill systemd and wait for the watchdog to reset the DUT.
100+
strategy.console.write(b"kill -11 1\n") # This command will not return, so we can not use shell.run()
101+
102+
# Wait for barebox to boot. Reset reason must be "Watchdog"
103+
index, _, _, _ = strategy.console.expect(
104+
["STM32 RCC reset reason WDG", TIMEOUT],
105+
timeout=30,
106+
)
107+
if index != 0:
108+
raise Exception("Device failed to reboot in time.")
109+
strategy.target.activate(strategy.barebox)
110+
strategy.barebox.run_check("global linux.bootargs.loglevel=loglevel=6")
111+
strategy.barebox.boot("")
112+
strategy.barebox.await_boot()
113+
strategy.target.activate(strategy.shell)
114+
except Exception as e:
115+
# With any exception happening in this test we must assume that the device state is tainted.
116+
# Let's switch it off, so the strategy can reboot the device into a clean state
117+
strategy.transition(Status.off)
118+
raise e

0 commit comments

Comments
 (0)