OxL Reference

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:

oxl✓ checked in CI
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 clockNamespace of the virtual clock
data diskNamespace of the disk controls
data netNamespace of the network controls
data nodeNamespace of the node controls
data simNamespace of the simulation itself

Functions

black_boxReturns x unchanged while hiding it from the optimizer, so that a benchmark's work is not optimized away (D-7053).

See also