Implementation:ClickHouse ClickHouse Coverage
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Testing, Instrumentation |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Code coverage instrumentation that collects execution data for test analysis.
Description
Implements custom coverage collection using LLVM sanitizer callbacks. Maintains arrays of executed addresses and provides APIs to retrieve current and cumulative coverage.
Usage
Use for measuring test coverage, implementing coverage-guided fuzzing, or analyzing code execution patterns.
Code Reference
Source Location
- Repository: ClickHouse
- File: base/base/coverage.cpp
- Lines: 1-175
Signature
void dumpCoverageReportIfPossible();
#if defined(SANITIZE_COVERAGE)
std::span<const uintptr_t> getCurrentCoverage();
std::span<const uintptr_t> getCumulativeCoverage();
std::span<const uintptr_t> getAllInstrumentedAddresses();
void resetCoverage();
#endif
Import
#include <base/coverage.h>
Usage Examples
#include <base/coverage.h>
// Reset coverage counters before test
resetCoverage();
// Run test code
run_test();
// Get coverage data
auto coverage = getCurrentCoverage();
for (uintptr_t addr : coverage) {
// Process covered address
}
// Dump coverage report
dumpCoverageReportIfPossible();
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment