2
  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 ?

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
deimus
  • 9,565
  • 12
  • 63
  • 107
  • 1
    This might be a stupid question, but: you are running your code with different inputs every time, right? – Mat Oct 28 '11 at 08:10
  • Actually it increases the execution count for each line ... but what is for the Hit section ??? – deimus Oct 28 '11 at 08:45
  • I execute without any input ... what is the case with inputs ? Shan't they summarized ? – deimus Oct 28 '11 at 08:45
  • 1
    If you run your program with the same (or no) input, the code path followed will be the exact same one every time unless you have time-dependent behavior, use random values or some other source of external data that may vary (or buggy/undefined behavior code). That's expected, the coverage output should be 100% identical for all runs if the global input set is fixed. – Mat Oct 28 '11 at 09:07

1 Answers1

2

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.

Michel
  • 2,523
  • 2
  • 17
  • 14