- program_parallel_map: four exclusive loans of disjoint quarters - program_channel_transfer: heap-owned messages moved through a bounded channel; the 64-byte budget fits exactly the bounded worst case - program_tcp_echo_tasks: server task, one echo task per connection, two client tasks sharing address and message by shared loans - runner --stress N: seeds 0..N-1 under quanta 1, 2, 7 and the test's own; failures print the replay command; CI runs --stress 200 - plan: P3-12, P3-13 done
50 lines
3.1 KiB
Markdown
50 lines
3.1 KiB
Markdown
# Testing
|
|
|
|
Non-normative. How the reference implementation is tested. Policy (what must be tested) is in `AGENTS.md`; this file covers the mechanics.
|
|
|
|
## Test levels
|
|
|
|
| Level | Where | Run | Purpose |
|
|
|---|---|---|---|
|
|
| Unit | `test` blocks in `src/`, `tools/` | `zig build test` | internal data structures, helpers, registry ↔ docs sync |
|
|
| Conformance | `tests/conformance/` | `zig build conformance` | spec behavior: accept/reject, later run output and traps |
|
|
| Reference programs | `tests/programs/` (from P2) | `zig build conformance` | the six programs in `plan/conformance-suite.md` |
|
|
| Litmus | `tests/litmus/` (from P5) | `zig build litmus` | memory-model outcomes allowed/forbidden |
|
|
| Schedule stress | runner flag (P3-12) | `zig build conformance -- --stress N` | every test with `schedules:` runs schedule seeds 0…N-1 under quanta 1, 2, 7 and its own; a failure prints the replay command. Systematic exploration (DPOR) is Phase 5 |
|
|
| Native parity | (from P7) | `zig build parity` | interpreter and native backend agree on the whole corpus |
|
|
|
|
Unit, conformance and hosted smoke tests exist today; conformance covers accept, reject and run tests in the deterministic profile, and `tests/hosted/smoke.py` checks observable effects (files, streams, sockets) of hosted runs.
|
|
|
|
## Conformance tests
|
|
|
|
Format and outcomes: [`tests/conformance/README.md`](../../tests/conformance/README.md).
|
|
|
|
Adding a verifier rule:
|
|
|
|
1. Write the rule in the spec, with its code in `docs/reference/error-codes.md` and `src/diag.zig`.
|
|
2. Add the smallest `reject` test that violates only that rule.
|
|
3. Add an `accept` test that is as close as possible to the reject test but legal. The pair documents exactly where the boundary is.
|
|
4. Implement until both pass.
|
|
|
|
Planned header extensions (added by the phase that needs them):
|
|
|
|
| Key | Phase | Meaning |
|
|
|---|---|---|
|
|
| `expect: run` + `result:` / `trap:` | P0 (implemented) | module must verify; run record must match |
|
|
| `stdout:` | P2 | expected output, `\n`-escaped (needs `io.write`) |
|
|
| `stdin:` / `vfs:` / `seed:` / `stdout:` / `stderr:` / `file:` / `blocked:` | P2 (implemented) | deterministic world inputs and expected observable output |
|
|
| `grant:` / `not_instantiated:` | P2 (implemented) | capability grants for `@main`; expected instantiation failure |
|
|
| `fuel:` | P0 (implemented) | instruction limit; default 1 000 000 (spec 11 §7.1) |
|
|
| `seed:` / `schedules:` / `quantum:` | P3 | scheduler seed / schedule budget / instructions per forced scheduling point (spec 11 §7.2) |
|
|
| `profile:` | P2 | runtime profile (`hosted`, `deterministic`, …) |
|
|
|
|
## Determinism checks
|
|
|
|
No test outcome may depend on wall-clock time. Runs are bounded by fuel; fuzz and stress tooling must always pass a fuel limit.
|
|
|
|
Every run test is executed twice by the runner from P0-12 onward and the outputs (stdout, trap record, trace hash) compared byte-for-byte. Concurrency tests additionally run under the stress modes listed in `plan/conformance-suite.md`.
|
|
|
|
## Diagnostics as API
|
|
|
|
Diagnostic JSON is a stable interface. Snapshot tests on the full JSON (not only the code) belong in unit tests next to the pass that emits them, so field renames are caught.
|