-
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?
Conversation
Signed-off-by: Chris Fiege <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The 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 |
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.
| 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.
Choose a reason for hiding this comment
The 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
| assert 10 <= data["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] <= 70 | ||
|
|
||
|
|
||
| def test_linux_watchdog(strategy): |
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.
No description provided.