Skip to content

test: fs: stop the disk space test racing with the filesystem - #442

Merged
otavio merged 1 commit into
masterfrom
fix-disk-space-test-race
Aug 19, 2026
Merged

test: fs: stop the disk space test racing with the filesystem#442
otavio merged 1 commit into
masterfrom
fix-disk-space-test-race

Conversation

@otavio

@otavio otavio commented Aug 19, 2026

Copy link
Copy Markdown
Member

a_requirement_beyond_the_available_space_is_rejected read the free space, then handed the very same number to ensure_disk_space, which reads it again:

let available = available_space(dir.path()).unwrap();   // reading 1
ensure_disk_space(dir.path(), available).unwrap();      // reading 2

Any other writer on that filesystem moves the second reading, so the boundary case the test was pinned to falls on the wrong side.

It failed exactly that way in the coverage step of run 32294740390:

NotEnoughSpace { available: 80615378944, required: 80615387136 }

8 KiB vanished while the two readings ran, because cargo llvm-cov has the parallel tests writing .profraw files the whole time.

The fix

Step back from the boundary on both sides. Half of the free space stays available however busy the disk gets, and no filesystem answers with u64::MAX, so the rejection no longer depends on what the second reading finds.

This blocks #441, which the same flake failed on with an unrelated diff.

Verification

  • cargo test --lib utils::fs: 11 pass, 0 fail.
  • cargo fmt --all -- --check: clean.
  • cargo clippy --locked --all-features --all --tests -- -D clippy::all: clean.

`a_requirement_beyond_the_available_space_is_rejected` read the free space, then
handed the very same number to `ensure_disk_space`, which reads it again. Any
other writer on that filesystem moves the second reading, and the boundary case
the test was pinned to then falls on the wrong side.

It failed exactly that way in the coverage step of
https://github.com/UpdateHub/updatehub/actions/runs/32294740390, with `available:
80615378944, required: 80615387136`: 8 KiB vanished while the two readings ran,
because `cargo llvm-cov` has the parallel tests writing .profraw files the whole
time.

Step back from the boundary on both sides. Half of the free space stays available
however busy the disk gets, and no filesystem answers with `u64::MAX`, so the
rejection no longer depends on what the second reading finds.
@otavio
otavio merged commit 1e936cc into master Aug 19, 2026
3 checks passed
@otavio
otavio deleted the fix-disk-space-test-race branch August 19, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant