flipperzero-rs / flipperzero

Rust on the Flipper Zero

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test harness

str4d opened this issue · comments

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.

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.
    • This step may block on #43.
  • The tests run, and results are collected.
  • Once the test is complete, the test harness removes the test app from the Flipper Zero.

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

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.

Also to add to the list os useful links:

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

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