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 withschemaVersion. - 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, not0x48). 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.
| Field | Required | What it is |
|---|---|---|
schemaVersion | yes | ct.board/1 |
id, name | yes | Board id and display name |
mcu | yes | The microcontroller twin: part (catalog part number), twinId or path (a twin bundle file). When several are given, twinId wins, then path, then part. |
clocks | no | hseHz (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[] | no | instance (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[] | no | name and port (a UART such as USART2). Suites read the first console by default. |
pins[] | no | name, pin, kind (led, button, header) and activeHigh (default true) |
canBuses[] | no | name, controllers (such as CAN1) and devices (instance names). A CAN controller on no bus is alone: nothing acknowledges its frames. |
layout, design | no | Written 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:
kind | By controller | By pins |
|---|---|---|
i2c | bus (I2C1) and address (7-bit) | scl, sda and address |
spi | bus (SPI1) and chipSelect (a pin) | sck, chipSelect and at least one of mosi, miso |
uart | port (USART2) | tx and/or rx |
gpio | devicePin (the part’s pin) and mcuPin, for interrupt, reset or data-ready lines | |
i2c_channel | switch (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.
{
"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 }]
}
]
}ct run build/thermostat.elf --board thermostat.board.json --until READYTest suite: ct.test-suite/1
Runs with ct test run locally or ct cloud suite run hosted (Test in CI).
| Field | Required | What it is |
|---|---|---|
schemaVersion, id, name | yes | ct.test-suite/1, the suite id and its name |
description | no | Free text |
defaults | no | board, limits and assertions for every case. Default assertions come before the case’s own. |
cases[] | no | The cases, below |
matrix | no | Cases 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
| Field | Required | What it is |
|---|---|---|
id | yes | Unique in the suite |
firmware | yes | path (an ELF), sha256 (refuse other bytes) and name (a label) |
name, tags | no | Display name; tags for ct test run --tag |
board | no | id (a built-in or stored board) or path (a board file). Default: defaults.board. |
stimulus[] | no | Input streams: target (device, port), interpolation and samples[] (tNs, value). Samples are in time order. |
scenario | no | id (a bundled scenario, see ct scenario list) or path (a scenario file) |
twinConfig | no | name and overrides[]: device, twin (another twin), disconnected (off the bus), registers (values after reset, by name or "0x" offset) |
uartInput[] | no | Text sent to a UART: port (UART or console name), atNs, text |
assertions[] | no | The checks, below |
limits | no | maxVirtualTimeNs, maxInstructions, maxWallMs. The case stops at the first limit it reaches and the assertions decide the verdict. Reaching maxWallMs is an error. |
fork | no | afterMarker or atNs: cases with the same fork point share one boot |
uninitializedMemory | no | zero (default) or seeded:<seed> |
errata | no | off (default), rev:<revision> or ids:<id>,<id>. See Silicon errata. |
wear | no | Flash and EEPROM wear before the run, a ct.wear/1 document |
verifies, coverage | no | Requirement 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.
kind | Fields | Passes when |
|---|---|---|
uart_contains | text, port | The console printed the text |
uart_not_contains | text, port | The console never printed it |
uart_regex | pattern, port | The console output matches the regular expression (Rust regex syntax) |
marker | pass, fail, port | pass appears and fail does not. The run stops at the pass text. |
oracle | port | ORACLE_RESULT=PASS appears and ORACLE_RESULT=FAIL does not. The run stops at that line. |
until | One of marker (with port), symbol or pc | The run reached that text, function or address, where it stops. At most one per case. |
memory_value | address, size (1, 2 or 4; default 4), mask, expected, atSymbol | The memory word equals expected at the end, or when the core first reaches atSymbol |
register_value | peripheral (GPIOA), register (ODR), mask, expected, atSymbol | The peripheral register equals the value |
symbol_value | symbol, offset (default 0), size (default 4), mask, expected, atSymbol | The firmware variable equals the value |
device_register | device, offset, mask, expected | A part’s register equals the value at the end |
display_frame | device, pngSha256 | The display’s frame memory at the end matches a golden PNG |
bus_transaction | bus (I2C1), matcher (address, direction read or write, dataPrefix bytes, acked), minCount (default 1), maxCount | The number of matching transfers is in range |
pin_state | pin, high, atNs (default: the end) | The pin is at that level |
pin_edges | pin, edge (rising, falling or any, the default), minCount (default 1), maxCount | The number of edges is in range |
completes_within | maxVirtualTimeNs, maxInstructions, minVirtualTimeNs | The run stopped inside the budget, and not before the minimum |
no_fault | none | No fault exception and no lockup |
fault_expected | exception (HardFault, MemManage, BusFault, UsageFault, SecureFault) | A fault, or that fault, was taken. The run continues past faults. |
no_issues | codes (empty: every code) | The run reported none of those issues |
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]ct test run thermostat.suite.yaml --junit junit.xmlUses 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).
| Field | Required | What it is |
|---|---|---|
schemaVersion, id, name | yes | ct.test-matrix/1, the matrix id and its name. description is optional. |
firmware[] | yes | name (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[] | yes | name (a label), id or path |
scenarios[] | no | name, id or path. Empty: no scenario. |
faults[] | no | Fault sets, below. Empty: one fault-free set named none. |
seeds or seedRange | no | A list of seeds (default [0]), or { first, count } |
variation[], corners | no | Variation profiles and their corners (random, min, typ, max). See Vary inputs across many units. |
engine[] | no | name, maxVirtualTimeNs, maxInstructions, uninitializedMemory (zero or seeded: from the cell’s seed), errata. Empty: one setting named default. |
inputs[] | no | Inputs held in every cell: device, port, value (in the input’s unit), periodNs (default 10 ms), noiseSigma (seeded noise, default 0) |
assertions[], limits | no | As in a suite: the assertions and limits of every cell |
stop | no | afterFailures: stop after this many failed or errored cells |
verifies, coverage | no | As 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:
kind | Fields | What it does |
|---|---|---|
bus_disconnect | device | The part does not answer on its bus |
register_force | device, registers (by name or "0x" offset) | Registers hold these values after reset, such as a wrong chip id |
sensor_stuck | device, port, value | The input holds one value for the whole run |
sensor_noise | device, port, sigma | Seeded noise on the input. The port needs an entry in inputs. |
sensor_out_of_range | device, port, value | The input holds a value outside the part’s range; the twin clamps it to its codes |
brown_out | atNs, 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_fault | note | For 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.
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.0ct 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.mode | What the reading does |
|---|---|
0 | Normal (the default) |
1 | Holds the last code it had |
2 | Stuck at fault.value |
3 | Open: reads fault.value when set, else the highest code |
4 | Steps 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:
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.
| Field | Required | What it is |
|---|---|---|
schemaVersion, id, name | yes | ct.scenario/1, the scenario id and its name |
durationNs | yes | How long the scenario runs |
seed, physicsStepNs | no | Noise seed (default 0) and the fixed step (default 1 ms) |
environment | no | temperatureC, pressurePa, relativeHumidityPct, illuminanceLux (profiles), gravity (default [0, 0, -9.80665]), magneticFieldUt, atmosphere (baseAltitudeM, seaLevelPressurePa, seaLevelTemperatureC), lights[], directionalLights[] |
mounts[] | no | Puts 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[] | no | Rigid 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[] | no | Lumped heat: a node has name, heatCapacityJPerK, ambientConductanceWPerK, initialC, heatW; a link joins a and b with conductanceWPerK |
loads[] | no | Electrical loads for current and power monitors: name, supplyV, sourceResistanceOhm, draw (current with amps, resistance with ohms, power with watts), heatsNode, heatFraction |
actuators[] | no | Pin 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[] | no | Input streams in the suite’s stimulus form, added after the world’s own |
circuit, magnets[], fluid, drives[], motors[], motorTraceNs | no | An 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:
kind | Fields | Reads |
|---|---|---|
environment | quantity | Air temperature, pressure, humidity or light; with the mount’s thermalNode, load or fluid, that node’s value |
acceleration, angular_rate, magnetic_field, angle | axis (x, y, z) | The mount’s motion and field, in the sensor’s frame |
distance | axis, maxM, noTargetM | The distance to the nearest body along the axis |
profile | quantity, profile | A value you script |
thermal | node | A thermal node’s temperature |
electrical | load, quantity (voltage, current, power) | A load’s voltage, current or power |
fluid_pressure, fluid_flow | node and gauge, or link | Pressure 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:
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: 100000000ct 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 6000ct 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.