In order to program with the Test Driven Development (TDD) paradigm it is essential to unit test all modules. I use the simple unit test environment Unity. The idea of unit testing is to test all public functions. Static (i.e. private) functions are indirectly tested.
There are two problems with unit testing FreeRTOS code:
- Stubs (test environment) need to be created to mimic the FreeRTOS queue behaviour. I solved this by dividing the run function into two functions and calling them with the testinput for the queues:
static void run(void parameters)
encapsulated in extra function to allow unit testing */
- The problem with the FreeRTOS architecture is that the tasks are based on static functions (the run function). I solved this by using the preprocessor define “-Dstatic=”, which removes the keyword static from the code. This is not an elegant way because 1. the unittest is not run on the orignal code and 2. the static variables inside the functions become non static.
Does anyone know a better solution to this problem?
Thanks in advance of any help