Code coverage - ligurio/openbsd-tests GitHub Wiki

Reasons to measure code coverage

Optimization

GCOV identifies the sections in the code that are heavy executed, using which we’ll be able to focus on optimizing the parts of the code which are executed often.

Identifying dead code

Any code that got compiled but never got executed on any possible scenario can be found using GCOV. Removing such code can help in reducing the memory footprint of the program. This can be vital information for programs running on embedded platforms.

Reliability of testing

The coverage report can help in identifying the gaps in testing. The coverage information can be used for writing test cases to exercise the uncovered area in the code.

Feedback-driven fuzzing

Criteria of testing completion

How-To

Results

References

A more interesting analysis would be to run a series of kernel tests prior to generating the code coverage report. To get a more accurate report, it would also be best to zero out the counters before running the tests: sudo lcov --zerocounters. Then run the series of kernel tests.