Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/test_linux_hardware.py
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):
"""
Expand Down Expand Up @@ -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):
Copy link
Member

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.

"""
Check if the system reboots, if we stop feeding the watchdog.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Check if the system reboots, if we stop feeding the watchdog.
Check if the system resets, if we stop feeding the watchdog.


The watchdog is handled by systemd, so stopping systemd should reboot the DUT.
Copy link
Member

Choose a reason for hiding this comment

The 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.
The watchdog is handled by systemd, so stopping systemd should reset the DUT.

"""

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# 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
Copy link
Member

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..

Suggested change
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)
Comment on lines +109 to +113
Copy link
Member

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
Comment on lines +114 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.