Skip to content

tests: add WASI integration test support via wasmtime#11717

Open
DePasqualeOrg wants to merge 1 commit intouutils:mainfrom
DePasqualeOrg:wasi-integration-tests
Open

tests: add WASI integration test support via wasmtime#11717
DePasqualeOrg wants to merge 1 commit intouutils:mainfrom
DePasqualeOrg:wasi-integration-tests

Conversation

@DePasqualeOrg
Copy link
Copy Markdown

This PR adds WASI integration test support, enabling ~1,250 existing integration tests across 26 tools to run against the WASI binary via wasmtime.

The changes have gone through multiple rounds of review and refinement with Claude Code and Codex. I have tested them on macOS and Linux.

The test framework now supports a UUTESTS_WASM_RUNNER environment variable. When set (e.g., to wasmtime), the test harness wraps each command invocation through the runner instead of executing the binary directly. The host-compiled integration tests exercise the WASI binary end to end without needing to compile the test harness itself for WASI.

Key changes:

  • tests/tests.rs: Allow UUTESTS_BINARY_PATH to be overridden by the environment, so tests can target a WASI binary instead of the host binary
  • tests/uutests/src/lib/util.rs: When UUTESTS_WASM_RUNNER is set, wrap command invocation through the runner with --dir, --argv0, and --env flags to map the working directory, set the binary name, and forward environment variables to the WASI guest
  • tests/uutests/src/lib/util.rs: Adjust usage_error assertions to use the filename (from --argv0) instead of the full path when a WASM runner is active
  • .github/workflows/wasi.yml: Add an integration test step that builds the WASI binary and runs tests through wasmtime
  • tests/by-util/test_basenc.rs, test_comm.rs, test_od.rs, test_tr.rs, test_wc.rs: Add conditional expectations for error messages, formatting, and collation behavior that differ between host libc and wasi-libc

Tools tested (26)

base32, base64, basenc, basename, comm, cut, dirname, echo, expand, factor, false, fold, head, link, nl, numfmt, od, paste, printf, shuf, sum, tee, tr, true, truncate, unexpand, unlink, wc

Adding more tools

Tools not yet included in the integration test run are tracked in a TODO comment in .github/workflows/wasi.yml. As WASI support is extended for these tools, they can be moved from the TODO list to the test list, with any necessary skips added for WASI-specific limitations.

Skipped tests by category

Tests are skipped for documented WASI platform limitations:

  • Host paths not visible in guest (20): Tests using /proc, /sys, or /dev paths that are not available inside the WASI sandbox (the guest root is mapped to the test's working directory)
  • WASI spec: argv/filenames must be valid UTF-8 (19): wasmtime enforces valid UTF-8 for command-line arguments and filenames per the WASI spec
  • No FIFO/mkfifo support (3): WASI preview1 does not support FIFOs
  • No pipe/signal support (2): WASI preview1 does not support pipe signals
  • No subprocess spawning (3): Tests that shell out or invoke another binary
  • stdin file position (3): stdin file position not preserved through wasmtime

Add UUTESTS_WASM_RUNNER support to the test framework, enabling
host-compiled integration tests to exercise a WASI binary through
wasmtime. This runs ~1,230 existing tests across 26 tools without
needing to compile the test harness for WASI.
@oech3
Copy link
Copy Markdown
Contributor

oech3 commented Apr 9, 2026

Why do not just use #[cfg] #[ignore] for the target at test code?

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.

2 participants