Skip to content

Rust insta based tests - #210

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

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

Conversation

@sriramster

@sriramster sriramster commented Jul 29, 2026

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 aarch32-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 Outdated
Comment thread .github/workflows/build.yml Outdated
Comment thread qemu-tests/tests/tests.rs Outdated
#[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

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 still like to see this, but I think I'm going to merge this as-is and work on that as a follow-up. Basically the existing #[test] will stay, but as a non-test function, and we can add a bunch of #[test] functions that call it, setting the parameters for the test as appropriate.

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.

@jonathanpallant Could you check the last push, i've reworked the infra a bit by using libtest_mimic crate. This now satisfies the comment and enables running of target specific tests

Sriram Raghunathan added 3 commits August 2, 2026 14:13
Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
* Move back to older style target based invocation of tests.
* Allow user to run target specific insta tests.
* Adapt test framework accordingly.

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

Copy link
Copy Markdown
Author

@jonathanpallant Please have a look when you've time. Hopefully I've address most of the comments in one way or the other.

tests. And control the execution with libtest_mimic addressing the
review comments

Signed-off-by: Sriram Raghunathan <sriram@hcoop.net>
@sriramster
sriramster force-pushed the rust_insta_based_tests branch from f299118 to 988e18e Compare August 5, 2026 05:03
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