fix(tests): resolve qemu-img via PATH so the differential runs off macOS - #4
Merged
Conversation
The oracle was pinned to the macOS-arm64 Homebrew path:
const QEMU_IMG: &str = "/opt/homebrew/bin/qemu-img";
That path does not exist on the ubuntu-latest runner, so every qemu
differential in this crate resolved nothing and returned early on every
CI run -- despite ci.yml installing qemu-utils in two jobs specifically
to feed them. The tests reported "4 passed" while validating nothing.
Resolve through PATH first (covering any install location), falling back
to the known absolute prefixes for a stripped PATH, with a QEMU_IMG_BIN
override. A candidate counts only if `--version` succeeds, which proves
the binary runs rather than merely exists.
Verified on Linux (rust:1-slim-bookworm + apt qemu-utils 7.2.22), three
controls:
A real qemu-img on PATH -> 4 passed (0.20s -- real work)
B QEMU_IMG_BIN=/bin/true -> 4 FAILED (proves the body runs the
oracle and consumes its output)
C QEMU_IMG_BIN=/nonexistent -> 4 passed (0.00s -- clean skip)
Control C's 0.00s is the signature of the old bug; control A's 0.20s is
what CI gets now. The reader agrees with qemu-img byte-for-byte on
Linux -- no parser defect behind the skip.
No RED commit: a test-plumbing change admits no honest failing test. The
verification is the control matrix above.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
The qemu-img oracle was pinned to the macOS-arm64 Homebrew path:
That path does not exist on the
ubuntu-latestrunner, so every qemu differential in this crate resolved nothing and returned early on every CI run — despiteci.ymlinstallingqemu-utilsin two separate jobs specifically to feed them. The tests reported4 passedwhile validating nothing.The fix
PATHfirst (covering any install location, including ones a fixed list cannot anticipate), the known absolute prefixes as fallback for a strippedPATH,QEMU_IMG_BINas override. A candidate counts only if--versionsucceeds — proving the binary runs, which a barePath::exists()does not.This is the shape already used by
sqlite-forensic'ssqlite3_bin()(env + PATH + probe) merged withqcow2-core's candidate list, rather than a new invention.Does the differential actually pass once the oracle is present?
Yes. Run on Linux (
rust:1-slim-bookworm+ aptqemu-utils7.2.22), where this had never executed:qemu-imgon PATHQEMU_IMG_BIN=/bin/true(resolves, exits 0, produces nothing)QEMU_IMG_BIN=/nonexistentControl B is the positive control: the tests must fail when the oracle produces no output, which proves the body genuinely runs the oracle and consumes its result. Control C's 0.00s is the fingerprint of the old bug — a green no-op, indistinguishable from real validation by the
okline alone.VhdReaderagrees withqemu-imgbyte-for-byte on Linux. No parser defect was hiding behind the skip.On the missing RED commit
A test-plumbing change admits no honest failing test — a unit test asserting "the resolver does not hardcode one directory" would be tautological. The verification is the control matrix above, not a fabricated RED.
Gates
cargo build·cargo test --workspace·cargo clippy --all-targets -- -D warnings·cargo fmt --check— all green.🤖 Generated with Claude Code