OpenBoot
Draft: this page is not reviewed yet.

Host testsDraft

OpenBoot has host tests that need no board. They cover pure logic and the tools around the firmware; they run on a Linux or macOS development machine. They do not replace a hardware run: see the hardware gate rule.

Python 3.11 or newer is assumed throughout (the device generator and the documentation builder use tomllib).

The suites#

Suite Directory Run with What it covers
Debug core and firmware logic tests/dbg_host make -C tests/dbg_host test (no trackpad firmware and no extra flags needed; see below) C code of OpenBoot compiled for the host with a C compiler (clang) and run against fake memory and fake devices: the hold decision, the OBLink engine, the monitor, USB controller logic, boot policy, the NVRAM settings and their writer, EL2 stage-2 and interrupt logic, the NVMe mediator, CPU performance logic and more. Also shell checks (check_*.sh) that guard build rules.
Hardware-run launcher tests/hwrun_host python3 -m pytest -q tests/hwrun_host tools/hw-run: the event matcher, the screen classifier, the safety refusals, firmware identification, the chain's state machine replayed against recorded console and monitor output. No hardware, no network.
OBLink host side tests/oblink_host python3 -m pytest -q tests/oblink_host The frame codec and decoder, the link, handshake, monitor round trips and image push with resume, against a simulated device on a pseudo-terminal. The link tests need pyserial and are skipped where it is not installed.
Device descriptors tools/devgen/tests and a check python3 -I tools/devgen/devgen.py --devices devices --check and python3 -I -m unittest discover -s tools/devgen/tests -q The generator that turns devices/<soc>/<board>.toml into the compiled-in table: validation, limits, the generated output. The first command validates every descriptor in the tree.
ADT sanitiser tools/adtsan/tests and a check python3 -I -m unittest discover -s tools/adtsan/tests -q The allowlist-based sanitiser for device-tree dumps. tests/dbg_host/check_adtsan.sh also checks that every device-tree fixture committed under tests/dbg_host/fixtures passes the allowlist.
Installer tests/installer_host bash tests/installer_host/run.sh The installer's shell and Python parts against fake tools and synthetic fixtures: planner, partitioning and prediction, the stub builder, the 1TR step 2 script (test_step2.sh), hand-off and verify, uninstall and legacy-group removal (remove-legacy), and the hardware-gate scripts (test_gates.sh, test_c9_gate.sh, none of which has run on hardware). A macOS-only part is in tests/installer_mac.
Documentation tests/docs_host python3 -m pytest -q tests/docs_host The documentation builder and its gates: output is deterministic, bad pages are rejected, the page sets agree. It needs the pinned dependencies of tools/docs/requirements.txt and pytest, which the pin file does not contain.

Other directories under tests/ hold the host tests of individual drivers and tools.

The debug-core suite in more detail#

tests/dbg_host/Makefile builds one test binary per group from test_<group>.c plus a shared runner. A group is listed in the GROUPS variable; make test builds every group, runs each, then runs every check_*.sh and the script tests.

The suite needs no firmware file. If the trackpad firmware plist (MTFW_PLIST) is not present, the Makefile sets MTFW_NONE=1 for the images the checks build, and the checks that need a finished firmware build or a real firmware blob report SKIP instead of failing. Checks that look at a finished firmware build, such as the librust.a rebuild check, are skipped on a tree where openboot.bin has not been built. clang is required; gdb-multiarch and lldb are optional.

Groups that relate to the topics of these pages:

Group Covers
hold, hold_ondemand The hold verdict: no plug, the connect window edges, the plain-USB handshake rule, which verdicts start the debug core.
oblink The OBLink engine against the protocol: the check value of the CRC, the HELLO reply, the receiver splitting frames any way, damaged and oversized frames, the 500 ms partial-frame timeout, console sanitising, the monitor bridge, push with resume, refusals and unknown types.
oblink_usb The glue between the USB gadget and the engine.
boot_policy, boot_fail, ob_settings, ob_settings_write, ob_menu The menu and settings: the policy decision, the failure counter, parsing of ob-* variables and the writer's rules.
devlayout, devtable, devident, devtopo, oblayout The device table and layout logic that descriptors feed.
obslot, fwpin, mtfw_src The measured install slot (versions 1 and 2, the pinned firmware and its ESP), the firmware pin check, and where the trackpad firmware comes from. check_wlan_toctou.sh and check_wlanpt_source.sh hold the firmware loader's ordering and lookup rules; check_mtfw.sh the release build's missing trackpad blob.

The shell checks guard properties that a unit test cannot, for example that a file never names a flash opcode other than the read ones, that a no-write image links no write path, that built images keep their layout, and that fixtures contain only allowlisted device-tree properties.

The hardware gate rule#

Host tests prove logic. They do not prove that code works on the machine. The project's policy for code that touches hardware is:

  • Hardware code runs on hardware first. A register sequence or a bring-up path is first tried on the board, in a hardware run, and the result is observed.
  • Tests follow from what the board did: a capture of the real behaviour becomes a fixture or a replay, and the host test guards it from then on. There is no required red-first ritual for such code.
  • Test-first is expected for safety rules and for pure logic: the hold decision, framing and CRC, the NVRAM settings writer's rules, the no-write proofs, parsers that read untrusted data.
  • A hardware gate that has not been run is said so in the documentation of the feature; a green host suite is never described as a hardware result.

Not verified#

  • Counts of tests change as the code does and are not stated here.
  • Which suites run in the public CI is not stated here; the commands above were run on a development machine, not taken from a CI configuration.