Skip to content

fix(tests): resolve qemu-img via PATH so the differential runs off macOS - #4

Merged
h4x0r merged 1 commit into
mainfrom
fix/oracle-path-resolution
Aug 5, 2026
Merged

fix(tests): resolve qemu-img via PATH so the differential runs off macOS#4
h4x0r merged 1 commit into
mainfrom
fix/oracle-path-resolution

Conversation

@h4x0r

@h4x0r h4x0r commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The defect

The qemu-img oracle was pinned to the macOS-arm64 Homebrew path:

const QEMU_IMG: &str = "/opt/homebrew/bin/qemu-img";   // x2, lines 19 and 99

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 separate jobs specifically to feed them. The tests reported 4 passed while validating nothing.

The fix

PATH first (covering any install location, including ones a fixed list cannot anticipate), the known absolute prefixes as fallback for a stripped PATH, QEMU_IMG_BIN as override. A candidate counts only if --version succeeds — proving the binary runs, which a bare Path::exists() does not.

This is the shape already used by sqlite-forensic's sqlite3_bin() (env + PATH + probe) merged with qcow2-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 + apt qemu-utils 7.2.22), where this had never executed:

Control Result
A — real qemu-img on PATH ✅ 4 passed, 0.20s
B — QEMU_IMG_BIN=/bin/true (resolves, exits 0, produces nothing) 4 FAILED
C — QEMU_IMG_BIN=/nonexistent ✅ 4 passed, 0.00s

Control 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 ok line alone.

VhdReader agrees with qemu-img byte-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

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>
@h4x0r
h4x0r marked this pull request as ready for review August 5, 2026 20:27
@h4x0r
h4x0r merged commit a4ed37a into main Aug 5, 2026
17 checks passed
@h4x0r
h4x0r deleted the fix/oracle-path-resolution branch August 9, 2026 15:28
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