0

I am trying to use gcovr on my linux project and have no luck getting .gcda files for the dynamic library after executing binary.

I have a project called projectA which creates a library called libprojectA.so and the unit test project links libprojectA.so. The main goal here is that I want to see the code coverage of projectA functions invoked from the unit test binary UnitTestExecutable.

I have such a directory structure: Project Structure

This is the steps I followed to call gcovr.

  1. Build projectA with its Makefile

    • Makefile has "-fprofile-arcs -ftest-coverage -fPIC"
    • creates .o and .gcno inside .build directory
    • creates dynamic library libprojectA.so
  2. Build unittest

    • Makefile links libprojectA.so
    • Makefile has "-fprofile-arcs -ftest-coverage -fPIC"
    • creates .o and .gcno
    • creates binary UnitTestExecutable
  3. Execute UnitTestExecutable

    • creates .gcda files inside /unittest/*.gcda
    • it doesn't create *.gcda inside /porjectA/ folder <== this is the problem
  4. Call gcovr gcovr -v -r /projectA/ --html --html-details -o test-html-details.html --object-directory=/projectA/.build/

    Here it complains that it can't find *.gcda inside /projectA/.build/

Could someone please help ?

Thanks,

takanoha
  • 183
  • 4
  • 17
  • Please don't use screenshots if you have text. Then I'd like to ask you for a [example]. You don't want us to waste time writing all these files by hand, do you? Did you check if the generated gcda files include those for your library units, just in the "wrong" directory? – the busybee Oct 17 '19 at 08:58
  • If no .gcda for the ProjectA files were created, that would mean that none of libprojecta's code was executed. This can happen e.g. with header-only libraries. If that's not the case, most likely you oversimplified the scenario and accidentally omitted some relevant details. – amon Oct 17 '19 at 15:05

0 Answers0