Open brainstorm opened 3 months ago
Hi,
The issue is that avr-tester must be run on your local machine (e.g. x86/aarch64 Linux/MacOS), but having this:
https://github.com/brainstorm/embassy-as5600/blob/avr_tester/.cargo/config.toml#L2
... I think causes the compiler to think it that should compile simavr for avr, which is bound to fail 😅
You should create a separate directory for your firmware and separate directory for your tests, like:
embassy-as5600/firmware
- where you put firmware's Cargo.toml
, .cargo/config
, src/main.rs
etc.embassy-as5600/firmware-tests
- where you put Cargo.toml
referencing avr-tester
, tests/test.rs
etc.Under this structure, running the tests requires entering the firmware
directory, executing cargo build --release
, going into the firmware-tests
directory and running cargo test
there.
Lemme know if that helps!
That makes a ton of sense, thanks for your answer!
I'd like to keep the tests on the same directory as any other "standard" Rust project to reduce DX friction: I do think that cargo [run|build|test] should run transparently across targets and that your simavr
wrapper could benefit from finding out how to pull that off.
I tried naively adding the following in my .cargo/config.toml
:
[test]
target = "aarch64-apple-darwin" <--- my current host target
But of course, the cargo build is targeting AVR anyways with the line you pointed out.
Then I searched a bit and it's a tricky problem with no clear solutions (i.e defmt-test
could work, but unfortunately that just targets cortex-m
, not AVR).
Here are some interesting pointers, I'm not ready to give up and go with the directory split you're proposing... yet :P
https://users.rust-lang.org/t/cargo-test-for-embedded-target-fails/98926
https://nexte.st/book/target-runners.html
https://github.com/rust-lang/wg-cargo-std-aware/issues/72
https://github.com/probe-rs/embedded-test
I'll poke a bit more on this issue, I think it'd be interesting to get it "right" without splitting the project.
Yeah, having more streamlined experience would be better, but I'm out of ideas myself 😅
I've been trying to utilize artifact dependencies as well (https://doc.rust-lang.org/nightly/cargo/reference/unstable.html?highlight=feature#artifact-dependencies), but without any luck.
Hello @Patryk27, thanks for this crate, I was really glad to see there was a
simavr
wrapper for my project:https://github.com/brainstorm/embassy-as5600/tree/avr_tester
But I'm facing some FFI/compile issues before reaching the tests themselves (barebones for now):
I do have all the Ubuntu 23.10 dependencies listed in
simavr-ffi
andsimavr
works fine independently for this project.Before I dig into this more deeply I wanted to ask if you have you seen those errors before or perhaps can spot right away what am I doing wrong?
Thanks in advance!
/cc @jubeormk1