CI testing with platformio with one build

49 views Asked by At

Hey I would like to get someones either solutions or opinions on how I can make the following both more scaleable and flexible for CI with platformio. The code is cpp.

We are using platformio to flash firmware onto ESP32-S3 units where we have some unit test using UNITY. Each test is seperated into their own files in a folder with the test name i.e

└── test 
    ├── test_a/
    │   ├── test_a.h
    │   └── test_main.cpp
    └── test_b/
        ├── test_b.h
        └── test_main.cpp

The test should all be run with certain triggers from gitlab, which works fine. This constitutes two jobs, one where we would like to build the test using the gitlab docker in docker which produces, with "pio test", a .bin file. The other job, which is a local raspberry pi that has some test units connected, then takes the .bin file and flashes it onto theese units such that we have ensured that the new firmware does not create errors.

The problem however is that when you use platformio in this way, it produces one firmware.bin file for each test_main.cpp which is then overwritten when the next test is build, i.e test_a is build creating a .bin file that can be flashed, test is run and when test_b is build the .bin file is overwritten. We would prefere to just create one .bin file that has all the test in it but there does not seem to be a satisfying solution to this.

What we do now to mitigate this is to make one test_all.h file that imports all other .h files which has a coresponding test_main.cpp file. The reason for why this is not a satisfying solution is:

  1. All tests must use different named functions and can no longer be an intuitive shouldBeValueChanged() or the like

  2. Test configurations should be put into a different file such that there is no confliction (I have seen two test.h files that can not be imported together since it makes the ESP crash, I have yet to look into what the conflict really is but it does mean you need to make future test carefully)

  3. when a new test is made the test_all.h file should be updated as well, or the test is not run in the full assembly, which is prone to human error like forgetfulness

Does anyone have a better solution? Sadly due to time constraint we cannot move aways from using platformio so it must be atleast compatible with it

0

There are 0 answers