Testing strategy and coverage¶
Maintainer note: this strategy doc is intentionally long-lived and should be updated when CI gates, test layers, or extension priorities change.
This document explains how abicheck is tested, why the current test layout exists,
and where coverage expansion should go next.
Testing strategy¶
abicheck uses a layered testing strategy:
- Fast deterministic gate (unit/component)
- Marker selection:
not integration and not libabigail and not abicc and not slow - Purpose: protect core logic and user-facing behavior on every PR with low runtime cost.
-
Includes checker logic, report serialization, suppression rules, CLI command behavior, dumper orchestration via mocks, and DWARF helper edge cases.
-
Integration confidence layer
- Marker selection:
integration - Purpose: validate real toolchain interactions (castxml, gcc/g++, ELF/DWARF parsing) against realistic examples and negative scenarios.
-
Includes end-to-end cases under
examples/, ELF integration parsing, and failure-path tests (bad ELF, broken headers, missing symbols). -
External parity layer
- Marker selection:
libabigailandabicc - Purpose: compare selected behavior against
abidiffandabi-compliance-checkerto reduce semantic drift and catch interpretation mismatches in ABI diagnostics.
This split keeps PR feedback fast while retaining deeper compatibility checks in dedicated jobs.
Coverage model and CI gate¶
Coverage is measured for the abicheck package with branch coverage enabled.
The fast CI gate enforces a threshold and publishes coverage.xml for inspection.
Current CI command:
pytest tests/ -v --tb=short \
-m "not integration and not libabigail and not abicc and not slow" \
-n auto --dist worksteal \
--cov=abicheck --cov-report=term-missing --cov-report=xml --cov-fail-under=80
The 80% line+branch floor is enforced only on the Linux unit-test lane — macOS and Windows skip the Linux-only ELF/DWARF tests, which structurally lowers their coverage, so those lanes run without the fail-under gate.
Test markers¶
| Marker | Needs | When to run |
|---|---|---|
| (default) | Python only | Always — fast, no external deps |
integration |
castxml + gcc/g++ | When modifying DWARF/ELF parsing |
libabigail |
abidiff + gcc/g++ | Parity testing |
abicc |
abi-compliance-checker + gcc/g++ | Parity testing |
msvc |
MSVC cl.exe (Windows) |
MSVC+PDB end-to-end lane |
slow |
varies | Hypothesis/perf benchmarks |
golden |
golden files | Snapshot tests — run when changing output format |
Why this gate shape¶
- Keeps gating stable and deterministic (no dependency on optional system tools).
- Provides a practical signal for regressions in high-change code paths.
- Leaves integration/parity variance to dedicated jobs where failures are easier to diagnose.
Test components by responsibility¶
1) Core ABI diff semantics¶
- Files like
tests/test_checker.py,tests/test_negative.py,tests/test_detector_contracts.py. - Validates change classification and verdict priority (
BREAKING,COMPATIBLE,COMPATIBLE_WITH_RISK,API_BREAK, etc.).
2) Data model/reporting/serialization¶
- Files like
tests/test_reporter.py,tests/test_sarif.py,tests/test_serialization.py. - Ensures machine and human outputs remain stable and parseable.
3) CLI behavior and UX contracts¶
tests/test_cli_phase1.py,tests/test_cli_unit.py,tests/test_cli_new_features.py.- Covers command success/failure flows, warning messages, output writing, and exit codes.
4) Dumper orchestration contracts¶
tests/test_dumper_phase1.py.- Covers no-header fallback behavior, castxml/parser wiring, and error propagation.
5) DWARF helper and parser edge cases¶
- dedicated DWARF regression tests,
tests/test_phase3_dwarf_helpers.py. - Covers nuanced DWARF forms (reference resolution, location decoding, packing/alignment, calling conventions, helper fallback behavior).
6) Real-world integration and parity¶
tests/test_abi_examples.py,tests/test_elf_parse_integration.py,tests/test_integration_phase2_negative.py,tests/test_abidiff_parity.py,tests/test_abicc_parity.py,tests/test_abicc_full_parity.py,tests/test_sprint7_full_parity.py,tests/test_sprint10_abicc_parity.py.- Exercises realistic binaries, toolchain outputs, and compatibility expectations.
Generated ABI edit corpus coverage¶
The generated edit corpus (tests/_edit_corpus_*.py: semantic edit operators
× seeds × configurations, run in PR, nightly and weekly tiers) reports two
separate coverage measures. Both are computed by
abiforge/coverage.py; every corpus cell writes a record when
ABICHECK_EDIT_CORPUS_COVERAGE_DIR is set, and
python -m abiforge.coverage report DIR... aggregates records into
a JSON report and a step summary (integration.yml for the PR tier,
edit-corpus-tiers.yml per shard and for the merged tier).
ChangeKind coverage. The denominator is the ChangeKinds one Linux ELF
shared library with DWARF and public headers can show. SCOPE_BUCKETS is that
partition as data: named buckets (by prefix or name) exclude PE/COFF, Apple,
Python/NumPy/wheel packaging, SYCL, kernel-module ABI and multi-library bundle
kinds, compile-mode switches only L3 compile commands carry, ELF header facts
no x86 build can change, executable-only and PE/Mach-O version facts,
STT_COMMON (never in a linked library) and kinds judged against a declared
deployment floor, and include the source-taxonomy kinds a header alone shows (concepts,
public typedef targets, header-only functions); module buckets take the rest of
each taxonomy module (symbols/types/platform in, build/source and the
source graph out — L3–L5 evidence). Macro, constexpr and default-argument
values stay out: abicheck reads them only from L4 sources, and the corpus gives
at most headers. Every kind is in exactly one bucket
(test_every_kind_is_in_exactly_one_scope_bucket), and every report lists the
buckets with their counts and reasons.
- Declared: an operator requires the kind (
expected, or anany_ofgroup of one) under some rule. A member of a largerany_ofgroup accepts a cell but is not declared on its own: one alternative may be a kind no cell can produce (abicheck always reports its sibling, as with the DWARF layout diff'sSTRUCT_*twins of theTYPE_*kinds). Computed from the operators alone. - Verified (per tier): a cell expected the kind, abicheck produced it, and the cell reconciled to a passing class. A strict-xfail (known) cell, a skipped cell and an unobservable cell verify nothing. A kind abicheck produced that the cell did not expect is listed separately, per tier with its cell count, as produced but not expected — a possible false positive or a missing expectation, never coverage.
abiforge/coverage_ledger.json is the ratchet:
tests/test_edit_corpus_coverage.py fails when a declared kind stops being
declared, when a new declared kind is not written down
(python -m abiforge.coverage ledger --write), or when a floor names
a kind no cell can verify. verified_floor[tier] holds the kinds a tier
verified when it was raised (report DIR --raise-floor TIER); a run that
verifies less fails --check-floor TIER. Only the merged run (every shard's
records) is held to the floor: a shard alone is reported, not checked, because
a kind its skipped, known-xfail or any_of cells expect may be verified by a
cell in another shard. The integration lane's edit-corpus-coverage job and
the scheduled tiers' report job merge the shards and check; the same check
fails on a covered point the space model calls infeasible (a model bug). Only
tiers with a floor in the ledger can drop (today pr). A space point is
covered only by a (build, consumer) pair that ran: an infeasible or
unavailable pair, and a cell with no execution evidence at all (a non-ELF
host, or the default matrix, which runs no consumers), cover none. Two
tests of one tier that run the same cell (the default matrix and the PR-tier
cells) keep separate records.
Language-space coverage. abiforge/model/space.py models the space
the corpus samples: construct (from the operators' roles and language
features) × language × standard × config feature (baseline, -O2, hidden
visibility, -m32, -fshort-enums, -fpack-struct,
_GLIBCXX_USE_CXX11_ABI=0, -fabi-version, different consumer flags) × build
toolchain × consumer toolchain × evidence level, with the headers level
split by the backend that dumps the headers (headers.castxml,
headers.clang, headers.gcc: Config.header_backend). castxml is the
reference; every PR-tier cell also runs under clang and the native gcc plugin
(ADR-092), and the nightly and weekly tiers draw the backend like any other
axis, so a backend that loses a fact castxml reads fails a cell (or is a
recorded strict xfail) instead of going unseen. A (build, consumer) pair that
cannot work is made infeasible by a PAIR_RULES entry. infeasible()
names why a point cannot be a meaningful cell (concepts before C++20, a C++
construct in C, -fabi-version on clang, std::string under
-fpack-struct, a family that does not target Linux ELF); the generator
refuses the same combinations through the same module. The report gives
covered against feasible points overall and per axis value, and the top
uncovered feasible points ranked by how thinly their axis values are covered.
The edit axis comes from abiforge/model/edit_model.py, which defines
the edit classes from C/C++ layout rules and imports nothing from the
operators. Record layout (struct) is split by member insert or remove ×
head, middle or tail × shifts (another offset or sizeof changes) or
absorbed (padding takes it). Head × absorbed is excluded because a layout
rule rules it out, and a test checks that against the Lean layout table. The
model also has classes for reorder, retype (same layout, grows, shrinks,
alignment only), array bound changes, bit-fields, record-level edits
(including a change of triviality for calls) and rename/cv. Base-class layout (inheritance) is split by base added
(non-virtual or virtual), removed, reordered, made virtual or non-virtual,
resized, or given a new access. A function (function) is split by the part
of its declaration, definition or exporting symbol that changes: each
parameter (added, removed, retyped, indirection, pointee cv, renamed,
reordered, default argument), the return type, variadic-ness, calling
convention, exception specification, attributes, language linkage, inline or
out of line, body imports, overloads, the function set (added, removed,
renamed, declared versus exported), and the symbol's binding, visibility,
version and type. Virtual functions (class_virtual) are split by what the
edit does to the Itanium vtable: a slot appended, inserted, removed or
reordered; a virtual's signature, covariant return, noexcept, purity,
override and final; a method made virtual or non-virtual; an override
added or removed in a derived class; a destructor made virtual or not; the
key function; the vptr appearing or going; a new polymorphic class; and the
vtable/type_info symbol. The three enum constructs (enum,
enum_fixed_underlying, enum_class) share one list (an enumerator
appended, inserted, removed, revalued, swapped, renamed or aliased; the
underlying type and its range; scoping; the enum added, removed or made
opaque), minus what a rule excludes and IMPOSSIBLE_ENUM_EDITS states (no
opaque declaration without a fixed underlying type; a fixed one cannot be
outgrown). A variable is split by its type's size effect, cv, initializer,
TLS, visibility, binding, alignment and version node, and by the object
added, removed, renamed, declared versus exported, or made a C++17 inline
variable; a typedef by retarget (size change, same size, pointee), removal,
rename, addition or a respelling to the same type; a template by a
parameter's default, a parameter added (defaulted or not), removed or
retyped, an instantiation added or dropped, an explicit specialization added
or removed, and a template argument type renamed. A class with no C
spelling (an overload, a scoped enum, an inline variable, an
alias-declaration) has no C points. Each class an older operator did not
generate has a probe in abiforge/model/probes.py and an operator in
abiforge/operators/ (vtable, enums, variables, aliases). An
operator whose role is a carrier for another construct
(a variable or record added beside the seed's functions, a rebuild with
other flags) is placed by OP_CONSTRUCT instead of by its role. Every other
construct has the single class any. OP_EDIT_CLASS in abiforge.model.space maps each operator of a
split construct to its class. It may only name model classes, and an
operator it does not place fails tests/test_edit_corpus_edit_axis.py.
Every model class is in the denominator, whether or not an operator generates
it. A class with no operator is an explicit gap: the summary lists it as
none (gap), and the ledger's edit_classes_without_operator records it
(ledger --write regenerates that list, and ledger fails while the list is
stale). To close a gap, add an operator and place it in OP_EDIT_CLASS. Do
not remove the class from the model.
What these numbers do not mean:
- A verified ChangeKind is not proof that abicheck reports that kind for every edit that should produce it; one cell under one configuration verified it.
- A covered space point means a cell ran there, not that abicheck was right there (mismatches are the corpus test's own result) and not that every edit of that construct ran. Ten constructs are split by the edit model's classes, but the others (unions, header constants, TLS objects, link and compile options, and the rest) are not split, so their individual edits are still not counted, and a class's points are covered by one operator, not by every layout that class can land in.
- The space holds only the corpus's own axes. Architectures beyond
-m32, other operating systems, link order and real-world library shapes are not in the denominator, so 100% would still not be "all of C/C++". - Declared coverage is a property of the operator table; only verified coverage says abicheck did anything.
7) Architecture conformance¶
tests/test_architecture_conformance.py,tests/test_changekind_completeness.py,tests/test_changekind_coverage.py.- Validates structural invariants: module boundaries, ChangeKind classification completeness, and policy set consistency.
Extension roadmap (next improvements)¶
The main strategy now is depth over breadth: extend tests where defects are most likely and costly.
- DWARF fixture corpus (high value)
- Add curated binary fixtures (or generated test inputs) for tricky DWARF producer/output variants (compiler versions, attribute forms, typedef nesting patterns).
-
Goal: reduce parser regressions when toolchains differ.
-
Dumper internals: cache/process paths
- Expand tests around castxml cache key/path behavior and subprocess failure modes (timeouts, malformed XML, partial outputs).
-
Goal: increase resilience of snapshot generation in CI and local automation.
-
CLI integration contracts
- Add more command-level tests for multi-output formats and failure diagnostics in
comparescenarios. -
Goal: keep user-facing behavior stable for CI consumers.
-
Integration matrix enrichment
- Add targeted C/C++ examples for edge ABI patterns not yet represented.
-
Goal: improve confidence that algorithmic changes match real binary behavior.
-
Threshold ratchet policy
- Raise
--cov-fail-underonly when sustained improvements are merged and stable. - Keep ratchets incremental to avoid churn from unrelated PRs.
Practical contributor workflow¶
- Pick one under-tested surface (DWARF helper, dumper path, CLI branch).
- Add at least one happy-path and one failure-path test.
- Run lint + fast gate locally.
- If coverage meaningfully improves and remains stable, propose a small threshold bump.
This keeps quality improvements continuous without making routine development fragile.