> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Automated testing

> Add host tests, board smoke tests, and saved hardware scripts with explicit pass conditions, then rerun them from chat, VS Code, or a terminal.

Use Inlay to add tests that prove a requirement, then rerun them the same way every time. Use your project's existing test framework for logic. Add a hardware check when the result depends on the target, timing, power, or an electrical interface.

## Choose the test

| Test | What it proves |
| - | - |
| Host test | Parsing, state transitions, and other logic that doesn't need the target. |
| Target build | The selected configuration compiles and links. |
| Flash-and-observe check | The image starts and prints the expected runtime marker. |
| Instrument capture | Protocol traffic, timing, voltage, or current stays within a limit. |

Record each test command and its expected result in [INLAY.md](/docs/core-concepts/inlay-md.md). Inlay reuses them in later requests.

## Add a regression test

In **Act** mode, name the failure the test covers, the suite it belongs to, and what to run afterward:

```text theme={"theme":"css-variables"}
Add a truncated-frame case to the existing parser suite. Run that case, then
the parser tests. If they pass, build the selected firmware configuration.
```

Keep each test tied to a failure or a requirement. If a static analyzer is configured, ask Inlay to run it as well. See [Static analysis](/docs/core-concepts/static-analyzers.md).

## Add a board smoke test

Name the board, the port or probe, the power setup, and the pass condition:

```text theme={"theme":"css-variables"}
Build the debug image and verify its artifact. Flash the selected board and
capture UART from startup. Pass only if "self-test: pass" appears within
15 seconds; report programming and runtime results separately.
```

Programming and runtime are separate results. A missing marker is a failure, even when programming succeeded. See [Flashing](/docs/debug-mode/flashing.md) for the flash command and boot-capture limits, and [UART](/docs/debug-mode/uart.md) for port settings.

## Save a hardware script

A hardware script is a Python file under `.inlay/hardware/` that you can rerun without starting a chat. Ask for setup, a bounded measurement, pass criteria, and cleanup:

```text theme={"theme":"css-variables"}
Create a reusable sensor smoke test. Read the chip ID and three measurements,
check them against the documented ranges, and return a clear pass or failure.
Keep the test read-only after the firmware is installed.
```

Run the saved script from any of these places:

| Where | How |
| - | - |
| Chat | In **Act** or **Debug** mode, ask Inlay to run the script by name. |
| VS Code | Open the script, then select **Run Hardware Script**: the play button in the editor title bar, or the editor's context menu. |
| Terminal | From the project folder, run `inlay script sensor_smoke.py --json`. |

`inlay script` takes a path relative to `.inlay/hardware/`. These options help in a test workflow:

| Option | Use it to |
| - | - |
| `--json` | Print the script's JSON result on standard output. Script output moves to standard error. |
| `--timeout <ms>` | Stop the script after this many milliseconds. Raise it for a longer measurement. The default is `60000` (60 seconds). |
| `--profile <json>` or `--profile @file` | Pass bench-specific ports or parameters. Without it, a profile file next to the script, such as `sensor_smoke.profile.json`, is used when present. See [Supply a capture profile](/docs/debug-mode/hardware-scripts.md#supply-a-capture-profile). |
| `--project-root <path>` | Run against a project folder other than the current one. |

The command exits with `0` when the script passes, `1` when it fails, and `2` for a usage error. A script that exits normally without printing a result line also exits with `0`, so print the result line in every test script.

> [!WARNING]
>
> If a run needs to install Python packages, the terminal asks you to confirm. When the command can't ask, for example because another program started it, the install is refused and the run fails. Run each script once from an interactive terminal first.

See [Hardware scripts](/docs/debug-mode/hardware-scripts.md) for profiles, instrument helpers, and hardware cases.

## Add instrument evidence

Give the channel assignments, sample rate, duration, trigger, and tolerance:

```text theme={"theme":"css-variables"}
Capture PWM on logic channel 0 for one second. Check frequency and duty cycle
against the test limits using the achieved sample rate. Save the raw capture.
```

Follow the instrument's guide for channel numbering, voltage limits, and trigger support: [logic analyzer](/docs/debug-mode/logic-analyzer.md), [oscilloscope](/docs/debug-mode/oscilloscope.md), or [power analyzer](/docs/debug-mode/power-analyzer.md).

Hardware scripts, including instrument captures, run in **Act** or **Debug** mode. Switch to Debug mode when the test needs GDB to inspect target state. For ETM instruction trace or source coverage, see [Coverage and trace](/docs/debug-mode/coverage-and-trace.md).

## Run checks in the background or from scripts

* **From your own scripts:** run `inlay script <name>.py --json` on the computer connected to the hardware. Check the exit code and parse the JSON result.
* **From GitHub or Slack:** ask for builds, tests, and hardware checks through [automation](/docs/headless/overview.md). The machine that runs the [daemon](/docs/headless/daemon.md) needs the project's toolchain, and any board the check uses must be connected to that machine.
* **Soak tests and long captures:** ask Inlay to run the script in the background. The chat stays available while it runs. See [Run longer checks](/docs/debug-mode/hardware-scripts.md#run-longer-checks).

A [bounded loop](/docs/core-concepts/goals-and-loops.md#create-a-bounded-loop) started with `/loop` can't run shell commands, builds, flashing, live captures, or GDB. With the **Observe hardware** workload, it can only read hardware status and serial output that is already buffered or saved. Use a hardware script for a repeated hardware sequence.

## Review failures

For each failure, keep the command, firmware artifact, target, observed output, and the condition that failed. Fix the setup or the implementation, then repeat the same check. Ask Inlay to report skipped or unavailable tests explicitly, so a gap doesn't read as a pass.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.