Closed Jeling-W closed 3 months ago
If I understand your environment: I think that we do exactly this, successfully. (Build coverage-instrumented shared library, use that library in a bunch of executables - generate unified coverage report across all the executables and all the tests.)
Maybe try to walk before you run:
GCOV_PREFIX
?
Why do you think you need GCOV_PREFIX
(there are valid reasons to use it - just wondering if your case is one of them).GCOV_PREFIX
?I guess you know that the runtime coverage data (the .gcda files) are generated only after running your executable - and only if it exits normally. Is the code missing from your data actually used/linked in your test executable? Did your tests run?
You did not mention platform or tool versions.
You are more likely to get a useful answer if you provide a small testcase that exhibits the issue you are seeing.
Thank you for your reply.
But there is no corresponding /data/source.cpp for /data/source.gcda, I confirm that both test1.cpp and test2.cpp have called functions in source. cpp.
I guess you realize that this is a compiler/toolchain issue - not an lcov issue. You may get better results by asking your question in a clang/llvm group. You will also get better results if you include a small testcase - or even a large testcase - which illustrates the issue you are seeing. Ideally, such a testcase would include a small handful of source files and a makefile or shellscript which builds your example application, runs your tests, and then indicates which data is missing. Without such an example, it is impossible to know what you did - maybe there is a problem in your setup, you used wrong parameters - and impossible to know what happened.
I do not know how -fprofile-dir
and GCOV_PREFIX
interact. We use one or the other - not both (the former to use the 'llvm profile' coverage data flow, and the latter to use the 'gcov data' coverage flow).
I suggest to start with a small example and build up slowly until you see an error that looks like what you see with your actual application - then you can either debug the issue, or include the example when asking for help. One possible "building up" sequence is:
and
lib`, one source file in each..o
and explicitly link them - say, with --coverage
(gcov flow) and with -fprofile-instr-generate -fcoverage-mapping
(profdata flow).i
Does coverage data get generated as you expected (say, with and without GCOV_PREFIX, with and without profile redirection)?lib
directory into a static library (ar -o libstatic.a ...
) - then link that with the .o from the src
directory and run the experiments again.
Did coverage data get generated as you expected?
lib
directory into a shared library - then link that with your .o, and see if coverage data gets generated as you expected.Gradually make your small testcase look more and more like your actual application as you try to make your testcase fail.
If the above sounds like too much work and too much schedule uncertainty: consider hiring a consultant who is expert in this field.
Closing this issue now. There has been no update in a while, and no indication what the issue(s) were in the first place - nor how to reproduce.
If there is still a problem, please reopen this issue or file a new one. Please include a testcase which exhibits the problem and/or include a detailed description of what you tried to do and what happened.
Hi, I want to generate the coverage of module name1. There are multiple cpp files under name1/, where name1/test/ is the test script for name1. The settings in name1/Android. bp are as follows:
The content in name1/test/Android. mk is as follows:
Set _export GCOV_PREFIX=/data/ export GCOV_PREFIXSTRIP=1 on the testing machine. After successfully running the test, only gcda files were generated under name1/test/, but other files under name1/did not have gcda files generated