ctest for embedded

is it possible to program microchip, then connect and run tests (collect results over uart, usb, bluetooth, etc.)?

are there points I can hook into to make it work?

i have a bunch of projects and most have libraries, was hoping i can run all tests (or subset) by using ctest as i moved to cmake build. don’t want to write stuff from scratch.

1 Like

Hello, Pavel!

Yes, you may try add_test(NAME <name> COMMAND <executable>) with launching the proper executables.
Usually that command is wrapped by helper macro for auto-registering some test sets;

1 Like

There is also the variable CMAKE_CROSSCOMPILING_EMULATOR, which if it is set and CMAKE_CROSSCOMPILING is on, that string will be prepended to every test command. So basically, you can use this to make it so that you can properly handle tests for crosscompiling, but run them normally without any emulators or whatever if you’re not crosscompiling. (This may be less of a concern if your project is embedded-only.)

Typically I would set CMAKE_CROSSCOMPILING_EMULATOR to something like wine, but you can also set it to the path of a script to do any custom startup/teardown logic you need, such as copying the cross-compiled executable over to the target system, executing it there, doing any cleanup, and reporting the results back to the host system.


this has no effect on how tests are run. still wants to run file directly. :frowning:

set(CMAKE_CROSSCOMPILING_EMULATOR "${CMAKE_CURRENT_LIST_DIR}/stm32_test_runner_bin/stm32_test_runner.exe")

you should not direct call your cross target!
see using cross emulator with custom target and ctest

1 Like