reduce-test-cases

Reduce failing Wasmtime and Cranelift test cases to minimal reproducers using automated reducers and manual playbooks.

18.6k|1.8k|Updated Aug 29, 2017
One-click install
npx skills add https://github.com/bytecodealliance/wasmtime --skill reduce-test-cases-bytecodealliance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: reduce-test-cases
Source: https://github.com/bytecodealliance/wasmtime/tree/main/.agents/skills/reduce-test-cases
Command: npx skills add https://github.com/bytecodealliance/wasmtime --skill reduce-test-cases-bytecodealliance

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Bug reports on Wasmtime or Cranelift often arrive with large, noisy failing inputs (.wasm, .wat, .wast, or .clif files) that obscure the root cause. This Skill guides you through shrinking those inputs down to the smallest case that still reproduces the crash, trap, panic, or miscompilation, producing a legible artifact suitable for a bug report or regression test. ## Core Features & Use Cases - Per-reducer predicate skeletons: Copy-and-edit shell templates for wasm-tools shrink, Binaryen wasm-reduce, creduce (wat/wast/clif), and clif-util bugpoint, each encoding the tool's specific contract for what counts as "interesting". - Wasm fallback chain: A three-tool strategy (shrink, then wasm-reduce, then disassemble plus creduce) for modules using proposals a given reducer cannot parse, such as wide-arithmetic instructions. - Differential miscompile predicates: A guarded two-configuration predicate shape (e.g. opt-level=0 vs default) for wrong-answer bugs that have no trap or panic message to grep. - Manual reduction playbook: Semantic techniques like neutralizing inputs one at a time and returning the diverging value directly, for cases where automated reducers plateau. - Use Case: A fuzzer reports a 649-line module that miscompiles under Cranelift. You confirm determinism, run shrink and creduce in parallel, then apply the manual playbook to produce a roughly 22-line self-checking module that proves the bug. ## Quick Start Reduce my failing file input.wasm to the smallest module that still traps with integer divide by zero when run under Wasmtime.

Frequently Asked Questions about reduce-test-cases

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce a failing wasm test case to a minimal reproducer?

Start with wasm-tools shrink using a predicate script that exits 0 when the bug still reproduces, then run wasm-tools shrink ./pred.sh input.wasm -o reduced.wasm. Always test the predicate on the original file first to confirm it fires before reducing.

How do I reduce a miscompile that has no crash or trap message?

Use a differential predicate that runs the input under two configurations, such as opt-level=0 versus the default, and treats the case as interesting only when both run cleanly, produce output, and disagree. Confirm the bug is deterministic before reducing, since flaky configs make the predicate unsound.

What is the difference between wasm-tools shrink, wasm-reduce, and creduce?

wasm-tools shrink is the most structural and produces the smallest wasm output. Binaryen wasm-reduce preserves behavior by matching stdout and exit code but cannot parse some proposals like wide-arithmetic. creduce reduces plain text, so it works on .wat, .wast, and .clif but plateaus earlier.

Can clif-util bugpoint reduce any Cranelift .clif failure?

No, bugpoint only reduces hard compile panics and has no predicate hook. It treats clean compiles and verifier errors as not interesting, so for miscompiles, graceful codegen errors, or test failures you must use creduce with a clif-util predicate instead.

Why does my creduce predicate never report the bug as interesting?

Common causes are relative tool paths that break in creduce's fresh temp directory, a missing chmod +x on the script, or set -e aborting the script when a trapping engine exits non-zero. Use absolute paths, reference the candidate by basename, and let the final grep determine the exit status.

Why does wasm-reduce fail with 'failed to read and write the binary'?

Binaryen cannot parse a wasm proposal used in your module, so its initial round-trip check fails. Pass -f to force past it, and if reduction still stalls, disassemble the module with wasm-tools print and reduce the text with creduce instead.