Skip to content

ci: gate branch coverage and test every backend - #3

Merged
aajll merged 1 commit into
masterfrom
ci/branch-gate
Oct 14, 2026
Merged

aajll merged 1 commit into
masterfrom
ci/branch-gate

Conversation

@aajll

@aajll aajll commented Oct 14, 2026

Copy link
Copy Markdown
Owner

CI gated only line coverage because three reader retry branches (src/seqlock.c:167,179,207) were reached only when a concurrent writer happened to interleave. This PR reaches them deterministically, builds the never-compiled no-atomics backend, and gates branches at 100%.

  • Retry test: tests/test_seqlock_retry.c, single-threaded.
    • Counter moves during the copy (load and try_load): the output buffer aliases hdr.seq, so the copy itself changes the counter between the reader's two loads.
    • Odd counter on a blocking load: SEQLOCK_CPU_RELAX is replaced with a test hook that completes the pending write. This needs no production code change because SEQLOCK_CPU_RELAX is already overridable.
    • The file is built twice: against the library, and with the hook compiled into its own copy of the core. The hook adds a call to the core's control flow, so gcov numbers that build's branches separately. Each build must reach its own branches, otherwise gcovr reports the library's line-179 branch as missed.
  • Backends: test_seqlock_c11.c becomes test_seqlock_backend.c and runs once per non-default backend (C11 and no-atomics). No-atomics was previously never compiled.
  • CI: --fail-under-branch 100 added to the coverage gate, and the pull_request branch filter removed so stacked PRs get CI.

Evidence

Coverage of src/ + include/, CI configuration (-fprofile-update=atomic), gcovr merged across all builds:

Tests run Lines Branches
Deterministic tests on master 100% 93% (45/48; 167, 179, 207 missed)
Deterministic tests on this branch 100% 100% (53/53)
Full suite on this branch 100% 100% (53/53)

The branch total rises from 48 to 53 because the hooked core and the no-atomics core add their own branches.

Local: ASan/UBSan gcc -Werror 10/10, clang -Werror 10/10, TSan 10/10.

The standards review lists seqlock at 87.2/77 from a local merged run. That run omitted -fprofile-update=atomic, which CONTRIBUTING documents as corrupting branch counts when the concurrent tests run. With the flag, master already measures 100% lines and 100% branches, but only when the concurrent tests happen to cover the retry paths.

The reader retry branches were reached only when a concurrent writer happened to interleave, so branch coverage could not be gated. A single-threaded test now drives each retry deterministically, the no-atomics backend is built and tested alongside C11, and CI gates on 100% branch coverage. The pull_request branch filter is removed so stacked PRs get CI.
@aajll
aajll merged commit 987bbd9 into master Oct 14, 2026
4 checks passed
@aajll
aajll deleted the ci/branch-gate branch October 14, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant