admin管理员组

文章数量:1278918

I want to test code coverage of my tests over library L.

Let L::foo() be a function in L that I do not use in my tests.

Therefore the object code of foo() is removed/opted out I think by the linker and is not be part of the test application.

So I end up with higher code coverage and cannot see that foo() is not covered.

I think there is a linker flag that forces linker to include even unused code, or perhaps I can do something else while running code coverage. Anyone knows how to do this?

I am using GCC, gcov on Linux.

I want to test code coverage of my tests over library L.

Let L::foo() be a function in L that I do not use in my tests.

Therefore the object code of foo() is removed/opted out I think by the linker and is not be part of the test application.

So I end up with higher code coverage and cannot see that foo() is not covered.

I think there is a linker flag that forces linker to include even unused code, or perhaps I can do something else while running code coverage. Anyone knows how to do this?

I am using GCC, gcov on Linux.

Share Improve this question edited Feb 25 at 12:43 dwto asked Feb 24 at 23:36 dwtodwto 8054 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

In general you need to remove -Wl,--gc-sections and add -fkeep-static-functions in your coverage build.

本文标签: cHow to prevent unused functions from being opted out by linkercompilerStack Overflow