Skip to content
This repository was archived by the owner on Nov 8, 2026. It is now read-only.

test: direct package coverage for differ, loop and mountutils - #44

Merged
aledbf merged 4 commits into
mainfrom
aledbf/package-coverage
Jun 12, 2026
Merged

aledbf merged 4 commits into
mainfrom
aledbf/package-coverage

Conversation

@aledbf

@aledbf aledbf commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Closes the per-package coverage gap in differ, loop and mountutils (+1660 test lines).

Root cause analysis

Most of the "very low" numbers were a measurement artifact: CI runs go test ./... without -coverpkg, so coverage earned cross-package (snapshotter's differ tests drive mountutils.MountAll/MountExt4 heavily) is not attributed. With cross-package attribution, mountutils was already at ~85% average. The genuine gaps were 5 functions at absolute 0% plus Apply at 27%.

Changes

  • mountutils (package: helpers-only → 91.7%): first direct tests for MountAll (plain path with partial-mount unwind, real multi-device EROFS mounts with loop-release verification, sibling guard, loop-failure cleanup), MountExt4 (read-only mount + lock lifecycle, mount-failure resource release) and lockImageFile (flock and QEMU-style OFD conflict branches → ErrFailedPrecondition).
  • loop (78.1% → 81.2%, Detach/GetInfo at 100%): detach idempotence (ENXIO), non-loop/unopenable paths, backing-file lookups incl. the deleted-cwd fallback, read-only/DirectIO setups, serial-based cleanup (skips gracefully on kernels without loop-serial sysfs, like the linuxkit Docker kernel).
  • differ (Apply 27.7% → 76.6%, every 0% function covered, package 78.9%): in-package tests for tar and native-EROFS Apply (incl. copyBlobAtomic error cleanup), stacked-layer overlay merging (newest-wins), multi-device fsmeta mounts, ext4-only upper routing + root-entry warnings, active-snapshot overlay with whiteouts, label semantics, and all compressor error branches.
  • task coverage: new target running the root suite in Docker with -coverpkg=./internal/... for honest cross-package numbers locally.

Final per-package coverage (Linux root run)

package before after
mountutils ~7% (helpers only) 91.7%
loop 78.1% 81.2%
differ ~55% 78.9%

All root tests verified in the privileged Docker image (mkfs.erofs/mkfs.ext4/loop devices); no loop or mount leaks (asserted per test). Lint clean on golangci-lint 2.11 and 2.12.

Follow-up needing maintainer approval

Adding -coverpkg=./internal/... to the CI coverage invocation in ci.yml would make codecov report attribution-correct numbers (snapshotter currently gets no credit for the mountutils/differ paths it exercises). One-line change, left out because CI workflow edits require explicit approval.

🤖 Generated with Claude Code

aledbf and others added 4 commits June 12, 2026 15:08
…geFile

The package's mount paths were exercised only cross-package from
internal/snapshotter tests, which doesn't count toward this package's
coverage and left regressions invisible in per-package reports. Add
root-gated in-package tests: plain mount.All path with partial-mount
unwind, real multi-device EROFS mounts (two mkfs-built layers merged into
an fsmeta) with loop-release verification, the sibling-mount guard, loop
setup failure cleanup, read-only ext4 mounting with lock lifecycle, and
both VM-in-use detection branches (flock and QEMU-style OFD locks).

MountAll 0% -> 87.5%, MountExt4 0% -> 85.0%, lockImageFile 0% -> 86.7%;
package 91.7%.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
FindBySerial had no coverage at all; Detach/DetachPath/GetInfo error and
already-detached paths were untested. Add tests for double-detach (ENXIO),
non-loop files (ENOTTY), unopenable paths, detached-device GetInfo,
backing-file lookups (hit and miss, including the deleted-cwd
filepath.Abs fallback), read-only and DirectIO setups, and serial-based
cleanup (skipping gracefully on kernels without loop serial sysfs support,
like the Docker test kernel).

Package coverage 78.1% -> 81.2%; Detach and GetInfo at 100%.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Apply and every with*Mount helper were exercised only from
internal/snapshotter tests. Add in-package tests: Apply tar conversion
(uncompressed and gzip) and the native EROFS copy path (copyBlobAtomic
incl. read-error cleanup), stacked per-layer EROFS mounts merged via
read-only overlay (newest-wins asserted), multi-device fsmeta mounts built
with the exact generateFsMeta invocation, ext4-only upper routing (diff
root is upper/, never the raw ext4 root) including the
unexpected-root-entries warning and the empty-upper case, the active
snapshot overlay with whiteout handling, ensureUncompressedLabel update
semantics, and all writeCompressedDiff compressor error branches.

Apply 27.7% -> 76.6%; all previously-0% functions covered; package 78.9%.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
'task coverage' runs the root test suite in Docker with
-coverpkg=./internal/..., so coverage earned cross-package (e.g.
snapshotter tests driving mountutils) is attributed correctly - the
per-package numbers CI/codecov report without it significantly understate
real coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@aledbf
aledbf merged commit 84c2df6 into main Jun 12, 2026
6 checks passed
@aledbf
aledbf deleted the aledbf/package-coverage branch June 15, 2026 21:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant