What is a .lcov file?
text/plain
LCOV is a plain-text code-coverage tracefile format originally produced by the Linux Test Project's front end for gcov and now emitted by tooling across many languages. Records are grouped per source file between an `SF:` line and an `end_of_record` line, with `DA:` lines giving per-line hit counts, `FN:`/`FNDA:` lines covering functions, `BRDA:` lines covering branches, and `LF`/`LH`, `FNF`/`FNH`, `BRF`/`BRH` summary counters.
How to use a .lcov file
Use an example .lcov file to test coverage viewers, merge tools, and CI coverage gates — verifying that summary counters match the detail lines, that multiple source records are merged rather than overwritten, and that branch data survives conversion to Cobertura or JSON.
Download example .lcov files
- Coverage — LCOV Tracefile with BRDA Branch RecordsThe reference LCOV tracefile: one record per source file with FN/FNDA function records, real BRDA branch records (block, branch and taken count, with '-' for a branch never reached) and DA line hits, closed by the LF/LH, FNF/FNH and BRF/BRH counters. Every file in this group describes the same four-file source tree and reports 127/140 lines, 17/24 branch outcomes and 18/20 functions, so a converter can be diffed against a known answer.
- Coverage — LCOV Without Branch RecordsThe same tracefile with every BRDA, BRF and BRH line removed — what a runner emits when branch instrumentation is off. A gate that reads branch coverage from this file must report it as unavailable, not as 0%, or an unconfigured project looks like a badly tested one.
- Coverage — LCOV with Function Records OnlyRecords containing FN/FNDA/FNF/FNH and nothing else: no DA lines, no LF or LH. Merge tools that assume every record ends with LF/LH either crash here or invent a zero line count for a file that simply was not line-instrumented.
- Coverage — LCOV with Two Test Runs Over the Same FilesTwo TN: blocks — a unit run and an integration run — each carrying a full record for the same two source files. A correct merge sums the DA hit counts per line and recomputes LH; a tool that keeps the last record seen throws away the unit run entirely.
- Coverage — LCOV at Zero CoverageEvery instrumented line present with a hit count of zero — the shape of a report from a run in which the tests never loaded the instrumented code. It is not an empty file, and conflating the two hides a broken test harness behind a missing-report warning.
- Coverage — LCOV at 100%Every line hit at least once, so LH equals LF exactly. The upper-bound control for a coverage gate, and the case that catches percentage formatting that renders 100% as 100.0% or, worse, rounds 99.95% up to it.
- Coverage — LCOV with Several TN: Test NamesThree named test runs in one tracefile, each covering a different part of the tree, reported via the TN: record most tools quietly discard. Keeping the name is what lets a report answer which suite covered a given line.
- Coverage — Gate Boundary at 80.00% (meets the gate exactly)A tracefile sitting meets the gate exactly against the 80% minimum in this group's gate config: 112 of 140 lines, 80.00%. 80.00% is exactly the configured minimum, so a > comparison fails the build and a >= comparison passes it — the single most common off-by-one in a coverage gate.
and 3 more in the library.