Lockstep.Trace (Lockstep v0.1.0)

Copy Markdown View Source

Recorded schedule. A trace is the sequence of decisions the controller made during a test iteration.

Each entry: %{step: integer, event: tuple}. Events:

{:hello, pid}
{:spawn, parent, child}
{:spawn_link, parent, child}
{:send, from, to, msg}
{:recv, pid, msg}
{:exit, pid, reason}
{:link, pid, target}
{:unlink, pid, target}
{:flag, pid, flag, prev_value}
{:exit_signal, dying_pid, linked_pid, reason}

PIDs are the original Erlang pids from the recording run. They are not meaningful for replay across runs; instead the trace records spawn order and replay reconstructs the equivalent ordering. See Lockstep.Strategy.Replay.

Format on disk: a :erlang.term_to_binary/1 of %{version: 1, ...}.

Summary

Functions

Build a trace entry.

Format a trace as a human-readable schedule.

Load a trace file. Returns the metadata map.

Save trace + iteration metadata to disk. Returns the path.

Types

entry()

@type entry() :: %{step: non_neg_integer(), event: tuple()}

t()

@type t() :: [entry()]

Functions

entry(step, event)

@spec entry(non_neg_integer(), tuple()) :: entry()

Build a trace entry.

format(trace, opts \\ [])

@spec format(
  t(),
  keyword()
) :: String.t()

Format a trace as a human-readable schedule.

load(path)

@spec load(Path.t()) :: %{required(atom()) => any()}

Load a trace file. Returns the metadata map.

save(trace, opts)

@spec save(
  t(),
  keyword()
) :: Path.t()

Save trace + iteration metadata to disk. Returns the path.