4

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.

bitoiu
  • 6,893
  • 5
  • 38
  • 60
Jai
  • 51
  • 1
  • 5
  • Did you figure this out? – ksl Aug 20 '14 at 11:19
  • Could it be failing to find the source files? See the answer I posted relating to a similar problem I was having. http://stackoverflow.com/q/25403165/820657 – ksl Aug 26 '14 at 11:12

5 Answers5

2

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?

Kevlar
  • 8,804
  • 9
  • 55
  • 81
  • I'm having the same problem. If I try your suggestion that I get the following output: ------------------------------------------------------------------------------ GCC Code Coverage Report Traceback (most recent call last): File "/usr/local/bin/gcovr", line 1972, in print_text_report(covdata) File "/usr/local/bin/gcovr", line 822, in print_text_report OUTPUT.write("Directory: "+options.root+"\n") TypeError: Can't convert 'NoneType' object to str implicitly – ksl Aug 20 '14 at 11:18
  • 1
    ksi, I found that outputting XML (`-x`) instead of the default tabular format would succeed when otherwise I'd get that error. – pr1001 Nov 03 '14 at 22:09
2

I had this problem when I try to run gcovr but different (from compile) gcc version was enable. While you are running gcovr, try to check if your gcc version the same as gcc version while compiling your project.

Nir Peretz
  • 21
  • 1
0

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

0

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/"

0

You can copy gcda and gcno files and trigger gcovr from anywhere as long as you provide path to sources in filter option and path to gcda and gcno in root option. Without explicit filter option set it points to the same directory as the root option, but this directory may not contain sources in your case.

I have checked it with absolute paths and it worked well.

mcz
  • 1
  • 1