开发者

Unit test on program which has lots of macros

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开发者_JAVA百科 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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜