4

I am trying to generate code coverage report using lcov from home directory. Sorce code is compiled with -coverage option to generate coverage information at compilation time(gcno files are created). Then I have copied the executables and gcno files to home directory.I am trying to check if by ./exe in home directory ,is it possible to generate coverage report.I run the executables in /home and its showing test cases passed but it was discovered that the .gcda files are not created.

I add the following CPP flag: -fprofile-dir= “/home” and hence run the executable but still .gcda is not created . 

Where I need to specify the path so that it will take .gcno files from home directory and generates the .gcdo files in the current directory??

2
  • Can we have have an option to specify the different dirctory or to use the current dirctory at the run-time?I have set the env variables ,but not getting the desired output. Commented Jul 19, 2018 at 11:52
  • Hi himshikha, I'm new to gcov and lcov. Trying to generate coverage report for modules with gtest which are built with Android.mk and Android.bp. Either of the way is not working for me. Could you please help me on this blocker. Commented Jan 29, 2019 at 7:25

2 Answers 2

4

This can be done using GCOV_PREFIX and GCOV_PREFIX_STRIP

Please, refer to the documentation: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html

Regards Thomas

Sign up to request clarification or add additional context in comments.

9 Comments

@Thomas I have set those env variables but its regenerating .gcda files for all other modules.I have .gcno files for a particular module ,while executing the test case for that specific modules,its creating .gcda +.gcda files from other modules too.
have you removed the previous gcda files? before relaunching the test? If the gcda files already exist even if your test will no go through all the gcno files, your gcda files will not be removed...
yeah,all the previous gcda files were removed
This mean that your tests goes through all modules, if you want to cover a single module, the easiest way is to remove all gcno file from other modules. Then, you'll have the coverage for one module..
ok. But what's the purpose of an image displaying text in lcov?
|
2

Maybe, you're compiling more than one module, have you checked the dependencies between modules? Please do this:

  1. compile all your code,
  2. then remove the useless .gcno files. (Gcno are generated at compilation time)
  3. Execute your tests (gcda should be created matching gcno files)
  4. Generate your report

Second possibility:

  1. Compile your code
  2. Execute the tests
  3. Remove useless gcno + gcda files
  4. Generate your report

Others: I guess you can use some options to generate report for a dedicated module, but I'm not very familiar with those options.

Regards

1 Comment

Hi Thomas, Could you please share me some sample project or module or reference link to generate coverage step by step in AOSP ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.