#2636·embassy

RFC: advanced testing feature

Author: lestofanteCreated Feb 28, 2024Updated Sep 20, 2026

This is an RFC for improving the default testing system, this is based on personal experience and need, but try to remain kiss while providing helper functionality for testing on chip and on development machine. The following is to collect ideas and document what is present, and eventually expand upon it. All that I am describing can potentially be already implemented by someone skilled in rust build system and specific embassy build setup, the idea is to make this accessible (and documented) for everyone as simple as possible

We want to be able to test:

  • application logic, or "business logic", probably a simple bunch of state machines
  • application driver, probably driver for specific sensors and actuator

For the first part, we want a way to specify that a test is gonna be compiled and run on the development machine. Ideally no mocks are required, but:

  • multiple test should able to coexist
  • a test may share file with other test (for example functionality to load recorded data and the actual recorded data)
  • a test could require to include one or more file from the main application (unit and integration test)
  • should be easy to call those test programmatically
  • a test file may generate multiple test (to support conditional compilation)
  • one or more test can be run from command line (just like normal tests)
  • can be parallelized

Possible simple implementation with conditional configuration, the issue is to tell the build system to use a completely different compiler/project setup. While those test could be placed anywhere, suggested to have them under path, relative to project root, "test/software/"

For application driver, our requirement we have all the above plus:

  • a "companion" executable that will run on the developer machine; this companion executable will be given in input the debugger/communication interface. (*1)
  • a "companion" executable that will run on a different target; this companion executable will be given in input the debugger/communication interface. (*2)
  • one or more test can be run from command line (including programming to targets, may need to provide info like debug interfaces and target chips)
  • a target chip can be a "visualized" chip

Again possible simple implementation with conditional configuration; the same trick to support different compiler/project setup could be reused to set up both companion executable. While those test could be placed anywhere, suggested to have them under path, relative to project root, "test/hardware/" where the companion are the same name as the test file, but appending .verifier_sw.rs and .verifier_hw.rs

Possible issues:

  • openocd should be able to support multiple client to the same target, but i wont be surprised if many clients breaks
  • multi target compilation must be first class
  • parallelization if of course limited by the amount of test hw connected to the computer unless virtualized

(*1) The idea is the executable is able to communicate with the chip, and even be able to halt/observe data trough the debugger. Lets imagine I have a debugger and a serial connected to the chip, i should be able to send data trough the serial, and check if the receive buffer is in memory. Of course this mean the debugger interface provide an easy API to add breakpoint, conditional breakpoint, halt, continue, read and write memory areas, depending on the debugger functionality.

(*2) there are test similar to (*1), but require specific timing, or HW capability. Technically this could be implemented with (*1); a second embedded project with multiple tests, the correct one get flesh in the second chip, and the script for that test return to the current test the debug interface, so now we have 2 debug interface, and can literally step the executions of the chips