This document describes how to use the JSON test specifications to write your own test executor for
wasi-testsuite. The test executor included in this project provides a completely-usable
reference implementation, but projects with other requirements may want to run the
tests in their own way (e.g., no Python dependency). The JSON test specifications provide a simple
way to verify that the tests indeed passed.
Before executing anything, a test executor is expected to:
-
find all
*.wasmfiles in a given subdirectory — these are the test cases -
find all
*.cleanupfiles in a given subdirectory and remove them — these are test artifacts that can be generated during testing -
for each test case, look for a
.jsonfile in the same directory matching the base name (e.g.,foo.jsonforfoo.wasm) — parse this specification -
if no
.jsonfile is present, use a default specification; a (conceptual) default specification would look like:{ "args": [], "dirs": [], "env": {}, "exit_code": 0, "stderr": "", "stdout": "" } -
if the specification is missing fields, use default values
To execute the tests, the test executor is expected to:
env: construct an environment from each key-value pair inenv; the environment should only contain these keys and otherwise should be empty (note that this environment is the WASI environment, whether the engine inherits the shell environment or explicitly configures it via--envparameters)dir: add each path listed indiras WASI preopen directories (some engines use a--dirflag)args: pass each argument in order to the WASI program (most CLI engines allow appending these after the module path)
The test executor runs the WebAssembly test case with the above context and records its results.
With the execution results in hand, the test executor is expected to:
exit_code: check that the WASI exit code matchesexit_code, or0if none was providedstderr: if astderrfield is provided, check that the bytes printed tostderrmatch itstdout: if astdoutfield is provided, check that the bytes printed tostdoutmatch it
A test case passes if all of the checks are true.