c-code-coverage
Example repo that show how to generate code coverage in C with two different methods
- gcov/lcov: gcc/clang instruments the binary that generates a .gcda when the binary is run and lcov can convert to coverage report
- kcov: Used debug symboles to place breakpoints in the binary and collect coverage and generate a coverage report
MacOS
brew install lcov
brew install kcovLinux
apt install build-essential # Be able to compile c code
apt install lcov # Used for gcov/lcov
apt install kcov # Used for kcovBuild with coverage
cd src
make lcov
make kcov # Not working on macOS at the moment for some reasonVSCode
Links
On this page
Languages
Makefile62.7%C37.3%
Contributors
MIT License
Created August 11, 2025
Updated September 29, 2025
