-
Notifications
You must be signed in to change notification settings - Fork 3
Add test_linux_watchdog: Test if the watchdog resets the device #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,9 @@ | ||||||||||||||||||
| import json | ||||||||||||||||||
|
|
||||||||||||||||||
| from pexpect import TIMEOUT | ||||||||||||||||||
|
|
||||||||||||||||||
| from lxatacstrategy import Status | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| def test_linux_i2c_bus_0_eeprom(shell): | ||||||||||||||||||
| """ | ||||||||||||||||||
|
|
@@ -80,3 +84,35 @@ def test_sensors(shell, record_property): | |||||||||||||||||
| assert "cpu_thermal-virtual-0" in data | ||||||||||||||||||
| record_property("cpu_thermal-virtual-0", data["cpu_thermal-virtual-0"]["temp1"]["temp1_input"]) | ||||||||||||||||||
| assert 10 <= data["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] <= 70 | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| def test_linux_watchdog(strategy): | ||||||||||||||||||
| """ | ||||||||||||||||||
| Check if the system reboots, if we stop feeding the watchdog. | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| The watchdog is handled by systemd, so stopping systemd should reboot the DUT. | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| """ | ||||||||||||||||||
|
|
||||||||||||||||||
| try: | ||||||||||||||||||
| strategy.target.deactivate(strategy.shell) | ||||||||||||||||||
|
|
||||||||||||||||||
| # systemd should be feeding the watchdog. let's kill systemd and wait for the watchdog to reset the DUT. | ||||||||||||||||||
| strategy.console.write(b"kill -11 1\n") # This command will not return, so we can not use shell.run() | ||||||||||||||||||
|
Comment on lines
+97
to
+100
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The upstream BareboxRebootStrategy does this a little different: https://github.com/labgrid-project/labgrid/blob/f63dfd70a5da2c7007ee8c320fa969df2c0bf16e/examples/strategy/bareboxrebootstrategy.py#L95 |
||||||||||||||||||
|
|
||||||||||||||||||
| # Wait for barebox to boot. Reset reason must be "Watchdog" | ||||||||||||||||||
| index, _, _, _ = strategy.console.expect( | ||||||||||||||||||
| ["STM32 RCC reset reason WDG", TIMEOUT], | ||||||||||||||||||
| timeout=30, | ||||||||||||||||||
| ) | ||||||||||||||||||
| if index != 0: | ||||||||||||||||||
| raise Exception("Device failed to reboot in time.") | ||||||||||||||||||
|
Comment on lines
+103
to
+108
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the benefit compared to..
Suggested change
..? |
||||||||||||||||||
| strategy.target.activate(strategy.barebox) | ||||||||||||||||||
| strategy.barebox.run_check("global linux.bootargs.loglevel=loglevel=6") | ||||||||||||||||||
| strategy.barebox.boot("") | ||||||||||||||||||
| strategy.barebox.await_boot() | ||||||||||||||||||
| strategy.target.activate(strategy.shell) | ||||||||||||||||||
|
Comment on lines
+109
to
+113
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're basically doing the same as the strategy does. I don't think that's a good approach. I would drop all of this (see below how the device can be easily transitioned to a well defined state). |
||||||||||||||||||
| except Exception as e: | ||||||||||||||||||
| # With any exception happening in this test we must assume that the device state is tainted. | ||||||||||||||||||
| # Let's switch it off, so the strategy can reboot the device into a clean state | ||||||||||||||||||
| strategy.transition(Status.off) | ||||||||||||||||||
| raise e | ||||||||||||||||||
|
Comment on lines
+114
to
+118
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
..and drop the |
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing makes sure the device is actually in the shell state.