6

I run gcov tool on some .c files using gcc -fprofile-arcs -ftest-coverage [filenames]. command
But its is very tedious job of supplying file names to this command.
Instead I need help in which I can run gcov tool on a folder which contains all source files.
Is this possible? Please help me out with a solution.

Thanks in advance.

Coding Master
  • 767
  • 1
  • 7
  • 12
  • Follwoing information would help others to provide you better answers: How do you supply other compilation flags? Is there a makefile? if so, just append the CFLAGS. – RRON Jul 01 '16 at 06:18

4 Answers4

7

I ran into the same problem, my project contains ~3000 files. Write a shell script to grab all .c .gcno and .gcda files to a common folder using find exec, then run gcov using the same command. sample:

LOCATION=your_gcov_folder_name
find -name '*.c' -exec cp -t $LOCATION {} +
find -name '*.gcno' -exec cp -t $LOCATION {} +
find -name '*.gcda' -exec cp -t $LOCATION {} +
cd $LOCATION
find -name '*.c' -exec gcov -bf {} \;

run it on your code folder which contains your project.

Venkat
  • 161
  • 2
  • 10
1

[LCOV][1] provides user friendly reports automatically, firstly I would suggest to take a look.

If you really want to use gcov to show coverage data you could try

find . -name "*.cpp" -exec sh -c 'gcov {} -o "$(dirname {})"' \;

this will create gcov files based on your gcno and gcda files.

And usually it is not perfect idea to move gcno/gcda files. It will cause problems with finding source codes.

valbok
  • 321
  • 2
  • 5
1

First of all, the command you have specified in the question is for compiling c/c++ files and instrumenting them for getting coverage generated later at the time of execution.

That command can be used as following too: gcc --coverage g++ --coverage

Note: you must specify the same flag for linking too.

Now about the question, if your question is about compiling multiple files then there are a lot ways for building projects, no matter how complex. You can use automated builds for it.

If your question is about generating coverage report for multiple files then:

You can use gcovr for generating report in various forms just by specifying root directory (directory above src and obj ) with "-r or --root=ROOT" flags. Refer to this user guide.

Answers given by others works too if you really want to use only gcov and nothing else. But in my opinion gcovr meets every purpose that can be fulfilled with gcov(except function level detail, you can get line level details though).

Vikas Tawniya
  • 1,323
  • 1
  • 13
  • 22
0

if you are not getting coverage report try removig

"coverageReporters": [ "text", "text-summary" ],

from file

jest.config.js

Salahudin Malik
  • 398
  • 4
  • 17