From 4faa1fe22a24fa3f5f15ecac2ffad2e856c9bd46 Mon Sep 17 00:00:00 2001 From: astapleton Date: Thu, 7 Aug 2025 13:24:17 -0700 Subject: [PATCH 1/3] Add cross configuration This allows running unit tests on a non-linux platform via the `cross test` command. --- Cross.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Cross.toml diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..e72ef40 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,13 @@ +# Cross doesn't seem to look for package specific configurations when invoked in a workspace so +# we put the default target in Cross.toml + +[build] +default-target = "aarch64-unknown-linux-gnu" + +# Allow usage of locally built version of the cross docker image that matches the host architecture +# e.g. Building a linux/arm64 image for an AARCH64 host allows native execution of the image. +# Specifying the toolchain for a linux/arm64 image means the correct toolchain is used on that +# platform (it defaults to x86_64). +[target.aarch64-unknown-linux-gnu.image] +name = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main" +toolchain = ["linux/arm64=aarch64-unknown-linux-gnu"] From d4361a1e809ddccffb16365d71478cda13e99abb Mon Sep 17 00:00:00 2001 From: astapleton Date: Fri, 8 Aug 2025 14:44:05 -0700 Subject: [PATCH 2/3] Remove default aarch64 target; add instructions for running cross tests --- .vscode/settings.json | 5 +++-- Cross.toml | 3 --- README.md | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ee1d9cb..5e6ad21 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,9 @@ { "rust-analyzer.cargo.features": [ "rt", - "stm32h503" + "stm32h503", + "async", ], "rust-analyzer.check.allTargets": false, "rust-analyzer.check.targets": "thumbv8m.main-none-eabihf", -} \ No newline at end of file +} diff --git a/Cross.toml b/Cross.toml index e72ef40..e94f60b 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,9 +1,6 @@ # Cross doesn't seem to look for package specific configurations when invoked in a workspace so # we put the default target in Cross.toml -[build] -default-target = "aarch64-unknown-linux-gnu" - # Allow usage of locally built version of the cross docker image that matches the host architecture # e.g. Building a linux/arm64 image for an AARCH64 host allows native execution of the image. # Specifying the toolchain for a linux/arm64 image means the correct toolchain is used on that diff --git a/README.md b/README.md index 59900bf..f66956a 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,20 @@ a number of fantastic resources available to help. - [Rust Embedded FAQ](https://docs.rust-embedded.org/faq.html) - [rust-embedded/awesome-embedded-rust](https://github.com/rust-embedded/awesome-embedded-rust) +## Running unit tests + +First, you'll need to install the `aarch64-unknown-linux-gnu` target to run unit tests. + +If you're on a linux host, you can to run unit tests with `cargo test`. + +If you're not, you'll need to install [`cross`](https://github.com/cross-rs/cross), which is a cross compilation tool. See the `cross` instructions for details of installation and use. Once that is installed, using `cross test` will run the unit tests within a docker image. + +Running tests with `cross`: + + cross test --target x86_64-unknown-linux-gnu --tests --features stm32h503 + +`cross` will automatically download the relevant docker image and install the correct rust toolchain. + ## Changelog See [CHANGELOG.md](CHANGELOG.md). Note: this will be populated once the first crates have been From 997140b9b84d7015f4c7de466e74ddf9fbd036b5 Mon Sep 17 00:00:00 2001 From: astapleton Date: Mon, 11 Aug 2025 10:33:46 -0700 Subject: [PATCH 3/3] Fix incorrect info in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f66956a..0ecf0bb 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,9 @@ a number of fantastic resources available to help. ## Running unit tests -First, you'll need to install the `aarch64-unknown-linux-gnu` target to run unit tests. +If you're on a linux host, you can simply run unit tests with: -If you're on a linux host, you can to run unit tests with `cargo test`. + cargo test --target x86_64-unknown-linux-gnu --tests --features stm32h503 If you're not, you'll need to install [`cross`](https://github.com/cross-rs/cross), which is a cross compilation tool. See the `cross` instructions for details of installation and use. Once that is installed, using `cross test` will run the unit tests within a docker image.