Skip to content

Test harness #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
str4d opened this issue Mar 5, 2023 · 7 comments · Fixed by #57
Closed

Test harness #53

str4d opened this issue Mar 5, 2023 · 7 comments · Fixed by #57
Milestone

Comments

@str4d
Copy link
Contributor

str4d commented Mar 5, 2023

Currently all testing facilities are disabled for the crates in this repo. It makes sense because everything will only run on an actual Flipper Zero, but it does make verification of things tricky.

It would be useful to have a test harness, that runs the test binaries on a connected Flipper Zero. I'm imagining something like the integration tests for the yubikey crate, which require setting a YUBIKEY_SERIAL environment variable in order to run. The test-with crate might also be helpful here, specifically #[test_with::env(FLIPPER_ZERO_SERIAL_PORT)] or something, that can be used to enable at compilation time tests that require a connected Flipper Zero.

@str4d
Copy link
Contributor Author

str4d commented Mar 5, 2023

Ideally the test harness would make it easy to write normal Rust tests that Just Work.™️ What I'm imagining is something like this:

  • We write normal tests, but maybe annotated with #[device_test] or something to trigger the harness.
    • Alternatively, we do everything inside an integration test suite (though that prevents testing internal APIs).
  • The test harness builds a test binary as a Flipper App, that:
    • Runs each test, capturing all panics.
    • Reports the result of each test to the computer over the serial connection.
  • The test harness deploys the test app to the specified Flipper Zero and launches it.
  • The tests run, and results are collected.
  • Once the test is complete, the test harness removes the test app from the Flipper Zero.

@dcoles
Copy link
Collaborator

dcoles commented Mar 5, 2023

@dcoles
Copy link
Collaborator

dcoles commented Mar 5, 2023

I also have a ST-Link USB dongle around somewhere which could be used to catch crashes with the in-circuit debugging feature.

@JarvisCraft
Copy link
Contributor

JarvisCraft commented Mar 6, 2023

It may also be worth looking at something like QEMU (as mentioned in The Embedded Rust Book) for running some tests, at least the ones which don't access periphery (screen, GPIO, iButton, etc). This would probably allow running these tests on CI.

@JarvisCraft
Copy link
Contributor

Also to add to the list os useful links:

@str4d str4d mentioned this issue Mar 17, 2023
@str4d
Copy link
Contributor Author

str4d commented Mar 19, 2023

Okay, #57 now implements on-device unit and integration tests with the kind of usability I was aiming for.

@dcoles
Copy link
Collaborator

dcoles commented Mar 25, 2023

I'm traveling overseas this week, but should be able to take a look in the evening.

@str4d str4d added this to the v0.9.0 milestone May 10, 2023
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 a pull request may close this issue.

3 participants