module std.test
std.test - fault injection for tests (§18.1, D-3601) and the controls of deterministic simulation (§18.4, D-4102).
use std.test { net, node, disk, clock, sim }.
In a test sim the controls act on the simulated world of the test process (runtime/src/sim): virtual time, a simulated
network between named nodes, node crashes and disk faults. All randomness depends on the seed (oxl test --seed N).
Node names are created on first use; a node without a protocol is a passive endpoint that can be partitioned and killed.
Example:
use std.test { net, node, clock }
test sim "the service survives a partition" seeds 1..=5 {
net.partition(["api"], ["db"], for: 2s)
clock.advance(5s)
assert !net.isBlocked("api", "db")
node.kill("db")
node.restart("db", after: 1s)
}Types
data clock | Namespace of the virtual clock |
data disk | Namespace of the disk controls |
data net | Namespace of the network controls |
data node | Namespace of the node controls |
data sim | Namespace of the simulation itself |
Functions
black_box | Returns x unchanged while hiding it from the optimizer, so that a benchmark's work is not optimized away (D-7053). |