File formats

Field-by-field reference for boards, test suites, test matrices, sensor fault inputs and scenarios, with runnable examples.

General rules

  • JSON or YAML (.json, .yaml, .yml); every file starts with schemaVersion.
  • Keys are camelCase (maxVirtualTimeNs); enums are snake_case (uart_contains, bus_disconnect). Unknown fields fail validation with line numbers.
  • Times are integer nanoseconds (tNs, atNs) unless named otherwise (maxMs). Write decimal numbers (72, not 0x48). Paths resolve relative to the file.
  • Input values use physical units or raw codes: JSON { "si": 21.0 } / { "raw": 2720 }; YAML !si 21.0 / !raw 2720 (map syntax is refused in YAML).

Board: ct.board/1

Declares the MCU, clocks, attached devices and UART consoles for ct run --board, suites, matrices and scenes.

FieldRequiredWhat it is
schemaVersionyesct.board/1
id, nameyesBoard id and display name
mcuyesThe microcontroller twin: part (catalog part number), twinId or path (a twin bundle file). When several are given, twinId wins, then path, then part.
clocksnohseHz (main external clock, alias mainClockHz), hseBypass (an external clock rather than a crystal; default false, alias mainClockExternal), lseHz (32.768 kHz crystal, alias slowClockHz)
devices[]noinstance (a name unique on the board), twin (part, twinId or path, plus function for a part with several functions), attachments[] (below) and config (part settings, an object)
consoles[]noname and port (a UART such as USART2). Suites read the first console by default.
pins[]noname, pin, kind (led, button, header) and activeHigh (default true)
canBuses[]noname, controllers (such as CAN1) and devices (instance names). A CAN controller on no bus is alone: nothing acknowledges its frames.
layout, designnoWritten by the board editor and by board import. Leave them as they are.

Each attachment has a kind. Name the controller, or the microcontroller pins the part is wired to:

kindBy controllerBy pins
i2cbus (I2C1) and address (7-bit)scl, sda and address
spibus (SPI1) and chipSelect (a pin)sck, chipSelect and at least one of mosi, miso
uartport (USART2)tx and/or rx
gpiodevicePin (the part’s pin) and mcuPin, for interrupt, reset or data-ready lines
i2c_channelswitch (the instance of an I2C switch on the board) and channel. Added next to the part’s i2c attachment.

Pin-based attachments require pin-mux data in the MCU twin; otherwise specify the controller directly.

thermostat.board.json
{
  "schemaVersion": "ct.board/1",
  "id": "thermostat-f103",
  "name": "Thermostat on NUCLEO-F103RB",
  "mcu": { "part": "STM32F103RB" },
  "clocks": { "hseHz": 8000000, "hseBypass": true },
  "consoles": [{ "name": "vcp", "port": "USART2" }],
  "pins": [
    { "name": "RELAY", "pin": "PA5", "kind": "led" },
    { "name": "B1", "pin": "PC13", "kind": "button", "activeHigh": false }
  ],
  "devices": [
    {
      "instance": "tmp117",
      "twin": { "part": "TMP117" },
      "attachments": [{ "kind": "i2c", "bus": "I2C1", "address": 72 }]
    }
  ]
}
terminal
ct run build/thermostat.elf --board thermostat.board.json --until READY

Test suite: ct.test-suite/1

Runs with ct test run locally or ct cloud suite run hosted (Test in CI).

FieldRequiredWhat it is
schemaVersion, id, nameyesct.test-suite/1, the suite id and its name
descriptionnoFree text
defaultsnoboard, limits and assertions for every case. Default assertions come before the case’s own.
cases[]noThe cases, below
matrixnoCases built from every combination of firmware[] (required), boards[], twinConfigs[] and scenarios[], each with the matrix’s assertions. For faults and seeds, use a test matrix.

A case

FieldRequiredWhat it is
idyesUnique in the suite
firmwareyespath (an ELF), sha256 (refuse other bytes) and name (a label)
name, tagsnoDisplay name; tags for ct test run --tag
boardnoid (a built-in or stored board) or path (a board file). Default: defaults.board.
stimulus[]noInput streams: target (device, port), interpolation and samples[] (tNs, value). Samples are in time order.
scenarionoid (a bundled scenario, see ct scenario list) or path (a scenario file)
twinConfignoname and overrides[]: device, twin (another twin), disconnected (off the bus), registers (values after reset, by name or "0x" offset)
uartInput[]noText sent to a UART: port (UART or console name), atNs, text
assertions[]noThe checks, below
limitsnomaxVirtualTimeNs, maxInstructions, maxWallMs. The case stops at the first limit it reaches and the assertions decide the verdict. Reaching maxWallMs is an error.
forknoafterMarker or atNs: cases with the same fork point share one boot
uninitializedMemorynozero (default) or seeded:<seed>
erratanooff (default), rev:<revision> or ids:<id>,<id>. See Silicon errata.
wearnoFlash and EEPROM wear before the run, a ct.wear/1 document
verifies, coveragenoRequirement ids this case verifies; true records the code it ran. See Compliance support.

interpolation accepts hold (default) or linear; stream samples apply at their timestamps, so use dense samples or a scenario for smooth ramps.

Assertions

Omitted port defaults to the board’s first console.

kindFieldsPasses when
uart_containstext, portThe console printed the text
uart_not_containstext, portThe console never printed it
uart_regexpattern, portThe console output matches the regular expression (Rust regex syntax)
markerpass, fail, portpass appears and fail does not. The run stops at the pass text.
oracleportORACLE_RESULT=PASS appears and ORACLE_RESULT=FAIL does not. The run stops at that line.
untilOne of marker (with port), symbol or pcThe run reached that text, function or address, where it stops. At most one per case.
memory_valueaddress, size (1, 2 or 4; default 4), mask, expected, atSymbolThe memory word equals expected at the end, or when the core first reaches atSymbol
register_valueperipheral (GPIOA), register (ODR), mask, expected, atSymbolThe peripheral register equals the value
symbol_valuesymbol, offset (default 0), size (default 4), mask, expected, atSymbolThe firmware variable equals the value
device_registerdevice, offset, mask, expectedA part’s register equals the value at the end
display_framedevice, pngSha256The display’s frame memory at the end matches a golden PNG
bus_transactionbus (I2C1), matcher (address, direction read or write, dataPrefix bytes, acked), minCount (default 1), maxCountThe number of matching transfers is in range
pin_statepin, high, atNs (default: the end)The pin is at that level
pin_edgespin, edge (rising, falling or any, the default), minCount (default 1), maxCountThe number of edges is in range
completes_withinmaxVirtualTimeNs, maxInstructions, minVirtualTimeNsThe run stopped inside the budget, and not before the minimum
no_faultnoneNo fault exception and no lockup
fault_expectedexception (HardFault, MemManage, BusFault, UsageFault, SecureFault)A fault, or that fault, was taken. The run continues past faults.
no_issuescodes (empty: every code)The run reported none of those issues
thermostat.suite.yaml
schemaVersion: ct.test-suite/1
id: thermostat
name: Thermostat controller
defaults:
  board:
    path: thermostat.board.json
  limits:
    maxVirtualTimeNs: 3000000000
  assertions:
    - kind: no_fault
cases:
  - id: boots
    name: Boots, finds the sensor, relay stays off at 21 C
    firmware:
      path: build/thermostat.elf
    stimulus:
      - target: { device: tmp117, port: temperature.temp_result }
        samples:
          - { tNs: 0, value: !si 21.0 }
    assertions:
      - kind: marker
        pass: READY
        fail: SENSOR FAIL
      - kind: uart_contains
        text: SELFTEST CRC OK
      - kind: bus_transaction
        bus: I2C1
        matcher: { address: 72, direction: write, dataPrefix: [15], acked: true }
        minCount: 1
      - kind: symbol_value
        symbol: g_setpoint_c100
        expected: 2100
      - kind: register_value
        peripheral: GPIOA
        register: ODR
        mask: 32
        expected: 0
    tags: [smoke]
  - id: heat-on
    name: Relay closes when the room cools below the band
    firmware:
      path: build/thermostat.elf
    stimulus:
      - target: { device: tmp117, port: temperature.temp_result }
        samples:
          - { tNs: 0, value: !si 22.0 }
          - { tNs: 500000000, value: !si 21.0 }
          - { tNs: 900000000, value: !si 20.4 }
    assertions:
      - kind: uart_regex
        pattern: 'RELAY ON  T=20\.[0-4][0-9]'
      - kind: pin_state
        pin: PA5
        high: true
      - kind: pin_edges
        pin: PA5
        edge: rising
        minCount: 1
        maxCount: 1
    tags: [control]
  - id: sensor-missing
    name: No sensor on the bus, the heater stays off
    firmware:
      path: build/thermostat.elf
    twinConfig:
      name: no-sensor
      overrides:
        - device: tmp117
          disconnected: true
    assertions:
      - kind: until
        marker: READY
      - kind: uart_contains
        text: SENSOR FAIL
      - kind: pin_state
        pin: PA5
        high: false
    tags: [failsafe]
  - id: heated-room
    name: Heater cycles around the setpoint in a small room
    firmware:
      path: build/thermostat.elf
    scenario:
      path: heated-room.scenario.yaml
    limits:
      maxVirtualTimeNs: 6000000000
    assertions:
      - kind: pin_edges
        pin: PA5
        edge: rising
        minCount: 2
      - kind: pin_edges
        pin: PA5
        edge: falling
        minCount: 2
    tags: [control]
terminal
ct test run thermostat.suite.yaml --junit junit.xml

Uses the heated-room scenario in case 4.

Test matrix: ct.test-matrix/1

Expands axes into unique cells for ct test matrix run (add --cloud for hosted runs).

FieldRequiredWhat it is
schemaVersion, id, nameyesct.test-matrix/1, the matrix id and its name. description is optional.
firmware[]yesname (letters, digits, . _ -), path, sha256 (required on the hosted service), and images: a path and digest per board label, for one version built for several boards
boards[]yesname (a label), id or path
scenarios[]noname, id or path. Empty: no scenario.
faults[]noFault sets, below. Empty: one fault-free set named none.
seeds or seedRangenoA list of seeds (default [0]), or { first, count }
variation[], cornersnoVariation profiles and their corners (random, min, typ, max). See Vary inputs across many units.
engine[]noname, maxVirtualTimeNs, maxInstructions, uninitializedMemory (zero or seeded: from the cell’s seed), errata. Empty: one setting named default.
inputs[]noInputs held in every cell: device, port, value (in the input’s unit), periodNs (default 10 ms), noiseSigma (seeded noise, default 0)
assertions[], limitsnoAs in a suite: the assertions and limits of every cell
stopnoafterFailures: stop after this many failed or errored cells
verifies, coveragenoAs in a suite, for every cell

A fault set has a name, its faults[], assertions[] checked after the matrix’s own, replaceAssertions (true: only the set’s own) and verifies. Faults:

kindFieldsWhat it does
bus_disconnectdeviceThe part does not answer on its bus
register_forcedevice, registers (by name or "0x" offset)Registers hold these values after reset, such as a wrong chip id
sensor_stuckdevice, port, valueThe input holds one value for the whole run
sensor_noisedevice, port, sigmaSeeded noise on the input. The port needs an entry in inputs.
sensor_out_of_rangedevice, port, valueThe input holds a value outside the part’s range; the twin clamps it to its codes
brown_outatNs, durationNs, nominalV, dipV, fallingV, risingV (default fallingV), filterNs (default 0), edgeNs (default 100 µs)The supply dips below the brown-out threshold and recovers.
harness_faultnoteFor wiring faults, use a scene’s harness, see Scene format.

Limits: 5,000 cells, 64 values per axis, 16 faults per set, 32 inputs, and 4,000 samples per input. Run time divided by periodNs must stay under 4,000: a 4 s run sampled every 1 ms is one sample too many.

thermostat.matrix.yaml
schemaVersion: ct.test-matrix/1
id: thermostat-faults
name: Thermostat heater control under sensor faults
firmware:
  - name: v2
    path: build/thermostat.elf
boards:
  - name: f103
    path: thermostat.board.json
inputs:
  - device: tmp117
    port: temperature.temp_result
    value: 18.0
    periodNs: 100000000
limits:
  maxVirtualTimeNs: 2000000000
assertions:
  - kind: no_fault
  - kind: pin_state
    pin: PA5
    high: true
seeds: [1, 2]
stop:
  afterFailures: 10
faults:
  - name: nominal
  - name: noisy-sensor
    faults:
      - { kind: sensor_noise, device: tmp117, port: temperature.temp_result, sigma: 0.2 }
  - name: sensor-off-bus
    faults:
      - { kind: bus_disconnect, device: tmp117 }
    replaceAssertions: true
    assertions:
      - kind: uart_contains
        text: SENSOR FAIL
      - kind: pin_state
        pin: PA5
        high: false
  - name: wrong-chip-id
    faults:
      - kind: register_force
        device: tmp117
        registers: { "0x0F": 0 }
    replaceAssertions: true
    assertions:
      - kind: uart_contains
        text: SENSOR FAIL -2
  - name: stuck-warm
    faults:
      - { kind: sensor_stuck, device: tmp117, port: temperature.temp_result, value: 25.0 }
    replaceAssertions: true
    assertions:
      - kind: pin_state
        pin: PA5
        high: false
  - name: out-of-range
    faults:
      - { kind: sensor_out_of_range, device: tmp117, port: temperature.temp_result, value: -300.0 }
    replaceAssertions: true
    assertions:
      - kind: uart_contains
        text: SENSOR IMPLAUSIBLE
      - kind: pin_state
        pin: PA5
        high: false
  - name: brown-out
    faults:
      - kind: brown_out
        atNs: 500000000
        durationNs: 20000000
        nominalV: 3.3
        dipV: 1.5
        fallingV: 2.0
terminal
ct test matrix run thermostat.matrix.yaml --list           # 14 cells; nothing runs
ct test matrix run thermostat.matrix.yaml --out results/

Sensor fault inputs

Generated sensor twins add <port>.fault.mode and <port>.fault.value (in the port’s unit) to every measured input, drivable via suite stimulus.

fault.modeWhat the reading does
0Normal (the default)
1Holds the last code it had
2Stuck at fault.value
3Open: reads fault.value when set, else the highest code
4Steps by fault.value (an offset)

Rebuild older twins with --force to enable fault inputs. Below, a BMI088 gyro reads 0.5 rad/s until 1.5 s, then sticks at 0:

gyro-fault.suite.yaml
schemaVersion: ct.test-suite/1
id: gyro-fault
name: Gyro fault modes
defaults:
  board:
    path: fc.board.json
  limits:
    maxVirtualTimeNs: 2000000000
cases:
  - id: gyro-stuck-at-zero
    name: Gyro X reads 0.5 rad/s, then sticks at 0 from 1.5 s
    firmware:
      path: build/fc.elf
    stimulus:
      - target: { device: imu, port: acceleration.z.acc_z }
        samples:
          - { tNs: 0, value: !si 9.80665 }
      - target: { device: gyr, port: angular_rate.x.rate_x }
        samples:
          - { tNs: 0, value: !si 0.5 }
      - target: { device: gyr, port: angular_rate.x.rate_x.fault.mode }
        samples:
          - { tNs: 0, value: !raw 0 }
          - { tNs: 1500000000, value: !raw 2 }
      - target: { device: gyr, port: angular_rate.x.rate_x.fault.value }
        samples:
          - { tNs: 0, value: !si 0.0 }
    assertions:
      - kind: uart_contains
        text: "TEL t=1416 roll=14 pitch=0 gx=286 "
      - kind: uart_contains
        text: "TEL t=1916 roll=0 pitch=0 gx=0 "

Scenario: ct.scenario/1

Scripts ambient conditions, motion, thermal nodes, electrical loads and pin actuators around a board.

FieldRequiredWhat it is
schemaVersion, id, nameyesct.scenario/1, the scenario id and its name
durationNsyesHow long the scenario runs
seed, physicsStepNsnoNoise seed (default 0) and the fixed step (default 1 ms)
environmentnotemperatureC, pressurePa, relativeHumidityPct, illuminanceLux (profiles), gravity (default [0, 0, -9.80665]), magneticFieldUt, atmosphere (baseAltitudeM, seaLevelPressurePa, seaLevelTemperatureC), lights[], directionalLights[]
mounts[]noPuts a board device in the world: device, body (absent: fixed in the world), localPose, signals[], and thermalNode, load, fluidNode or fluidLink for what it measures
bodies[], joints[]noRigid bodies (name, shape, massKg default 0.05, fixed, initial pose, motion[], restitution default 0.2, friction default 0.6, and more) and joints between them
thermalNodes[], thermalLinks[]noLumped heat: a node has name, heatCapacityJPerK, ambientConductanceWPerK, initialC, heatW; a link joins a and b with conductanceWPerK
loads[]noElectrical loads for current and power monitors: name, supplyV, sourceResistanceOhm, draw (current with amps, resistance with ohms, power with watts), heatsNode, heatFraction
actuators[]noPin effects: pin, activeHigh (default true), mode (level or duty for PWM) and effect: heater (node, watts), load_switch, force, torque, light_switch, coil_current, pump, valve. They need firmware: ct scenario simulate leaves them off.
streams[]noInput streams in the suite’s stimulus form, added after the world’s own
circuit, magnets[], fluid, drives[], motors[], motorTraceNsnoAn analog circuit the converters sample, magnets and coils, liquid tanks, pipes and pumps, bodies turned by a stepper driver, and motors the firmware drives

A profile is a value over time. Its kind is constant (value), ramp (from, to, startNs, endNs), keyframes (points[] of tNs and value, and interpolation hold or linear) or sine (mean, amplitude, periodNs, phaseNs).

A signal binds one input of the device: port, source, noise (stddev; process white, the default, randomWalk or gaussMarkov with correlationNs), samplePeriodNs (default: the physics step), bias and sourceId. The source’s kind:

kindFieldsReads
environmentquantityAir temperature, pressure, humidity or light; with the mount’s thermalNode, load or fluid, that node’s value
acceleration, angular_rate, magnetic_field, angleaxis (x, y, z)The mount’s motion and field, in the sensor’s frame
distanceaxis, maxM, noTargetMThe distance to the nearest body along the axis
profilequantity, profileA value you script
thermalnodeA thermal node’s temperature
electricalload, quantity (voltage, current, power)A load’s voltage, current or power
fluid_pressure, fluid_flownode and gauge, or linkPressure at a fluid node, flow through a link

Quantities: temperature, pressure, relative_humidity, acceleration, angular_rate, magnetic_field, illuminance, distance, voltage, current, power, resistance, counts, flow_rate, angle. Values use SI units, except where the field name says otherwise (temperatureC).

20 W relay heater cycling around 21 °C in 15 °C ambient air:

heated-room.scenario.yaml
schemaVersion: ct.scenario/1
id: heated-room
name: Small room heated by the relay
seed: 7
durationNs: 6000000000
physicsStepNs: 10000000
environment:
  temperatureC: { kind: constant, value: 15.0 }
thermalNodes:
  - name: room
    heatCapacityJPerK: 2.0
    ambientConductanceWPerK: 1.0
    initialC: 19.0
actuators:
  - pin: PA5
    effect: { kind: heater, node: room, watts: 20.0 }
mounts:
  - device: tmp117
    thermalNode: room
    signals:
      - port: temperature.temp_result
        source: { kind: environment, quantity: temperature }
        noise: { stddev: 0.01 }
        samplePeriodNs: 100000000
terminal
ct scenario check heated-room.scenario.yaml --board thermostat.board.json
ct run build/thermostat.elf --board thermostat.board.json --scenario heated-room.scenario.yaml --max-ms 6000

ct scenario check --board validates every signal against board twin ports; ct scenario simulate prints streams without firmware.

Scenes

Multi-board ct.scene/1 schema: Scene format.