Gcovr generates coverage data for 0 files

两盒软妹~` 提交于 2019-12-11 19:05:21

问题


I am setting up code coverage for an iOS application. I am using XCode 5.0.2 and gcovr 3.1 to test and perform code coverage for iOS 7 devices. I initially had issues with .gcda file generation but I followed this blog and resolved the issue.

I have set ‘Generate test coverage files’ to ‘Yes’, ‘Instrument Program flow’ to ‘Yes’ for the Debug module only. I have also set -fprofile-arcs -ftest-coverage for Debug module in ‘Other C Flags’. I have added __gcov_flush() in my app code when application terminates.

Now .gcda files are generating without issues.

I then copy that to my workspace in my Home directory. From the workspace, I try to run code coverage for the application. I execute the gcovr command from the command line, passing –object-directory and gcov command runs for the 252 gdca files I have. In the end I get this output:

Gathered coverage data for 0 files

Please help me in solving the issue. I have spent a lot of time browsing for similar issues but none of the solutions is working out.


回答1:


I haven't tried copying the .gcda files elsewhere, but if I cd to the directory that the gcda files are generated in by default, then run gcovr with no arguments, I get valid results. Perhaps that's what you need to do?




回答2:


gcovr should be executed from the folder where the .gcda and .gcno files exist. And the root path is the folder where the source files(.c or .cpp) exist.

With this, the command looks like something as shown below.

rr-mac:gcdaFolder$ gcovr -r /path_to_C_sourceFiles/ .

For output html file below command works

rr-mac:gcdaFolder$ gcovr --html -o Filename_rp.html -r /path_to_C_sourceFiles/ .

Note: The dot(.) at the end is mandatory




回答3:


For Xcode Coverage results 0 files, you should appoint object-directory with .gcda and .gcno files and your root path should contain the source files(.m .h) when you have a folder such as "Myproject" and all your sourcecode is in that folder, the command looks like this:

gcovr --root="Myproject/." --object-directory = "Build/Intermediates//..//Objects-normal/x86-64/"



来源:https://stackoverflow.com/questions/22712135/gcovr-generates-coverage-data-for-0-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!