Recently, I need to add unit test to one legacy program.
But in it, there are lots of macros, like
#ifdef CONFIG_XXX
do xxx
#endif
#ifdef CONFIG_YYY
do yyy
#endif
Currently, the generic program path are covered by unit tests. So, I want to add tests to cover the inside macro parts (different program path).
It seems that I need to compile and run my program with certain macros each time, and how to design the composition of macros to cover the program path and reduce compilation times is really not easy.
So, I plan to move all the hardware related code to arch folder, now, macros were moved from c files to makefile, but still need to compile with certain macros each time to get UT work.
Does anyone have experiences on this problem before?
Thanks for your comments.
i think you can just use gcc -D to generate many version of the binary program. compile and run them with a script to do that :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With