Skip to content

Conversation

astapleton
Copy link
Member

This allows running unit tests on a non-linux platform via the cross test command.

This allows running unit tests on a non-linux platform via the `cross test` command.
@astapleton astapleton requested a review from usbalbin August 7, 2025 20:25
@astapleton astapleton marked this pull request as ready for review August 7, 2025 20:25
@usbalbin
Copy link
Member

usbalbin commented Aug 7, 2025

Wow, I had no idea that was a thing!

Would you mind adding some instructions/links in the readme?

@astapleton
Copy link
Member Author

astapleton commented Aug 8, 2025

Wow, I had no idea that was a thing!

Would you mind adding some instructions/links in the readme?

So I'll add generic instructions on how to use cross to test. There is more to it in terms of running aarch64_unknown-linux-gnu on an AARCH64 host (e.g. Mac M1+), but building the image is a little broken in cross at the moment. Hopefully once cross-rs/cross#1636 merges breakages will get picked up in CI.

README.md Outdated

## Running unit tests

First, you'll need to install the `aarch64-unknown-linux-gnu` target to run unit tests.
Copy link
Member

Choose a reason for hiding this comment

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

Why would I need that target specifically? Does x86_64 not work for the tests? Also why would I need to cross compile in the first place for running tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry. That's incorrect. Updated


Running tests with `cross`:

cross test --target x86_64-unknown-linux-gnu --tests --features stm32h503
Copy link
Member

Choose a reason for hiding this comment

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

Judging by the

[target.aarch64-unknown-linux-gnu.image]

line in Cross.toml is there something special to do on that arch?

Copy link
Member Author

Choose a reason for hiding this comment

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

So you can run it on either architecture. That directive in Cross.toml is to allow you to run tests for the aarch64-unknown-linux-gnu in a cross aarch64-unknown-linux-gnu image that is built for arm64 hosts (ie. no cross-compilation), which makes building a lot faster on an arm64 Macs (and probably Windows too). Unfortunately building that cross image for arm64 hosts is currently broken (this PR will fix it I believe: https://github.com/japaric/xargo/pull/349/files), so including instructions for use is kinda awkward. Without that directive, cross will download the aarch64-unknown-linux-gnu image built for x86_64 and run the tests on that, which does involve cross compilation and provides no benefit over running the x86_64-unknown-linux-gnu cross image.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, okay

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add some instructions for building with a guest image that matches the host architecture when it's more accessible with cross!

Copy link
Member

@usbalbin usbalbin left a comment

Choose a reason for hiding this comment

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

LGTM

@astapleton astapleton merged commit 889ebde into master Aug 11, 2025
33 checks passed
@astapleton astapleton deleted the as/add-cross branch August 11, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants