* Create the `hil-test` package * Add a simple integration test to verify basic GPIO functionality * WIP * feat: Update with esp-hal unification * build: Update dependencies * feat: Add a simple CI workflow test * ci: Avoid using a gh-hosted-runner to build * ci: Remove building bins in gh-hosted-runner * ci: Remove HIL Gpio CI test * ci: Test all the available tests * test: Add spi_full_duplex test * docs: Add documentation * test: Add uart test * style: Remove unused imports * docs: Update wiring, document H2 VM * ci: Enable H2 tests * ci: Add rust-cache action * docs: Document H2 vm * test: Add timeout * ci: Enable ESP32-C3 tests * feat: Add timeouts * feat: Add aes test * ci: Avoid running CI workflow when we change hil-test stuff * test: Remove warnings * feat: Address feedback * feat: Update features names and spi methods * ci: Remove rust-cache action * Update HIL to probe-rs#2292 (#1307) * feat: Update probe-rs/embedded-test to probe-rs#2292 * feat: Remove lib * ci: Use a matrix * ci: Enable ESP32C3 * feat: Add a way to cfg away test for unsuported peripherals * ci: Update trigger conditions * feat: Update pins to make it work on s3 * feat: Changes enabling S3 * feat: Remove log feature * feat: Adapt for rebase * feat: Remove env * feat: enable S3 * chore: Remove todo * build: Pin dependencies * feat: Add target alias * docs: Update readme * fix: Fix traits imports after rebase. Use debug * build: Remove lto * feat: Build tests on release mode --------- Co-authored-by: Jesse Braham <jesse@beta7.io>
3.9 KiB
hil-test
Hardware-in-loop testing for esp-hal.
For assistance with this package please open an issue or start a discussion.
Quickstart
We use embedded-test as our testing framework, which relies on defmt internally. This allows us to write unit and integration tests much in the same way you would for a normal Rust project, when the standard library is available, and to execute them using Cargo's built-in test runner.
Running Tests Locally
We use [probe-rs] for flashing and running the tests on a target device, however, this MUST be installed from the correct revision, and with the correct features enabled:
cargo install probe-rs \
--git=https://github.com/probe-rs/probe-rs \
--rev=b431b24 \
--features=cli \
--bin=probe-rs
Target device MUST connected via its USB-Serial-JTAG port, or if unavailable (eg. ESP32, ESP32-C2, ESP32-S2) then you must connect a compatible debug probe such as an [ESP-Prog].
You can run all test for a given device using:
cargo +nightly esp32c6
# or
cargo +esp esp32s3
For running a single test on a target:
# Run GPIO tests for ESP32-C6
CARGO_BUILD_TARGET=riscv32imac-unknown-none-elf \
PROBE_RS_CHIP=esp32c6 \
cargo +nightly test --features=esp32c6 --test=gpio
- If the
--testargument is omitted, then all tests will be run. - The build target MUST be specified via the
CARGO_BUILD_TARGETenvironment variable or as an argument (--target). - The chip MUST be specified via the
PROBE_RS_CHIPenvironment variable or as an argument ofprobe-rs(--chip).
Some tests will require physical connections, please see the current configuration in our runners.
Running Tests Remotes (ie. On Self-Hosted Runners)
The hil.yml workflow builds the test suite for all our available targets and executes them.
Our Virtual Machines have the following setup:
- ESP32-C3 (
rustboard):- Devkit:
ESP32-C3-DevKit-RUST-1connected via USB-Serial-JTAG.GPIO2andGPIO4are connected.
- VM: Configured with the following setup
- Devkit:
- ESP32-C6 (
esp32c6-usb):- Devkit:
ESP32-C6-DevKitC-1 V1.2connected via USB-Serial-JTAG (USBport).GPIO2andGPIO4are connected.
- VM: Configured with the following setup
- Devkit:
- ESP32-H2 (
esp32h2-usb):- Devkit:
ESP32-H2-DevKitM-1connected via USB-Serial-JTAG (USBport).GPIO2andGPIO4are connected.
- VM: Configured with the following setup
- Devkit:
VM Setup
# Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y --profile minimal
# Source the current shell:
source "$HOME/.cargo/env"
# Install dependencies
sudo apt install -y pkg-config libudev-dev
# Install probe-rs
cargo install probe-rs --git=https://github.com/probe-rs/probe-rs --rev=b431b24 --features=cli --bin=probe-rs --locked --force
# Add the udev rules
wget -O - https://probe.rs/files/69-probe-rs.rules | sudo tee /etc/udev/rules.d/69-probe-rs.rules > /dev/null
# Add the user to plugdev group
sudo usermod -a -G plugdev $USER
# Reboot the VM
Adding New Tests
- Create a new integration test file (
tests/$PERIPHERAL.rs) - Add a corresponding
[[test]]entry toCargol.toml(MUST setharness = false) - Write the tests
- Document any necessary physical connections on boards connected to self-hosted runners
- Write some documentation at the top of the
tests/$PERIPHERAL.rsfile with the pins being used and the required connections, if applicable.