tests: add WASI integration test support via wasmtime#11717
tests: add WASI integration test support via wasmtime#11717DePasqualeOrg wants to merge 5 commits intouutils:mainfrom
Conversation
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.
|
Why do not just use #[cfg] |
|
Compiling the test harness itself for WASI isn't practical, since it depends on Unix-specific crates like |
|
I meant excluding unsupported tests by cfg instead of maintaining cargo's args at *.yml. |
|
The alternative would be annotating dozens of tests across many files, and the skip reasons (no FIFO, no pipes, no UTF-8 filenames, etc.) are easier to understand when kept in one place. Also, as WASI support expands (for example, with the other two PRs that I submitted), tests will move off the skip lists, and having them in one place makes that easier to track. |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
| # vdir yes | ||
| UUTESTS_BINARY_PATH="$(pwd)/target/wasm32-wasip1/debug/coreutils.wasm" \ | ||
| UUTESTS_WASM_RUNNER=wasmtime \ | ||
| cargo test --test tests -- \ |
There was a problem hiding this comment.
this long list isn't ideal
we should #ignore them for wasi in the .rs files
There was a problem hiding this comment.
I can change this if you feel strongly about it, but then we lose the centralized tracking of what's not yet supported, but soon could be.
Or, if a separate centralized list is maintained somewhere, it would need to be kept up to date with the #ignore annotations.
There was a problem hiding this comment.
you can "grep" it easily in the code
There was a problem hiding this comment.
The tradeoff is that there would not be one place where the coverage is understandable at a glance, and that information would need to be aggregated from many files.
I'm happy to make whatever changes you require, but just wanted to make the tradeoff clear. Having a centralized account of gaps in support would be helpful for me, since I hope to expand WASI support for these tools over time.
There was a problem hiding this comment.
I switched to test annotations in the latest commit. Does this look good to you now?
|
GNU testsuite comparison: |
|
please fix: |
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_RUNNERenvironment variable. When set (e.g., towasmtime), 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: AllowUUTESTS_BINARY_PATHto be overridden by the environment, so tests can target a WASI binary instead of the host binarytests/uutests/src/lib/util.rs: WhenUUTESTS_WASM_RUNNERis set, wrap command invocation through the runner with--dir,--argv0, and--envflags to map the working directory, set the binary name, and forward environment variables to the WASI guesttests/uutests/src/lib/util.rs: Adjustusage_errorassertions 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 wasmtimetests/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-libcTools 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:
/proc,/sys, or/devpaths that are not available inside the WASI sandbox (the guest root is mapped to the test's working directory)