Definition
Block coverage (also called basic block coverage, BBC) is a code coverage criterion that tracks whether every basic block in a program's control flow graph (CFG) has been executed at least once by a test suite. A basic block is a maximal straight-line sequence of instructions with a single entry and single exit point.
Role in Search-Based Software Testing
Block coverage has been studied as a secondary objective for search-based test generation and crash reproduction:
- Approach-level and branch-distance heuristics used by many search-based techniques only target explicit branches (conditionals, loops) and ignore implicit branchings that occur at runtime, for example when an exception is thrown inside a branchless method.
- A secondary objective called Basic Block Coverage (BBC) was introduced to account for coverage of relevant basic blocks in the CFG, complementing branch-distance guidance.
- Evaluated with DynaMOSA for unit test generation, and with STDistance and WeightedSum fitness functions for crash reproduction, BBC yielded systematic, small (~1.5%) improvements in branch coverage, increased output-domain coverage, higher implicit runtime exception coverage, and greater diversity of runtime states.
- In crash reproduction, combining BBC with STDistance and WeightedSum helped reproduce 3 new crashes per fitness function and significantly reduced reproduction time for 43.5% (STDistance) and 45.1% (WeightedSum) of crashes, cutting time by 71.7% and 68.7% on average, respectively.
Role in Coverage-Guided Fuzzing
In binary-only coverage-guided fuzzing, block coverage granularity is the native level supported by Coverage-guided Tracing (CGT) frameworks such as UnTracer, which achieve orders-of-magnitude throughput gains by activating tracing only when new coverage is guaranteed. Most state-of-the-art fuzzers, however, require finer-grain metrics such as edge coverage and hit counts, which CGT does not directly support. Subsequent work extended CGT to preserve edge coverage and hit counts while keeping near-identical speed to block-coverage-only CGT, outperforming tracers such as QEMU, Dyninst, RetroWrite, and AFL-Clang by 2-24x across 12 real-world binaries.
Role in Hardware Verification (NISA-DV)
Block coverage is also a metric used to evaluate the efficacy of hardware verification frameworks. NISA-DV, a verification framework for RISC-V-based neuromorphic ISA extensions, combines random constrained tests with directed feedback and manually designed directed tests. Compared with random testing using only RISCV-DV, NISA-DV achieved an 8.34% block coverage improvement and a 29.63% toggle coverage improvement on the NeuroRVCore sample neuromorphic processor.