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,

0

There are 0 best solutions below