Getting started
Quickstart
This test runs against hardlabs/demo-board, which every account has. It's an STM32F405 with an MCP9808 temperature sensor, an OLED, three LEDs and a button. Its firmware prints the temperature, raises an alarm above 60 °C and takes the button press as an acknowledgement. You need the SDK installed and signed in (see Installation).
Write a test
def test_overheat_raises_the_alarm(hardlabs_board):
board = hardlabs_board
board.wait_for("temp") # the first reading
board.do("temperature-sensor-mcp9808.overheat-75-c") # set the sensor to 75 °C
board.wait_for("ALARM", within=5)
assert board.read("alert-pin")
board.do("button.sw1")
board.wait_for("alarm acknowledged", within=5)Run it
pytest test_demo.py --hardlabs-sim hardlabs/demo-boardWhat happens:
- The hardlabs_board fixture boots the board once for the test session and stops it at the end.
Board.wait_forwaits for a console line.within=5means five seconds of simulated time, however long that takes in real time.Board.doandBoard.readtake the names the board's panels use.Board.controlslists them.- If the test fails, pytest's report includes the console's last lines.
Use your own board
Pass your board's name and the firmware you build:
pytest tests/ --hardlabs-sim company_name/board_name --hardlabs-firmware build/app.elfNext: Loading firmware for bootloaders and raw images, or Using your own test framework if your tests already talk to the device over a serial port.