Add test_linux_watchdog: Test if the watchdog resets the device#18
Add test_linux_watchdog: Test if the watchdog resets the device#18SmithChart wants to merge 1 commit intolinux-automation:masterfrom
Conversation
Signed-off-by: Chris Fiege <cfi@pengutronix.de>
0be54f6 to
098aeac
Compare
|
|
||
| def test_linux_watchdog(strategy): | ||
| """ | ||
| Check if the system reboots, if we stop feeding the watchdog. |
There was a problem hiding this comment.
| Check if the system reboots, if we stop feeding the watchdog. | |
| Check if the system resets, if we stop feeding the watchdog. |
| """ | ||
| Check if the system reboots, if we stop feeding the watchdog. | ||
|
|
||
| The watchdog is handled by systemd, so stopping systemd should reboot the DUT. |
There was a problem hiding this comment.
| The watchdog is handled by systemd, so stopping systemd should reboot the DUT. | |
| The watchdog is handled by systemd, so stopping systemd should reset the DUT. |
| index, _, _, _ = strategy.console.expect( | ||
| ["STM32 RCC reset reason WDG", TIMEOUT], | ||
| timeout=30, | ||
| ) | ||
| if index != 0: | ||
| raise Exception("Device failed to reboot in time.") |
There was a problem hiding this comment.
What's the benefit compared to..
| index, _, _, _ = strategy.console.expect( | |
| ["STM32 RCC reset reason WDG", TIMEOUT], | |
| timeout=30, | |
| ) | |
| if index != 0: | |
| raise Exception("Device failed to reboot in time.") | |
| strategy.console.expect("STM32 RCC reset reason WDG", timeout=30) |
..?
| 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
| 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 | |
| finally: | |
| # Let's switch the TAC off, so it reaches a well defined state | |
| strategy.transition("off") |
..and drop the from lxatacstrategy import Status.
| 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() |
There was a problem hiding this comment.
The upstream BareboxRebootStrategy does this a little different: https://github.com/labgrid-project/labgrid/blob/f63dfd70a5da2c7007ee8c320fa969df2c0bf16e/examples/strategy/bareboxrebootstrategy.py#L95
| assert 10 <= data["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] <= 70 | ||
|
|
||
|
|
||
| def test_linux_watchdog(strategy): |
There was a problem hiding this comment.
Nothing makes sure the device is actually in the shell state.
No description provided.