mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 14:44:42 +00:00
ci: Adapt HIL tests to use RPi (#1493)
This commit is contained in:
parent
3dfea214d4
commit
20c77891d8
81
.github/workflows/hil.yml
vendored
81
.github/workflows/hil.yml
vendored
@ -17,27 +17,23 @@ env:
|
|||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
hil:
|
build-tests:
|
||||||
name: HIL Test | ${{ matrix.target.soc }}
|
name: Build Tests | ${{ matrix.target.soc }}
|
||||||
runs-on:
|
runs-on: ubuntu-latest
|
||||||
labels: [self-hosted, "${{ matrix.target.runner }}"]
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
target:
|
target:
|
||||||
# RISC-V devices:
|
# RISC-V devices:
|
||||||
- soc: esp32c3
|
# - soc: esp32c3
|
||||||
runner: rustboard
|
# rust-target: riscv32imc-unknown-none-elf
|
||||||
rust-target: riscv32imc-unknown-none-elf
|
|
||||||
- soc: esp32c6
|
- soc: esp32c6
|
||||||
runner: esp32c6-usb
|
|
||||||
rust-target: riscv32imac-unknown-none-elf
|
rust-target: riscv32imac-unknown-none-elf
|
||||||
- soc: esp32h2
|
# - soc: esp32h2
|
||||||
runner: esp32h2-usb
|
# rust-target: riscv32imac-unknown-none-elf
|
||||||
rust-target: riscv32imac-unknown-none-elf
|
# # Xtensa devices:
|
||||||
# Xtensa devices:
|
# - soc: esp32s3
|
||||||
- soc: esp32s3
|
|
||||||
runner: esp32s3-usb
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
if: github.event_name != 'workflow_dispatch'
|
if: github.event_name != 'workflow_dispatch'
|
||||||
@ -64,4 +60,59 @@ jobs:
|
|||||||
ldproxy: false
|
ldproxy: false
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo xtask run-tests ${{ matrix.target.soc }}
|
run: cargo xtask build-tests ${{ matrix.target.soc }}
|
||||||
|
|
||||||
|
- name: Prepare artifact
|
||||||
|
run: |
|
||||||
|
# Create the 'tests' directory if it doesn't exist
|
||||||
|
mkdir -p tests
|
||||||
|
|
||||||
|
# Find ELF files in the specified path and move them to 'tests'
|
||||||
|
find "hil-test/target/${{ matrix.target.rust-target }}/release/deps/" -type f -exec file {} + | \
|
||||||
|
grep ELF | \
|
||||||
|
awk -F: '{print $1}' | \
|
||||||
|
xargs -I {} mv {} tests
|
||||||
|
|
||||||
|
# Rename files in 'tests' by removing everything after the first dash
|
||||||
|
for file in tests/*-*; do
|
||||||
|
base_name="$(basename "$file" | cut -d'-' -f1)"
|
||||||
|
mv "$file" "tests/$base_name"
|
||||||
|
done
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: tests-${{ matrix.target.soc }}
|
||||||
|
path: /home/runner/work/esp-hal/esp-hal/tests
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
hil:
|
||||||
|
name: HIL Test | ${{ matrix.target.soc }}
|
||||||
|
needs: build-tests
|
||||||
|
runs-on:
|
||||||
|
labels: [self-hosted, "${{ matrix.target.runner }}"]
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
# RISC-V devices:
|
||||||
|
# - soc: esp32c3
|
||||||
|
# runner: rustboard
|
||||||
|
- soc: esp32c6
|
||||||
|
runner: esp32c6-usb
|
||||||
|
# - soc: esp32h2
|
||||||
|
# runner: esp32h2-usb
|
||||||
|
# # Xtensa devices:
|
||||||
|
# - soc: esp32s3
|
||||||
|
# runner: esp32s3-usb
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: tests-${{ matrix.target.soc }}
|
||||||
|
path: tests
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
export PATH=$PATH:/home/espressif/.cargo/bin
|
||||||
|
for file in "tests"/*; do
|
||||||
|
probe-rs run --chip ${{ matrix.target.soc }} "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ Our Virtual Machines have the following setup:
|
|||||||
- ESP32-C6 (`esp32c6-usb`):
|
- ESP32-C6 (`esp32c6-usb`):
|
||||||
- Devkit: `ESP32-C6-DevKitC-1 V1.2` connected via USB-Serial-JTAG (`USB` port).
|
- Devkit: `ESP32-C6-DevKitC-1 V1.2` connected via USB-Serial-JTAG (`USB` port).
|
||||||
- `GPIO2` and `GPIO4` are connected.
|
- `GPIO2` and `GPIO4` are connected.
|
||||||
- VM: Ubuntu 20.04.5 configured with the following [setup](#vm-setup)
|
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)
|
||||||
- ESP32-H2 (`esp32h2-usb`):
|
- ESP32-H2 (`esp32h2-usb`):
|
||||||
- Devkit: `ESP32-H2-DevKitM-1` connected via USB-Serial-JTAG (`USB` port).
|
- Devkit: `ESP32-H2-DevKitM-1` connected via USB-Serial-JTAG (`USB` port).
|
||||||
- `GPIO2` and `GPIO4` are connected.
|
- `GPIO2` and `GPIO4` are connected.
|
||||||
|
@ -19,6 +19,8 @@ enum Cli {
|
|||||||
BuildExamples(BuildExamplesArgs),
|
BuildExamples(BuildExamplesArgs),
|
||||||
/// Build the specified package with the given options.
|
/// Build the specified package with the given options.
|
||||||
BuildPackage(BuildPackageArgs),
|
BuildPackage(BuildPackageArgs),
|
||||||
|
/// Build all applicable tests or the specified test for a specified chip.
|
||||||
|
BuildTests(RunTestsArgs),
|
||||||
/// Bump the version of the specified package(s).
|
/// Bump the version of the specified package(s).
|
||||||
BumpVersion(BumpVersionArgs),
|
BumpVersion(BumpVersionArgs),
|
||||||
/// Generate the eFuse fields source file from a CSV.
|
/// Generate the eFuse fields source file from a CSV.
|
||||||
@ -127,6 +129,7 @@ fn main() -> Result<()> {
|
|||||||
Cli::BuildDocumentation(args) => build_documentation(&workspace, args),
|
Cli::BuildDocumentation(args) => build_documentation(&workspace, args),
|
||||||
Cli::BuildExamples(args) => build_examples(&workspace, args),
|
Cli::BuildExamples(args) => build_examples(&workspace, args),
|
||||||
Cli::BuildPackage(args) => build_package(&workspace, args),
|
Cli::BuildPackage(args) => build_package(&workspace, args),
|
||||||
|
Cli::BuildTests(args) => build_tests(&workspace, args),
|
||||||
Cli::BumpVersion(args) => bump_version(&workspace, args),
|
Cli::BumpVersion(args) => bump_version(&workspace, args),
|
||||||
Cli::GenerateEfuseFields(args) => generate_efuse_src(&workspace, args),
|
Cli::GenerateEfuseFields(args) => generate_efuse_src(&workspace, args),
|
||||||
Cli::RunExample(args) => run_example(&workspace, args),
|
Cli::RunExample(args) => run_example(&workspace, args),
|
||||||
@ -334,6 +337,47 @@ fn run_example(workspace: &Path, mut args: RunExampleArgs) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_tests(workspace: &Path, args: RunTestsArgs) -> Result<(), anyhow::Error> {
|
||||||
|
// Absolute path of the package's root:
|
||||||
|
let package_path = xtask::windows_safe_path(&workspace.join("hil-test"));
|
||||||
|
|
||||||
|
// Determine the appropriate build target for the given package and chip:
|
||||||
|
let target = target_triple(&Package::HilTest, &args.chip)?;
|
||||||
|
|
||||||
|
// Load all examples and parse their metadata:
|
||||||
|
let tests = xtask::load_examples(&package_path.join("tests"))?;
|
||||||
|
let mut supported_tests = tests
|
||||||
|
.iter()
|
||||||
|
// Filter down the examples to only those for which the specified chip is supported:
|
||||||
|
.filter(|example| example.supports_chip(args.chip));
|
||||||
|
if let Some(test_name) = &args.test {
|
||||||
|
let test = supported_tests.find_map(|example| {
|
||||||
|
if &example.name() == test_name {
|
||||||
|
Some(example.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if let Some(test) = test {
|
||||||
|
xtask::build_example(&package_path, args.chip, target, &test)?;
|
||||||
|
} else {
|
||||||
|
log::error!("Test not found or unsupported for the given chip");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let mut failed_tests: Vec<String> = Vec::new();
|
||||||
|
for test in supported_tests {
|
||||||
|
if xtask::build_example(&package_path, args.chip, target, test).is_err() {
|
||||||
|
failed_tests.push(test.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !failed_tests.is_empty() {
|
||||||
|
bail!("Failed tests: {:?}", failed_tests);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn run_tests(workspace: &Path, args: RunTestsArgs) -> Result<(), anyhow::Error> {
|
fn run_tests(workspace: &Path, args: RunTestsArgs) -> Result<(), anyhow::Error> {
|
||||||
// Absolute path of the package's root:
|
// Absolute path of the package's root:
|
||||||
let package_path = xtask::windows_safe_path(&workspace.join("hil-test"));
|
let package_path = xtask::windows_safe_path(&workspace.join("hil-test"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user