Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Add gcov code coverage instrumentation to C/C++ projects
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -28% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -5% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 386% | 0% |
| case-06 | ✓→✓ | = Same ✓ | -9% | 0% |
| case-04 | ✓→✓ | = Same ✓ | -2% | 0% |
Instrument C/C++ programs with gcov to measure test coverage.
bashgcc --coverage -o program source.c
bash./program # Creates .gcda files with execution data
Text report:
bashgcov source.c # Creates source.c.gcov with line-by-line coverage
HTML report:
bashgcovr --html-details -o coverage.html
--coverage (shorthand for -fprofile-arcs -ftest-coverage -lgcov)CFLAGS and LDFLAGSmakefileENABLE_COVERAGE ?= 0 ifeq ($(ENABLE_COVERAGE),1) CFLAGS += --coverage LDFLAGS += --coverage endif
cmakeoption(ENABLE_COVERAGE "Enable coverage" OFF) if(ENABLE_COVERAGE) add_compile_options(--coverage) add_link_options(--coverage) endif()
--coverage to CFLAGS and LDFLAGSmake clean or rm -f *.gcda *.gcnomake ENABLE_COVERAGE=1 or cmake -DENABLE_COVERAGE=ONmake test or ./test_suitegcovr --html-details coverage.html --print-summaryText (.gcov files):
-: 0:Source:main.c
5: 42: int x = 10;
#####: 43: unused_code();5: = executed 5 times#####: = not executed-: = non-executableHTML: Interactive report with color-coded coverage
Target: 80%+ line coverage, 70%+ branch coverage
Other measured skills in the registry, with their headline benchmark lift.