Skip to content

Rust insta based tests - #210

Open
sriramster wants to merge 5 commits into
rust-embedded:mainfrom
sriramster:rust_insta_based_tests
Open

Rust insta based tests#210
sriramster wants to merge 5 commits into
rust-embedded:mainfrom
sriramster:rust_insta_based_tests

Conversation

@sriramster

Copy link
Copy Markdown

This patch series introduces rust insta based testing framework. The insta framework documentation is available (https://docs.rs/insta/latest/insta/).

  • Patch introduces a new crate for testing named qemu-tests
  • All the older reference folder are removed. And new snapshots are saved under qemu-tests/snapshots
  • Each test runs the binaries in qemu for all the defined targets, and compares the output with .snap files saved.
  • The .snap files needs to be bootstrapped for any new example added. Check justfile for more details on this.
  • The github workflow is updated to pickup these changes.
  • Older tests.sh code is remove as testing is handled by rust internally.

The PR address #138

Sriram Raghunathan added 4 commits July 29, 2026 00:01
This patch series introduces the rust insta crate based testing upgrade.
The insta crate allows for snapshot comparison which is more powerful
than the current bash script based testing framework.

For documentation https://docs.rs/insta/latest/insta/

This patch introduces a new crate named qemu-tests.

* The qemu-tests has a mod named common, which lists the bins available
  in each of the examples
* Once bins are populated, we use rust's command execution from std, and
  call the `cargo run` with specific flags and --bin
* Before validating the test suite needs to be bootstrapped for the
  insta to load the snapshot for comparsion please refer to justfile for
  notes on how to initialize the test suite.

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
… with insta crate

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
…rkflow to use updated test-qemu

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>

@jonathanpallant jonathanpallant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for these changes. I think the proposed solution is going to work well and I left you some thoughts.

Comment thread qemu-tests/tests/common/mod.rs Outdated
Comment thread qemu-tests/Cargo.toml
@@ -0,0 +1,10 @@
[package]
name = "qemu-tests"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe call this 'run-tests'? I don't think there's anything QEMU specific about it, and we might use other runners in future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would rename the environment variables too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

'run-tests' sounded generic, perhaps! Something like 'aarch32-tests' ? Following the other crates aarch32-rt , aarch32-rt-macros.

Does that sound ok?

- test-qemu-v7a-zynq
- test-qemu-v8r
- test-qemu-v8r-el2
- test-qemu-versatileab

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd prefer to leave the justfile target names as they were - if I'm working on something ARMv6 specific I wouldn't want to keep running the tests for the other architectures, even if they run on the same machine.

Comment thread qemu-tests/tests/tests.rs
#[test]
#[ignore = "requires QEMU_TARGET; run via the justfile"]
fn test_examples() {
let target = std::env::var("QEMU_TARGET")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to have one test per target, instead of passing in the target as an environment variable? Then bare cargo test would work, and you'd see:

armv4t-none-eabi   PASS
armv5te-none-eabi  PASS
armv6-none-eabi    PASS
etc etc

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
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