Question

  1. I've created simple hello word cpp app.
  2. Compiled it by passing gcc --coverage flag
  3. Executed the executable
  4. Generated coverage by invoking
    lcov --directory . --capture --output-file ic.info
  5. Generated html based report by genhtml
    genhtml -o html/ ic.info

Now the question. No matter how many times I'm running the executable I'm getting always the same result, i.e. the same coverage of lines and functions. Should it increase the line coverage for every execution ? Do I get something wrong ?

If lcov generates coverage only for one execution, then how can I generate coverage for all executions that I've done ?

Was it helpful?

Solution

I guess you misunderstand how the coverage results are generated. lcov is not generating the coverage, as stated in your question. It only processes the coverage results, which are generated when running your program (step 3 in your question).

So, when executing the program multiple times (step 3) your line execution times will increase (not necessary the coverage). To see this you can generated multiple coverage reports (execute step 3,4 and 5 multiple times). You will see an increase in the execution times of lines in your code in the reports generated in step 5.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top