2

I'm in the process of generating coverage information of a c++ application and using gtest for the same, and the C++ application is part of the buildroot build. Got correct coverage information for almost files except header files. So I googled the same and found this link as useful, having said that I didn't get the correct answer. gcov is not generating coverage information for header files From the link, I understood that to obtain "mymoneyaccount.cpp.gcov",execute "gcov mymoneyaccount.cpp", but to obtain "mymoneyaccount.h.gcov", we need to execute "gcov mymoneyaccounttest.cpp". My first doubt is Anyone have an idea why we need to execute the test app to generate the .gcov of header file? Both files include "mymoneyaccount.h"."

My exact scenario is I'm trying to get the code coverage of source files which is located in "Source" folder and the test application is located in the "Test" folder. Please find the folder structure.

  1. Source
    1.1 a
    1.1.1 logic.cpp
    1.1.2 logic.h
  2. Test
    2.1 a
    2.1.1 logictest.cpp
    Both Source and Test are art of Buildroot build system, cross compiled it and run the test in the Raspberry Pi-3. As part of Compilation process, logic.cpp.gcno & logictest.cpp.gcno files were generated in the build PC and as part of execution process in the Raspberry Pi-3, corresponding .gcda files were generated. Copied the .gcda files from the RPi to the corresponding locations in Build PC. Executed the gcov on the .gcno files and get the coverage details. Coverage of logic.cpp.gcov is valid and the .h.gcov in the Test directory is satisfying, were .h.gcov in the Source directory is not. Opened the .h.gcov in the Source dir, it shows line counts with the exact source code(not valid coverage data), but the .h.gcov in the Test dir, shows the line counts with code as /EOF/(hope it shows the valid coverage data). Hope it is clear now. Is any solution to view the content of the .h.gcov in the Test directory as the exact code?. Then only we can ensure that we got a valid coverage data and we can implement more test cases with the remaining code. Thank you.
  • Could you edit your question to include a small `.h` and two `.cpp` files that match your scenario? Not necessarily the full code but just a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that matches what you are describing. This will make it easier to understand and to answer your problem. – Patrick Aug 03 '20 at 12:48
  • I was actually expecting you to show us part of the files that you are dealing with. Also, it would be better to include this new information in your question rather than in the comments. It will allow for better formatting. – Patrick Aug 05 '20 at 02:45
  • @Patrick, Question updated. – user3595318 Aug 05 '20 at 05:13

0 Answers0