开发者

How to prevent functions from being excluded from coverage profiling?

开发者 https://www.devze.com 2023-01-22 16:55 出处:网络
We\'re using AQTime\'s coverage profiler to check coverage results for unit tests. It seems to generally work okay, but has a nasty habit of overestimating coverage because some functions don\'t appea

We're using AQTime's coverage profiler to check coverage results for unit tests. It seems to generally work okay, but has a nasty habit of overestimating coverage because some functions don't appear at all. I think this is because the linker has stripped them because they're not called, but obviously it is not ideal because I'd like them to show up as "not covered".

Does anyone know if there's a way to configure either Visual C++ or AQTime such that these functions will be correct开发者_C百科ly tagged as "not covered"?


AQtime gets the list of routines from a module's debug information. Since the linker has stripped some routines, there is no debug information for them and AQtime does not "see" them.

As a rule, all linkers have an option to enable/disable this feature. For example, in a Visual C++ project this option is named References and located under the Linker | Optimization properties group. Remove the value of this option or set it to No (/OPT:NOREF) in your application's Debug configuration and the linker will not remove unused functions. The option is documented here.


Odd. Whether the compiler/linker strips them or not, the fact is, at the end of test execution, there is no record of them being executed. So if the tool can list all the functions, it should have no such evidence, and thus it should report "not executed".

Our SD C++ Test Coverage tool does not have this bizarre behavior, at least not if you actually specify that the containing compilation unit or header file that is part of those that should be instrumented. (You might fail to list ah header file that contains a function body, and that won't then get reported). It will even report that a function, which has been inlined, has been executed, regardless of the number of places it has been inlined.

0

精彩评论

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