Automated Test Framework User Guide

For the design background, the layering model and the decision record, see tools/sdk_test/DESIGN.md in the repository (not published with the documentation site). This document only covers how to use the framework.

There are now examples you can actually run: example/test/unit_test/ (on-board Unity unit tests) and example/get-started/hello_world/ (the console and pytest harnesses).

The QEMU carrier from section 4 (customer/boards/qemu_*, rtos/rtthread/bsp/sifli/drivers_qemu/, tools/qemu/, example/qemu/) is in the tree, and the on-board unit tests run on it. Which projects are not in the tree yet, and which cases are red right now, is recorded only in section 11 — not repeated here, so the two places cannot drift apart. For the design boundary, see the table at the top of tools/sdk_test/DESIGN.md.


1. The Two Halves

+-- SDK side (tools/sdk_test/, not bound to hardware) ---------------------+
| testcase.yaml -> discovery -> matching -> build -> run -> logs + report  |
| (instance, platform) pairs -> the Lab Agent                              |
+--------------------------------------------------------------------------+
                                   | local HTTP
                                   v
                  +--------------------------------+
                  | Lab Agent (machine side)       |  holds the binding and the boards: serial / probe / relay
                  | tools/lab_agent/               |  hands out one testbed at a time
                  +--------------------------------+
                                   |
                              real board

The division of labour is one sentence: a test case declares only its needs (which fixtures, which peripherals it requires) and never contains a port number, a probe serial number or a mux channel. The physical reality all lives in the binding file on the Lab Agent side.


2. Quick Start (No Hardware Needed)

You can type this section out as it stands. The tree contains three example test case projects you can list and plan: example/get-started/hello_world/ (console and pytest), example/test/unit_test/ (on-board Unity unit tests) and example/qemu/.

. .\export.ps1                    # Windows; on Linux/macOS use source ./export.sh
# See which test cases there are
sdk.py test list -T example
sdk.py test list -T example --json          # for CI to generate a matrix
sdk.py test info                            # which harnesses / backends this build supports

# Dry run: work out the plan only, no build, no flashing
sdk.py test plan -T example/get-started/hello_world \
    -p sf32lb52-lcd_a128r16

Run the framework’s own tests (no hardware needed, and no Lab Agent either):

python -m unittest discover -s tools/sdk_test/tests -p "test_*.py"
python -m unittest discover -s tools/lab_agent/tests -p "test_*.py"
# You can also collect them with pytest; the two are compatible
python -m pytest tools/sdk_test/tests -v

2.1 After a Run: Where the Logs and Reports Are

test run produces artifacts by default (aligned with twister), with no extra flags. When it finishes, the terminal prints:

[outdir] E:\...\test-out\2026-10-03T17-09-22     ← printed before the run starts; you can tail device.log from it
[plan]  3 test(s) to run:                        ← lists what is about to run, for watching progress
        1/3  rtt/hello_world.console    (sf32lb52-lcd_a128r16, console)
        2/3  rtt/pytest/hello_world.pytest  (sf32lb52-lcd_a128r16, pytest)
        3/3  no-os/hello_world.noos     (sf32lb52-lcd_a128r16, console)

------- [1/3] rtt/hello_world.console  (sf32lb52-lcd_a128r16, console) -------
[build] rtt/hello_world.console for sf32lb52-lcd_a128r16
[run]   rtt/hello_world.console via board
[PASS ] rtt/hello_world.console on sf32lb52-lcd_a128r16_01  (25.5s)

------- [2/3] rtt/pytest/hello_world.pytest  (sf32lb52-lcd_a128r16, pytest) -------
...
[log]    E:\...\test-out\2026-10-03T17-09-22\runner.log
[report] E:\...\test-out\2026-10-03T17-09-22\sifli.json
[report] E:\...\test-out\2026-10-03T17-09-22\sifli.xml

================= rtt  (2 test(s): 2 passed) =================                 ← the tail groups by testcase
[PASS ] rtt/hello_world.console on sf32lb52-lcd_a128r16_01  (25.5s)
[PASS ] rtt/pytest/hello_world.pytest on sf32lb52-lcd_a128r16_01  (21.9s)

================ no-os  (1 test(s): 1 passed) ================
[PASS ] no-os/hello_world.noos on sf32lb52-lcd_a128r16_01  (22.3s)

3 test(s): 3 passed, 0 failed, 0 errored, 0 skipped  in 69.8s
artifacts: E:\...\test-out\2026-10-03T17-09-22

Listing the cases before the run starts, a separator line between cases, and a verdict the moment a case finishes — all three are there for the sake of “watching progress”: in a long run the only question anyone asks is “how many are left”, and the summary at the end cannot answer it. The summary at the end is in turn grouped by testcase.yaml (one directory, one file, and usually one firmware), one summary line per group, with the details of a failure indented directly beneath its line — no hunting back and forth.

Each run gets its own timestamped directory, so the previous run’s logs are not overwritten — the log of a passing test case is exactly the baseline you want when chasing a flaky one. The timestamp is local time in the 2026-10-03T17-09-22 format, and sorting lexicographically sorts by time, so the newest comes last in an ls. Two runs started within the same second automatically get -2, -3 suffixes instead of being merged into one tree.

test-out/                        ← --outdir, defaults to the directory you ran sdk.py from (gitignored)
  2026-10-03T17-09-22/
    runner.log                   run level: what this run did, and what it ran against
    sifli.json                   the main document
    sifli.xml                    JUnit, derived from the JSON
    sf32lb52-lcd_a128r16/
      ble_central_and_peripheral.peer/
        build.log                the compiler verbatim (absent with --no-build)
        device.log               the device verbatim, including the boot banner
        bt_peer-ble.log          the instrument the test drove (only when it opened one)
        runner.log               this instance's record
    qemu_sf32lb52x/
      hal_mock.spi_flash_status/
        build.log                the compiler verbatim (absent with --no-build)
        device.log               the device verbatim, including the boot banner
        runner.log               this instance's record
  2026-10-03T16-40-05/           ← the previous run, still there
    ...

Reports and logs are two independent paths: a report can be pinned to a fixed directory with --report-dir (CI needs a fixed path to collect the junit), while logs still get a directory per run. When you do not specify it, the report lands in this run’s timestamped directory too.

Compiler output does not scroll through the console; it lands in build.log. One scons run is hundreds of lines and the vast majority of it is noise, and the moment you actually want to look at it (a build failure) is exactly when it has already scrolled past. So by default only one line is printed, [build] <id> for <board>, and the full text goes into the file.

What each of these files is for, and when to look at which:

File

The question it answers

build.log

What the compiler said. The only place with an answer when a build fails — exit code 2 does not tell you whether a header is missing or a type is wrong

device.log

What the device actually said. Verbatim, byte for byte, no header and no separator lines, so you can diff it, grep it, or paste it into a ticket as-is

<fixture>.log

What an instrument said (bt_peer-ble.log). The other radio’s own words, in the same directory; absent when the case declared no instrument

instance runner.log

How the harness reached its verdict: the verdict, the per-case table, the harness’s own words, plus how much serial output was retained and whether any of it was trimmed

run-level runner.log

What this run did: how many were discovered and how many ran, which were filtered out and why, the time and the environment

The one-sentence rule for troubleshooting: when a harness reports “I saw nothing”, only device.log can tell “the device produced no output” apart from “the device produced output but the harness did not read it”.

On failure the terminal gives you the list directly, with no digging through files:

[FAIL ] hal_mock.spi_flash_status  (4.0s)  at run
        1 of 3 Unity test(s) failed: status_returned_as_reported
        FAIL  status_returned_as_reported (spi_flash:170): Expected 3 Was -559038737
        logs: <the directory above>

at run is the failure stage: plan / build / open / run / close. at build means this run never got as far as running, and the problem is in the compilation rather than in the test case — that is the distinction most worth spotting at a glance in the pile of ERRORs. Adding -i replaces the logs: line with the full serial output.

Retention policy: nothing is ever deleted — the logs of passing test cases stay, and so do those of the previous run (twister deletes both). To clean up, delete by directory: the timestamped directories under test-out/ are independent of one another, so deleting one leaves the others alone.


3. Running on Real Hardware

Two terminals.

Terminal A — start the Lab Agent on the machine with the board plugged in:

cp tools/lab_agent/examples/runner.local.yaml my-runner.yaml   # edit it following the comments
python tools/lab_agent/runner.py -c my-runner.yaml --check     # validate the config first
python tools/lab_agent/runner.py -c my-runner.yaml --list      # see which testbeds were recognised
python tools/lab_agent/runner.py -c my-runner.yaml             # start the service

Terminal B — run the test cases. The only two things you state are which platform to run on, and where the agent is:

sdk.py test plan -T example -p sf32lb52-lcd_a128r16     # look at the plan first (no hardware touched)
sdk.py test run  -T example -p sf32lb52-lcd_a128r16     # the agent allocates a free board

--agent-url already defaults to http://127.0.0.1:8760, so it can be omitted while the agent is on the same machine as you.

Exit codes: 0 everything passed, 1 some test case failed, 2 the request itself is not usable.

The SDK holds no inventory of the lab. A run is (instance, platform, backend, build dir) and nothing finer: which board of that platform will host it is not decided here and cannot be, because the agent allocates from its own configuration at the moment hardware is requested. So naming a platform is the whole of what you say — the hardware map never enters this side at all (it belongs to the hardware team, see section 8).

-p overrides a case’s own integration_platforms — the flag wins. The whole tree is pulled onto the platform you name, including cases pinned to a different one. That is exactly what “run everything on this board” wants, but it does bypass the cases’ own declarations, so do not be surprised when a cross-platform case turns up.

To run on several platforms: the command line takes only one -p today. Running the whole tree on two platforms means naming them in the cases’ integration_platforms:, or running twice.

Common flags:

Flag

What it does

-T/--testsuite-root

The directory to search recursively for testcase.yaml (default: the SDK’s example/)

-t/--testcase

Run only the given id (repeatable). Both the full id and just the tests key are supported

--tag

Select by tag (union)

-p/--platform

Name a board to build for; needed unless every test case names its own integration_platforms

--no-build

Skip the build and use what is already in build_<board>/

-j/--jobs

Number of parallel build jobs

--timeout

Override the timeout of every test case

--outdir

Artifact root, default test-out/. Each run creates a timestamped directory under it, holding this run’s run-level runner.log, the per-instance device.log/runner.log, and the reports

-i/--inline-logs

On failure, print the serial log into the terminal instead of only giving the path

--report-dir

Where the reports land; defaults to --outdir

--report-name

The report filename stem, default sifli (producing <name>.json and <name>.xml)

--report-suffix

Appended to the report filename to tell builds apart in CI (→ sifli_ci123.xml)

--report

Compatibility alias: pins the JUnit directory and filename (the extension is stripped, and the JSON lands under the same stem). Reports are produced by default now, so you normally do not need it

--fail-fast

Stop at the first failure (by default the run continues; nightly needs the full picture more)

--no-confirm

Never stop to ask mid-run. It only affects boards with reset.method: manual (see section 8). Giving it means nobody answers “has the board booted”, so the harnesses that write before they read are refused, that is, unity without autorun; console, pytest and unity with autorun are all unaffected

3.1 How the build reaches the board

It is sent as one package, so the two machines need not share a filesystem. The build happens here; the SDK side packs the two manifests in build_<board>/ (download.jlink, sftool_param.json) together with the images they name into one tar and POSTs it to the agent. The agent unpacks it into a directory of its own and flashes from there. The rest of build_<board>/ – tens of thousands of object files – is not sent; for this board the whole package comes to 420 KB.

So the agent can run on another machine: it never needs to see your build directory. Uploading the same build twice is fine – the agent names a package after its contents, so it unpacks one copy. A testbed’s packages go away when it is released.

The package carries its platform, and the agent checks it: only the side that built the image knows which board it was for, and without the check an A-board image programmed into a B board succeeds all the way to a result nobody can explain. It also carries the device name the probe needs (SF32LB52X_NAND and the like) – that is not in download.jlink, and without it a remote agent can only read the board file in its own checkout, which may be a different revision.

3.2 When the agent is not the same code as your SDK

The agent is a long-running process, quite possibly started days ago from another checkout, while your SDK keeps changing. Two layers:

  • The protocol version: a mismatch is refused outright, and the message names both sides. It only moves when the interface genuinely stops being compatible – “a field I send that you cannot read” – which is not something a version number can guess at.

  • The two revisions: recorded, never checked. A dirty worktree is a normal working state, and making it a gate would refuse to run exactly when somebody is mid-change. sifli.xml carries sdk_revision, agent_revision and sdk_protocol in its <properties>, which is where “which two revisions produced this result” is answered afterwards. Differing revisions are not an error by themselves, but they are the only clue to the most common real accident here: a long-running agent still holding old code.


4. Running Without Hardware: the QEMU Carrier

Everything this section needs is in the tree now: the framework side’s backends/qemu.py, the boards (customer/boards/qemu_*), the BSP (rtos/rtthread/bsp/sifli/drivers_qemu/) and the examples (example/qemu/), so the commands below run as written.

A real board is not the only carrier. qemu_sf32lb52x is an ordinary board name in the SDK, so the same test cases, with the same harnesses, can run with no hardware at all — no Lab Agent, no binding file, no wiring.

sdk.py test run -T example/qemu                      # console harness
sdk.py test run -T example/test/unit_test --no-build -t unit_test.qemu

The second one runs the on-board Unity unit tests (the three suites in the same image), just on a different carrier. The test case declares where it runs:

  - id: unit_test.qemu
    harness: unity
    timeout: 120
    integration_platforms: [qemu_sf32lb52x]   # with this, no binding is needed
    harness_config:
      autorun: true

You need QEMU installed locally; when it is not on PATH, point at it with SIFLI_QEMU_EXE (on this machine it is at E:\Program Files\qemu\qemu-system-arm.exe).

4.1 QEMU Boards with a Chip Identity

All five QEMU boards select a chip — there is no chipless carrier. To touch anything chip-related (bf0_hal.h, register maps, any code under #ifdef SOC_SF32LB5xx), pick the board whose series matches:

Board name

Chip identity

qemu_sf32lb52x

SF32LB52X

qemu_sf32lb55x

SF32LB55X

qemu_sf32lb56x

SF32LB56X

qemu_sf32lb57x

SF32LB57X

qemu_sf32lb58x

SF32LB58X

The same QEMU machine (mps2-an505), the same link.lds, only the chip identity differs — and that identity has to be in the board name, since --board=<name> resolves to customer/boards/<name>/hcpu and a testcase names its platform by board name.

There used to be a sixth carrier, qemu_cortex_m33, that selected no chip and served as a fake SoC. It is gone: the cases that need bf0_hal.h (CMock stubs, the HAL tests, unit_test) could not compile against it at all, and the rest run just as well on a board that names a chip.

The hal_mock commands below refer to a project that is not in this tree yet (see 7.1); they illustrate the shape, not a runnable pair.

scons --board=qemu_sf32lb52x -j8            # build directly
sdk.py test run -T example/test/hal_mock               # the test cases declare their own platform
sdk.py test run -T example/test/hal_mock --no-build -p qemu_sf32lb55x   # run on another series

What it does for you: the board’s Kconfig.board has select SOC_SF32LB5<nnn>X, and the carrier side (rtos/rtthread/bsp/sifli/drivers_qemu/SConscript) uses that to add the chip’s include paths and the three macros SF32LB<nnn>X / SOC_BF0_HCPU / USE_HAL_DRIVER, and to guarantee the include order — bf0_hal.h does #include "register.h" by name, and the chip’s copy has to win over the carrier’s own drivers_qemu/register.h.

So do not write any of this in a test project. Injecting -DSF32LB52X yourself has two traps: a compiler macro is not the same as a Kconfig symbol (the #ifndef SOC_SF32LB55X in drv_spi_flash.c will not be satisfied), and you do not control the include order — what comes out is “missing register map” or “unknown type name”, which looks nothing like the root cause. example/test/cmock_unit/ and example/test/hal_mock/ both follow this rule (neither is in this tree yet), so copy the shape when they land.

Note: these boards only exist in the KCONFIG_V2 flow that --board= goes through; the old sdk.py menuconfig without --board= cannot see them (in v1 the chip is a choice, mutually exclusive with SOC_QEMU).

Why QEMU matters: like the pc simulator, SOC_QEMU makes drivers/SConscript skip the whole drivers/ tree. That is, the image contains no HAL implementation at all, and a CMock-generated mock is the only definition of the symbol it replaces — which is exactly the precondition requirement 3 (stubbing) needs. See middleware/test_fwk/mocks/README.md for details. (Skipping is the default: a project that declares QEMU_HAL_DRIVER_ENABLED takes the tree back out of it — all of drivers/ but cmsis/, see 7.2 — that is the route the real-HAL cases take.)

A few traps (all of them silent failures):

  • Writes of a command must be rate-limited character by character (the backend defaults to 20 ms/character). Writing a whole line at once drops characters, and what you see is a command that echoes back fine but never executes — because what got dropped is exactly the trailing carriage return and line feed.

  • Line endings must be CRLF. Sending only \r gets dropped.

  • A session is not handed over as soon as QEMU starts; it waits until the device has finished booting and gone quiet before handing over, otherwise the command is sent at a moment when the UART is not yet enabled, the whole line is dropped, and what you see is “no Unity summary line found” after waiting out the full timeout.

  • The console does not go through interrupts; it is polled (measured: enabling the UART receive interrupt and unmasking every NVIC line produces no device interrupt at all). So do not expect it to reflect real interrupt behaviour.

  • The qemu_run.* and qemu_smoke_test.py under tools/qemu/ match the backend: the same -display none -monitor none -serial stdio, with SIFLI_QEMU_EXE pointing at the binary when QEMU is not on PATH. Use them to run an image outside sdk.py test.

5. Writing a testcase.yaml

Two rules to hold on to before you write the first one; every later section leans on them:

  1. Do not derive the expected strings from the source code. Copy them out of the real output (test-out/<timestamp>/<board>/<case>/device.log) and fix them in testcase.yaml, keeping them aligned with the log — the format string in that rt_kprintf and the bytes that actually arrive are not the same thing (newlines, buffer splits and prefixes all change).

  2. Do not stub a dependency that is part of board bring-up (clock, UART, MPI, the whole HAL): without it the board will not boot. Put that case on the QEMU carrier, or move the dependency behind a replaceable interface; stubbing other isolatable dependencies on a real board follows section 7.3.

Put it in the directory of the test case it measures. The id is generated from “relative path + tests key”, so do not assemble it yourself.

tests:
  - id: my_case
    description: one sentence on what this case verifies
    harness: console          # console | unity | pytest (shell not implemented)
    tags: [smoke]
    timeout: 60
    harness_config:
      ...

The full set of fields is defined by tools/sdk_test/schema/testcase.schema.json, which is the single source of truth: a wrong field name is rejected outright rather than silently ignored.

Both ways of writing it are supported. tests: can be a list (each entry carrying its own id), or a mapping (the key is the id):

tests:
  my_case:                   # the key is the id, no separate id: line needed
    harness: console
    harness_config:
      record: ["Hello world!"]
  my_other_case: ~           # an empty entry = id only, everything else takes the default

There is also a top-level common:: a set of values written there merges into every entry of tests:, and each entry’s own key of the same name wins:

common:
  tags: [smoke]
  timeout: 60
tests:
  - id: my_case              # inherits the tags and timeout above
    harness: console

Other usable fields: platform_allow / platform_exclude / integration_platforms / depends_on (matches the instance types declared in the board’s features.yaml, see section 8) / extra_args (passed through to scons) / skip / build_only / project_dir.

These fields are not all in the same state, and it is worth knowing that before you write them — several are accepted by the schema but read by no code:

Field

State

depends_on

Works. Matches the board’s features.yaml and filters before the build (stage one). If it is absent, that file is not read at all.

integration_platforms

Works, and it is the whole list: write three and it runs three times. It is not a “preferred platform”.

platform_allow / platform_exclude

Work; they still apply when --platform is given explicitly.

extra_args

Works, but what it is passed through to is the scons build, not the run.

build_only / skip

Work. skip is decided before the build, so it saves you a build.

min_flash / min_ram / slow / type / dut / dut_client

Removed: the schema no longer accepts them, so writing one is rejected outright. They used to be parsed and read by nothing. Why they went, and what they were for (resource limits, marking slow cases, multi-device), is recorded in the TODO section of tools/sdk_test/DESIGN.md.

harness: shell

Legal in the schema but not implemented; selecting it raises an error rather than passing silently.

project_dir: the test case and the project are not at the same level

A testcase.yaml usually sits next to the project rather than inside it. By default it looks, by convention, for “the directory testcase.yaml is in” or “its project/ subdirectory”; when neither matches it searches within the two levels below for a unique one, and finding several is an error rather than a guess. To point elsewhere, write project_dir (relative to the testcase file):

    project_dir: ../project     # used by example/get-started/hello_world/rtt/pytest/

6. Writing Each of the Three Harnesses

console — no test code on the device, the host matches serial output

  - id: hello_world.console
    harness: console
    timeout: 60
    harness_config:
      record:
        - "- SiFli Corporation"     # regex, matched in declaration order
        - "Hello world!"
        - "msh />"
  • Matching is done on the accumulated buffer, not line by line. RT_CONSOLEBUF_SIZE=128 splits long lines apart, and there is no global console lock, so noise gets interleaved between lines — ignore it and write normally.

  • The entries are matched in order by default (sharing one cursor). To demote an entry to “appears anywhere”, write ordered: false.

  • Repeat N times: {regex: "tick", repeat: 3}; a shortfall is reported as (2/3) rather than just “missing”.

  • Matching across lines: {regex: "Hello world!", type: "multi_line"} (line breaks are folded into spaces; separator lets you use something else).

  • The failure message names which entry is missing and appends what the device actually output.

When to use it: the assertion is “several strings appear in order”. Three lines of YAML is enough, and no dependency is needed.

unity — Unity runs on the board, the host parses its own summary

A test case looks like this:

  - id: unit_test.board
    harness: unity
    timeout: 120
    harness_config:
      autorun: true       # the firmware runs every suite itself at power-on; the host only reads the port
      # suite: lz4        # optional. Write it and you claim only lz4's results, see below

One test case = one build + one flash + one boot. The project calls sifli_unity_autorun() once in main() (CONFIG_TEST_FWK_AUTORUN, already turned on in the test project’s proj.conf), so the board runs every suite in the registry at power-on, prints all the results into one transcript, and the host just reads the serial port — you send no command, and you do not have to worry about what moment to send it at.

So do not split entries by suite. Which suites an image contains is a build fact: src/SConscript has already scanned the test_*.c actually compiled into unity_suites_gen.json. Listing them again here would write one fact in two places; and splitting them into several entries only turns into several more flashes and several more boots.

When several test cases share one image: suite claims results

One autorun writes the results of all suites into a single transcript, so a test case may have to declare who it is:

      suite: lz4          # optional. Write it and you claim only lz4's results

The host dispatches by the suite name in the result line <file>:<line>:<suite.case>:PASS|FAIL. A test case that does not write suite is responsible for the whole transcript — which is how it is written when a project has one test case (see the real-hardware example below).

Two things to remember:

  • Not a single result appeared for your own suite → failure. A transcript has only one summary line (<n> Tests <n> Failures <n> Ignored — one UnityBegin/UnityEnd around the whole loop, so that line belongs to the firmware, not to any single suite). Handing the firmware’s overall OK to a suite that ran nothing is a green light that proves nothing.

  • Another suite failing does not affect you. That is the actual shape on real hardware: in one transcript cjson and circular_buf come out PASS and lz4 comes out FAIL, independent of each other.

Two gates against a no-op run: no summary line seen → failure; the summary says 0 test cases → failure. (The latter is the most dangerous false green: linking Unity but registering no test case at all prints a clean OK.)

Why the host is not made to send unity_run: there is no reliable moment to send it — the boot banner is printed once, and before the prompt; and the prompt’s text in turn follows the build configuration. Send the command too early and it is lost, and the symptom is no Unity summary line found, which looks like broken firmware. Handing the decision to the firmware makes that timing problem go away. For the full argument, see tools/sdk_test/DESIGN.md.

prompt / cmd are needed only when the firmware waits for a command

Turn CONFIG_TEST_FWK_AUTORUN off (set it to n in proj.conf) and the board stops at the shell waiting for a command; only then does the host need those two fields. Running a single suite by hand goes that way too: flash once, then type unity_run lz4.

The reverse holds too: writing cmd or prompt alongside autorun: true is refused outright — that path does not read those two keys, and a key that has no effect is an error in this framework, never silently ignored.

    harness_config:
      prompt: "msh />"    # optional; the default is the msh prompt (msh [^>\n]*>, which
                          # takes both `msh >` and `msh />`). Wait for it to appear in the
                          # console output before sending the command; writing your own
                          # string replaces it, it does not add to it
      # cmd: unity_run    # optional; default unity_run. The command itself, sent once the wait is over

prompt answers when it is safe to send, cmd answers what gets sent. Both are replacing: write your own string and the default is no longer used — it is not “the default first, then yours”. To accept several markers, alternate them in one regex, e.g. prompt: "msh />|READY", which means “either one opens the gate” — again not one after the other.

Waiting for prompt is load-bearing, not a safety net: on a manual-reset board, the console is opened while the download has just finished writing and the board is still booting, and sending the command out at that moment means the board never receives it. The two defaults are a matched pair — cmd sends unity_run by default, and that is an msh command, which can only run if msh is already up; so prompt waits for the msh prompt by default (msh [^>\n]*>, which takes both spellings), which is exactly that precondition. For a different shell, point prompt at the readiness marker the firmware itself prints.

Not finding the prompt is not a failure: the command is sent anyway and the existing checks decide.

Two gates against a no-op run: no summary line seen → failure; the summary says 0 test cases → failure. (The latter is the most dangerous false green: linking Unity but registering no test case at all prints a clean OK.)

harness: unity does not accept record — the verdict belongs to Unity, and forcing one in raises an error telling you to use console instead. autorun is in turn unity-only: console and pytest never read it, and receiving it raises an error.

How to run it on real hardware

example/test/unit_test/ is a ready-made project. One testcase.yaml holds two test cases — one for real hardware, one pinned to QEMU — sharing one firmware, and that firmware contains three suites (lz4, cjson, circular_buf).

One test case = one build + one flash + one boot, and every suite in the image runs within that one boot. So do not split entries by suite: splitting would mean three flashes and three boots.

# Dry run: confirm what gets planned first (no hardware touched)
sdk.py test plan -T example/test/unit_test -t unit_test.board -p sf32lb52-lcd_a128r16

# Real hardware. This bench's reset.method is `auto` — the download brings the board up by
# itself, so the run needs no extra action. Autorun's results start from the first byte the
# board boots, so that boot has to happen after the serial port is open, or nobody sees it.
sdk.py test run  -T example/test/unit_test -t unit_test.board `
    -p sf32lb52-lcd_a128r16

The unit_test.qemu one is pinned to qemu_sf32lb52x, a platform this lab does not have, so test plan aborts as a whole (it is strict), while test run records it as an ERROR and carries on. So pick the real-hardware one with -t unit_test.board.

With it passing it looks like this (one test case, nine cases):

=================== unit_test  (1 test(s): 1 passed) ====================
[PASS ] unit_test.board on sf32lb52-lcd_a128r16_01  (19.0s)

The above is the shape when everything is green. In this tree that case still has one red (lz4.boundaries); its state and cause are recorded only in section 11, not repeated here.

On failure the terminal gives you which sub-case went red directly, with no digging through logs — the one below is the actual current output:

[FAIL ] unit_test.board on sf32lb52-lcd_a128r16_01  (19.0s)  at run
        1 of 9 Unity test(s) failed: lz4.boundaries
        FAIL  lz4.boundaries (test_lz4.c:129): Expected 1024 to be less than 0

In the report each case is identified as suite.case (for example lz4.boundaries): case names repeat across suites (cjson and lz4 both have boundaries), and without the suite there is no telling them apart — which is also exactly the filter syntax unity_run accepts. The parentheses hold the real source file and the line the assertion tripped on, so a failure reads as a plain file:line location.

pytest — the test case directory brings its own Python; use it when you need control flow

example/get-started/hello_world/rtt/pytest/
  testcase.yaml
  test_hello_world.py
  - id: hello_world.pytest
    harness: pytest
    timeout: 180
    project_dir: ../project
    harness_config:
      pytest_root: .              # relative to the testcase file
      # pytest_args: [-x, -k, "smoke"]
def test_the_console_is_bidirectional(dut):
    dut.send_line("")                      # ask first
    assert dut.expect(r"msh />", timeout=10), "the shell did not answer"

The dut fixture is loaded automatically by the framework (no conftest.py needed), and what it receives is the testbed the runner has already claimed, not a new board request.

Available methods: expect(regex, timeout), send_line(), write(), read(), drain(), reset(), expect_unity_test_output(timeout), symbol(name), read_memory(address, length), plus dut.testbed_id / dut.platform / dut.build_dir.

Two of them reach past the console. dut.read_memory(address, length) asks the lab’s probe for bytes of target RAM, so it needs a probe declared in the binding (jlink: or a probe flash/reset); a lab without one reports that as an error rather than skipping the evidence. dut.symbol(name) resolves an address from the ELF the build just produced and needs only the build directory, which sdk.py test run provides. A plain symbol needs the symbol table; a struct member (dut.symbol("drv_lcd.debug_cnt1")) is resolved through DWARF and therefore also needs debug information – a build without -g, or a stripped ELF, raises SymbolError for the member form.

Two semantics of expect (both load-bearing; keep them in mind when writing test cases):

  • The cursor only moves forward, and it carries across cases. dut is session-scoped, so “the device said X” means from this case onward. A prompt left over from boot does not satisfy the next case’s expect — that would be a green light proving nothing. If you want a fresh prompt, send_line first.

  • A single serial read may deliver the text this case expects and the next case’s text at the same time. Matching happens on the accumulated buffer, searching forward from the cursor, so the earlier one does not swallow the later one’s content. Do not write an implementation where one expect reads once and returns — that was a real bug once: the later one would wait out the entire timeout and then report that “the device said nothing”, pointing in a completely wrong direction.

When to use it: the assertion depends on “ask, then answer”, or you need to coordinate several boards, drive instruments, or retry. For pure assertions it is only more verbose, and it costs you an extra pytest install.

pytest is not a hard dependency of the framework: console and unity, and the framework’s own tests, are pure standard library. pytest is only there if you installed it with install.ps1 (it is already in tools/locks/default).

The peer instrument: a second board as a peer (BLE / Wi-Fi) {#peer-instrument}

Some tests need a second radio: connect, service discovery, read/write, notify (Bluetooth), or a hotspot and an echo server of their own that the test controls (Wi-Fi). The framework models that board as an instrument, not as a second dut:

  • it is not a testbed – it is never built, flashed or reset by the framework;

  • it runs a fixed firmware, flashed once by the lab;

  • it is declared in the binding, next to the DUT;

  • the test drives it over its own console through a line protocol.

The firmware. One project per instrument; two ship with the repository: example/test/bt_peer/ for BLE, and example/test/wifi_peer/ for a Wi-Fi SoftAP (it brings its own DHCP server and an echo service). One firmware can play several roles, exposed as capabilities; the pytest fixture is named after the firmware and takes the capability as its parameter — bt_peer:ble for the BLE peer used here. Build and flash it once, when the lab is set up; the suite never builds or flashes it. It is code, though: change the instrument firmware and you have to reflash it — its command set and usage live in its own README.md.

The protocol. Host and firmware speak a line protocol (peer info, peer req <id> <op> ...; the device answers @info / @ok / @err / @evt), so a response is matched by request id rather than by scraping ulog text. The host side lives in tools/sdk_test/instruments/; the command set, the rules and the host API are in tools/sdk_test/BT_PEER_DESIGN.md. The Wi-Fi side shares that wire format; its ops are ap.start (ssid= / key= / mac= / ch=), ap.stop, ap.status and state.reset. What changes between instruments is the project, not the mechanism.

The binding. The instrument is a connection on the DUT’s testbed, with its own console port:

testbed:
  - id: sf32lb52-lcd_a128r16_01
    platform: sf32lb52-lcd_a128r16
    console: {port: COM5, baud: 1000000}
    connections:
      - fixture: bt_peer:ble
        console: {port: COM9, baud: 1000000}   # the instrument's UART

The instrument’s port lives here and nowhere else: a test case still names only bt_peer:ble.

The test case. Declare the need like any other fixture, and keep it in its own entry so a lab without the instrument still runs everything else:

  - id: ble_central_and_peripheral.peer
    harness: pytest
    tags: [pytest, ble, peer]
    harness_config:
      fixture: bt_peer:ble
      pytest_root: pytest_peer

Allocation then only succeeds on a testbed that offers bt_peer:ble; a lab that has none reports this entry as an error at the open stage and runs the rest.

A fixture: reference reads name[@instance][:capability,capability]:

  • bt_peer:ble – any instrument providing ble. A lab wired as bt_peer:ble,classic satisfies it too: capabilities are matched as a subset, so an instrument with more does not lose cases that ask for less.

  • bt_peer:ble,classic – both must be present.

  • bt_peer@peer1:ble – the instrument called peer1 (its connections entry says bt_peer@peer1 too), which must also provide ble. This is how one testbed with several same-named instruments is disambiguated; driving the wrong board is worse than not running.

The suite. The bt_peer fixture returns a BtPeer; its BLE capability is bt_peer.ble, a BleInstrument. Connecting is a session-scoped fixture rather than a test, so any case that needs the link can be run on its own (pytest -k gatt):

@pytest.fixture(scope="session")
def connected_link(dut, bt_peer):
    ble = bt_peer.ble                              # verifies the firmware advertises `ble`
    ble.reset()
    link = ble.connect(ble.strongest(ble.scan()))  # scan, strongest first
    dut.expect(r"connected", timeout=30)           # whatever the DUT prints on connect
    return link

def test_gatt(bt_peer, connected_link):
    service = bt_peer.ble.discover(connected_link, service_uuid)   # UUID as read from the DUT
    handle = service.value_handle()
    bt_peer.ble.write(connected_link, handle, b"\x22\x00\x00\x00")
    assert bt_peer.ble.read(connected_link, handle) == b"\x22\x00\x00\x00"

scan / strongest / connect / discover / read / write / subscribe / wait_notification each map to one protocol op; the parsing lives in the instrument layer, so a BLE suite does not re-invent it. The peer is a session fixture: its cursor moves forward like dut’s.

The shipped example/ble/central_and_peripheral/pytest_peer/ suite instead keeps its steps as ordered tests and says so at the top – that reads well for one linear scenario. The connected_link pattern above is what a suite needs when a case must be runnable on its own.

The Classic (BR/EDR) half. An image built with the Classic stack advertises ble,classic and adds btc=1 to @info once the Classic half’s init has succeeded (event callback and IPC objects in place; an image that failed there omits it, so the SPP suite’s explicit btc=1 assertion fails before the first btc.* command). btc=1 still does not say the stack is up – the first btc.* op answers that; bt_peer.classic then hands out a BtClassicInstrument (inquiry, connect/disconnect, SPP send and receive) over the same console stream, so a dual-mode case declares fixture: bt_peer:ble,classic and uses both sub-APIs. Asking for .classic on a BLE-only image raises a capability error instead of failing at the first btc.* command. The Classic-capable image is a 58X build of the same firmware; the worked example is example/bt/spp/pytest/, and the btc.* command table (UUID byte order, link id namespace, line budget; including btc.pair – SPP must be paired before it connects) is in example/test/bt_peer/README.md.

If a suite uses bt_peer without the test case declaring fixture: bt_peer:ble, the fixture skips and says so – that is a missing declaration, not a failed test.

Known trap, not yet fixed: the harness records the pytest exit code as the verdict, and a skip exits 0, so the run above is reported as PASS. A suite that never really ran its assertions can therefore look green. The planned fix (strict mode: any skip becomes a failure when the framework drives the run; a manual pytest still skips) is a TODO in tools/sdk_test/DESIGN.md, section “TODO:pytest 的 skip 不是 PASS”. Until then, do not use skip to mean “not verified”.

The instrument’s log is kept too. When the case ends, the runner reads back every instrument console the test opened, before releasing the testbed, and writes it next to device.log as <fixture>.log (here bt_peer-ble.log; the : in a spec is not portable in a file name, so it is sanitised). A two-radio failure is then read from both sides instead of from one side’s account of the other. A stream the test never opened produces no file – an empty log would read as a silent instrument.

Constraints worth knowing:

  • The instrument is opened on the agent’s machine (the binding names its port), so a remote agent works.

  • The test picks the strongest advertisement, because the DUT’s address is not otherwise known to the agent. Keep the peer next to its DUT; the DUT-side connected assertion is what fails when it latches onto another board.

  • A bt_peer:ble connection must resolve to exactly one instrument. The fixture opens that instance; declaring the fixture more than once is an error, not a guess.

  • The instrument has no framework-driven reset. Recovery between runs is the lab’s (power-cycle), or the DUT’s own reset, which drops the link.

  • Two boards of the same model usually ship with the same MAC. When the second board plays the AP, give it a different address (rt_wlan_dev_set_mac(), called before the AP starts), or the AP’s BSSID is the DUT’s own address and the peer rejects the association as “a station may not authenticate to itself”. There is a second step: sync lwIP’s copy in netif->hwaddr (netif_find("<iface>") then rt_memcpy), because host-side frames are stamped with that copy. Skip it and the symptom is “association succeeds, DHCP never lands, every ping is lost” while scan, association and the 4-way handshake all look perfect. Assert explicitly that the peer runs at the address you chose.

USB host-side observation (usb_host) {#usb-host}

Device examples are only half-proven on the DUT console: the other half is what the host sees when the board enumerates as a USB device – the PnP identity, the CDC COM port, the mounted volume, the HID usage. usb_host is a testbed-level capability, not an instrument: the Lab Agent’s machine observes the DUT’s USB port, so the runner and the agent may live on different machines. There is no firmware to flash and no line protocol; the suite names only usb_host.

The binding. Declare it as a connection on the DUT’s testbed, with the usb: options under that connection:

connections:
  - fixture: usb_host          # bare, no :capability
    usb:
      backend: auto
      exclude_ports: []          # extra ports only; the reserved ones are automatic
      allow_fixed_drives: false
      max_file_bytes: 4194304
      serial_baud: 115200

Write usb_host, never usb_host:xxx: the fixture: grammar reads what follows : as a capability/bus check, so a suffix is a wiring error, not a parameter. The usb: block must hang under the connection – a usb: block at testbed level is refused when the binding loads. The DUT console, the instrument consoles and the download port are reserved automatically; exclude_ports only adds further ports to that set.

The test case. Declare the need under harness_config.fixture. When an instrument is needed too, use a list:

harness_config:
  fixture: usb_host
  # or, with an instrument: fixture: [usb_host, bt_peer:ble]
  pytest_root: pytest

The suite. The usb_host fixture returns a UsbHost client; every call goes through the agent’s HTTP API.

def test_cdc_frame(usb_host):
    dev = usb_host.wait_for(vid=0x38F4, pid=0xFFFF,
                            serial="2022123456", require_com=True, timeout=30)
    with usb_host.serial(dev) as port:
        port.set_dtr(True)
        frame = port.read_exact(2048, timeout=5)
    assert frame[:10] == b"1234567890"

def test_msc_readme(usb_host):
    dev = usb_host.wait_for(volume_label="SiFli MSC", timeout=30)
    volume = usb_host.volume(dev, timeout=20)
    text = volume.read_text("README.TXT")

Match on VID/PID + iSerialNumber, not on the product name. Windows binds a class driver to these devices, so the PnP product string is the INF description (“USB Serial Device”), not the firmware’s iProduct. class is a Python reserved word: pass it through the mapping form, match={"class": 10}.

Failure semantics. The fixture raises, it never skips: an undeclared fixture, an agent without the capability, or an agent older than these routes is an error, not “not run”. port_denied is a retryable UsbConflict (the OS refused the open; retry for a bounded time); forbidden_port and path_denied are permanent UsbDenied. Do not use skip to mean “not verified” – the trap above applies here too.

Bench constraint: a flash or reset is not a host-visible disconnect. The SoC re-initialises its USB stack, but D+ never drops, so Windows keeps the old address and configuration: PnP still lists the device and CreateFile succeeds, yet SetCommState fails with WinError 31 on every attempt. Device-class cases therefore need one host-visible re-enumeration before they run. The verified sequence is: unplug the DUT’s USB data cable, start sdk.py test run, and plug the cable back during the enumeration wait window. Automatic re-enumeration (an elevated device restart, a switchable hub/VBUS, a --reuse mode) is a TODO; see tools/sdk_test/DESIGN.md, section “TODO:烧录/复位后的主机可见重枚举”.

Full contract. The HTTP endpoints, error codes, client API and the per-example check points are in docs/design/usb-host-observation.md. That file is a design record kept in the repository, not part of the published documentation site – the same arrangement as BT_PEER_DESIGN.md.

Negative verification: do it before submitting

An over-permissive test case also passes on a working device, so “it is green on the board” is not evidence that the assertions are right. Before submitting, verify in the other direction and answer one question: what broken behaviour would still let this case pass? If you can answer, the assertion is too weak.

console cases can do this entirely offline, without occupying a board: feed synthetic transcripts to the real ConsoleMatcher and confirm the cases that should fail do fail. Cover all four defects – first, middle or last occurrence missing content, and out-of-order output.

The multi-occurrence trap: ordered does not bind entries to the same occurrence. A later entry only has to find its text after the cursor, so when an earlier occurrence is missing content it borrows that text from the next one. For example, splitting a report into CPU Usage: + run_time + tidle groups still passes when the first report printed only its title and the second is complete: run_time and tidle are taken from the second. To assert that one occurrence is complete, anchor it inside a single match (e.g. use the boot banner as the only anchor and (?!...). to forbid crossing the next title), or switch to pytest and split the transcript into blocks – usually more readable.

For pytest / unity cases, deliberately break one expectation (or make the command fail) once and confirm the run goes FAIL, then put it back.

Before submitting:

  • the normal path passes on a real board (or the intended carrier)

  • at least one “feature is broken” input was tried, and the case did fail

  • multi-occurrence assertions survive the first/middle/last-defect and shuffled matrices

  • expected strings come from the actual device.log, not from source or README

  • you can answer: what broken behaviour would still let this pass?


7. Writing On-Board Unity Unit Tests

For a project template, see example/test/unit_test/.

/* One test case is just a function */
void test_lz4_roundtrip(void)
{
    TEST_ASSERT_EQUAL_INT(orig_len, LZ4_compress_default(src, dst, orig_len, cap));
}

/* See the Unity documentation for how assertions are written; a failure carries file:line */

The registry is generated; do not write it by hand. src/SConscript uses test_registry.action(...) to read the test_*.c that actually take part in this project’s build, and produces unity_suites_gen.c (the sifli_unity_cases[] array — an ordinary array, not a linker section, so no linker script needs changing) and a .json manifest of the same name.

So a test case declares only one thing: its definition. The suite name and the case name are derived by the rules below, and you only need an extra line of hinting when the name you want differs from the derived one:

You want

How to write it

suite name

Name the file test_<suite>.c; when the filename does not fit, write a line suite: <name> in the file

case name

The function name minus test_<suite>_ (test_lz4_roundtrip → roundtrip); for another name, write a line case: <name> in the comment block above the function

/* Malformed input has no partial success: the parser must report NULL.
 *
 * case: malformed
 */
void test_cjson_malformed_returns_null(void)

The hint must be on a line of its own (/* case: malformed */ also works), so that a “case:” appearing in prose is not taken for a hint, and it applies only to the function directly below it.

Platform gating is automatic too: if a suite’s module cannot compile on a given carrier, SrcRemove it in src/SConscript and it disappears from the registry along with it — no more writing an #if in the registry.

Turn these on in proj.conf:

CONFIG_RT_USING_UNITY=y
CONFIG_USING_TEST_FWK=y

Device-side commands: unity_run [suite|case|suite.case], unity_list.

Mind the EOL: rt_kprintf expands \n into \r\n, middleware/test_fwk already handles that, and the host-side parser tolerates both LF and CRLF.

7.1 Stubbing: CMock

CMock itself and the mock_*.c/h generated artifacts came in with an earlier commit. The two example projects below are not in this tree yet, so the commands do not run — landing progress is recorded only in section 11. Until they land, see middleware/test_fwk/mocks/README.md for the generator and the existing mocks; the table records the intended shape.

When the branch you want to test cannot be reproduced on the bench (“erase failure”, “write timeout”, “ID mismatch”), replace that dependency with a CMock-generated mock. Two intended example projects (not yet in this tree) to copy the shape from:

Project

What it stubs

Cases

example/test/cmock_unit/

middleware functions (circular_buf_*, ipc_hw_*)

5

example/test/hal_mock/

HAL functions (HAL_QSPI_GET_SR)

3

# not implemented yet -- kept for the intended shape
sdk.py test run -T example/test/cmock_unit
sdk.py test run -T example/test/hal_mock

Both need a board with a chip identity (see 4.1), because the module under test includes bf0_hal.h.

The mechanism is “do not compile the mocked implementation”, not interception: SOC_QEMU makes drivers/SConscript skip the whole drivers/ tree, the image contains no HAL implementation at all, so the mock is the only definition of that symbol — no duplication, no weak symbols, no touching the ROM table. (Skipping is the default: a project that declares QEMU_HAL_DRIVER_ENABLED takes the tree back out of it — all of drivers/ but cmsis/, see 7.2 — and hal_mock declares no such thing, so the paragraph above is its case.)

Three points that really do bite:

  1. The size of a mock. CMock has no switch for “generate only these few functions”; it can only generate a whole header. bf0_hal_mpi_ex.h declares 593 APIs, the generated artifact is 588 KB, and the test case uses 1 of them. This is a deliberate trade-off (the generated artifacts are committed and never hand-edited), but be aware of it.

  2. GlobalExpectCount / GlobalVerifyOrder must be defined by the test project itself. With :enforce_strict_ordering turned on, the generated mock only extern-declares and assigns them, and never defines them. The link error names only the symbol, which is easy to misread as a missing library.

  3. _CallCount() is not a call count, it counts callback invocations, and under an ordinary _ExpectAndReturn it is always 0. To prove “it was called”, rely on _Verify() consuming the expectations (call it in tearDown), plus :fail_on_unexpected_calls.

Always do the reverse verification after writing one: deliberately make a mock expectation mismatch, and the test case must FAIL. Without that step you cannot prove the mock is really linked in — if what got linked is the real implementation, changing the mock would produce no reaction at all.

For the details (how the generator is run, how :strippables is written, why the chip identity must come from the board, why the link-time closure is only 2 symbols), see middleware/test_fwk/mocks/README.md.

7.2 Running the Real HAL: Registers in RAM

7.1 replaces a HAL function with a mock and measures whoever calls it; this one goes the other way, compiling the HAL implementation into the image and executing it. The first answers “what does the driver do when the HAL reports this state”, the second “are the words the driver writes to the peripheral right”. Neither covers the other: the second’s assertion grain — the exact word written, the exact place a channel lands — is not something a bench can give you.

The mechanism: SiFli’s HAL is STM32-style — the handle’s Instance is the register base, and every access in the driver is written hptc->Instance->FIELD. So a test can declare a register block of its own and hand over its address:

static PTC_TypeDef g_ptc_regs;
g_ptc.Instance = &g_ptc_regs;
HAL_PTC_Enable(&g_ptc, 1);
TEST_ASSERT_EQUAL_HEX32(expected, g_ptc_regs.IER);

Every word the driver writes lands in that variable. No linker script change, no reserved memory and no address remapping are involved: the block is an ordinary variable whose address the linker chooses, and the carrier’s own console at 0x40200000 is nowhere near it.

Getting the HAL into the image: SOC_QEMU makes drivers/SConscript skip the whole drivers/ tree, so running the real HAL in a carrier image means the project has to narrow that skip. It does so by declaring a switch of its own in Kconfig.proj:

config QEMU_HAL_DRIVER_ENABLED
    bool
    depends on SOC_QEMU
    default y

drivers/SConscript reads it and compiles the tree back out of the skip, by the SDK’s own walk — all of drivers/ but cmsis/, whose chip bring-up does not compile on a carrier and whose startup_bf0_hcpu.S would be a second Reset_Handler beside the carrier’s own — the project lists no files at all, and the objects land under build_qemu_sf32lb52x_hcpu/sifli_sdk/drivers/<subdir>/ by the same rule every other SDK module follows. example/test/hal_real/project/Kconfig.proj holds those three lines.

Why the project declares that switch, and the driver layer does not offer it: it has to be promptless, or it would appear in menuconfig, which it must not; but a promptless symbol cannot be assigned in a configuration file — check_no_promptless_assign in tools/kconfig/kconfig.py (invoked with --handwritten-input-configs from tools/build/building.py:3185) fails the build outright with

is assigned in a configuration file, but is not directly user-configurable (has no prompt)

Satisfying both at once leaves one route: the value has to come from a default, and that means the project that wants it declares it — the arrangement example/lcpu_rom/Kconfig.proj:6-8 uses for ROM_ATTR. The cost is that every HAL-testing project copies those lines again; the benefit is that a project which does not declare it cannot see the symbol at all, which is how example/test/hal_mock keeps its image free of any HAL implementation so that its CMock mock stays the sole definition of a HAL symbol (see 7.1).

What that costs: the switch brings the whole of drivers/hal back, not the two modules a case touches — 68 of its 76 .c on qemu_sf32lb52x (the other 8 are excluded by the existing per-chip logic), all 68 compiling with zero diagnostics and no unresolved symbol at the link. The cost is build time: a clean -j8 build goes from ~18–21 s to ~28–31 s. It does not mean the whole subtree reaches the image either: gcc sections each function (-ffunction-sections) and the link discards what nothing reaches (--gc-sections), so 3 of the 68 keep any code at all, 1,118 bytes. Three things you would not guess without measuring:

  • The image comes out about 4 KB smaller (.text 33,453 → 29,501 B): bf0_hal.c:56 defines __WEAK __aeabi_unwind_cpp_pr0, and libgcc’s unwind objects (libunwind.o + pr-support.o + unwind-arm.o, 4,039 B) existed only to satisfy that reference, so bf0_hal.o on the link line retires them. It is not a benefit this project asked for — on a real board bf0_hal.o is always linked.

  • drivers/hal registers no init entries at all (no INIT_*_EXPORT anywhere in it), so the usual worry that “the kept init table drags things in” does not apply here.

  • What does reach in is the vector table: bf0_hal.c:575 defines a strong NMI_Handler while drivers_qemu/startup_qemu.S:112 declares it weak, so on this carrier the HAL’s handler takes the slot. That is a real behaviour change and the tests cannot see it — NMI never fires under mps2-an505.

The limit: only entries that take Instance from the caller can be driven this way. A HAL file that reaches for a global hwp_* pointer (RCC, pinmux, AON) has no handle to point anywhere, and needs a different mechanism.

sdk.py test run -T example/test/hal_real     # no hardware, no Lab Agent, no binding

The project’s two suites (ptc, crc) share one image and the host dispatches by suite name — the same rule as section 6.

What it establishes: the driver’s decision logic and its register choreography — which bits a value goes to, which block a channel lands in, whether the table’s constants are right, which word a polling pass writes. The values written are readable afterwards, so a case asserts the exact word instead of inferring it from behaviour.

What it does not establish (these matter more than the lines above, and each case says so in its own header):

  • Timing, handshakes, interrupts, DMA completion: none of it. A polling path is testable only because the test can write the status bit beforehand: that is what test_crc.c does with CRC_SR_DONE, and the wait loop in HAL_CRC_Accumulate reads back exactly what the test put there. The other way round, a driver that polled the wrong bit, or never exited, cannot be caught here.

  • RAM cannot tell a write-1-to-clear register from a plain one. ICR |= 1 << channel clears an interrupt flag on silicon and merely sets a bit in RAM. That case therefore pins the store itself, not its effect.

Three things the first run turned up (they all cost time):

  1. setUp/tearDown is one pair per image, not one per suite. Unity reaches the pair by name from UnityDefaultTestRun(), and middleware/test_fwk/sifli_unity_runner.c defines it RT_WEAK so a project can replace it — two suites in one image each defining it is two strong definitions, and the link stops:

    test_ptc.c:100: multiple definition of `setUp';
    test_crc.c:56: first defined here
    

    So the pair lives in src/unity_main.c (which already owns the other image-wide concern, autorun), and it calls the *_fixture_reset() each suite exports, with the registers staying private to their own file.

  2. HAL_PTC_Enable() without HAL_PTC_Init() writes to address 0, and says nothing. Chn is derived by Init alone ((PTC_ChnTypeDef *)&Instance->TCR1 + Channel), and Enable never derives it; with Init left out the handle still holds the NULL setUp memsets into it, so hptc->Chn->TCR = ... lands at 0 — which on this carrier is real memory (0x0 is an alias of 0x10000000), not a fault. The assertion then reads zeros out of a register nothing wrote, and a case can pass vacuously: asserting “RCR stays 0” while the driver under test is writing to 0. The arrange step is part of the test.

  3. This carrier’s shell prompt has no slash, so the host default could not match it and every instance burned its whole timeout. finsh spells the prompt "msh " + cwd + ">", and the cwd only appears when RT_USING_DFS && DFS_USING_WORKDIR is on — which the QEMU board’s board.conf turns off, so what gets printed is msh > while the default was pinned to the cwd spelling and could never match. The symptom reads as “a slow device”: the command does not go out until the timeout expires, which does not look like a pattern that never matched. Measured on this project: 132.5 s per instance → 13.8 s, run total 265 s → 27 s. The fix went into the framework, not the test case: DEFAULT_PROMPT in tools/sdk_test/harness/unity.py now accepts msh [^>\n]*>, which takes both spellings (msh alone, or a > further down the log, does not), so this project needs no harness_config.prompt at all — that is a property of one carrier and does not belong in a test case file.

One thing worth knowing, though it is not about this section’s mechanism: HAL_PTC_GetData in drivers/Include/bf0_hal_ptc.h used to be spelled (*(hptc->Chn->TDR)), while PTC_ChnTypeDef.TDR is a plain __IO uint32_t, so expanding it could not compile. Nothing in the SDK ever expanded it, which is how it survived; hal_real is the first thing to — the last case in test_ptc.c, which reads a register back through the HAL, is what turned it up, and the header has since been fixed (the stray * gone, with a comment naming the project that found it). The case stays: it is the only one in the file that reads a register through the HAL rather than writing one, and breaking the macro again would take it out.

The full account of the mechanism and its limits is in the project’s own file headers: testcase.yaml (the whole idea), project/Kconfig.proj (why the switch is the project’s to declare), and src/test_ptc.c / src/test_crc.c (what each case establishes and what it does not).

7.3 Unit Testing Practice Guide

When testing module A with module B replaced by a mock, the hard part in this SDK is usually not CMock but the build: in Kconfig/SConscript, one switch often decides both “B’s headers are on the include path” and “B’s .c files are compiled”. Turn it on and B is in the image, leaving no room for the mock; turn it off and B’s headers cannot be found either.

The principle is to separate the three concerns and let the test project declare them explicitly, instead of letting B’s Kconfig decide the test build indirectly:

What the test build needs

Decided by

Mechanism

Which headers are visible

the test project

DefineGroup(..., src=[], CPPPATH=[...])

Which implementations are compiled

the test project

list A’s .c and the mock explicitly; never list B’s .c

Which configuration macros are visible

the test project / the carrier

define only the macros the headers need; otherwise use STUB_<B>

DefineGroup() appends CPPPATH to the shared environment even when src=[] (tools/build/building.py), so “headers only, no implementation” is already possible and needs no change to B.

Test project skeleton

example/test/<A>/
  project/
    proj.conf          # B's Kconfig stays off (except carrier dependencies such as HAL)
    Kconfig.proj       # declare a promptless STUB_<B> when needed
  src/
    SConscript
    test_a.c
  mocks/               # generated once, checked in, never hand-edited
    mock_b.c
    mock_b.h
    cmock_config.yml
# example/test/<A>/src/SConscript
import os
from building import *

cwd = GetCurrentDir()
SIFLI_SDK = os.getenv('SIFLI_SDK')

src = [
    os.path.join(SIFLI_SDK, 'middleware/<A>/<a>.c'),  # A: named explicitly
    'test_a.c',
    os.path.join(cwd, '../mocks/mock_b.c'),           # the mock
    # B's .c files are not listed
]

CPPPATH = [
    cwd,
    os.path.join(SIFLI_SDK, 'middleware/<A>/include'),
    os.path.join(SIFLI_SDK, 'middleware/<B>/include'),  # independent of whether B is enabled
    os.path.join(cwd, '../mocks'),
]

group = DefineGroup('test_<A>', src, depend=['USING_TEST_FWK'], CPPPATH=CPPPATH)

By the shape of B

Shape of B

What to do

Change B?

Standalone middleware with self-contained public headers

add B’s CPPPATH in the test project; keep B’s Kconfig off

no

A and B in the same SConscript/directory (e.g. middleware/ipc_queue/common)

do not invoke that SConscript; name A’s .c in the test project, add the directory’s include, leave B’s .c out

no

B’s public header depends on USING_<B> macros

keep B enabled, but its SConscript clears src and keeps CPPPATH under GetDepend('STUB_<B>'); the test project declares config STUB_<B> / default y in Kconfig.proj

yes (one line)

HAL / a whole subsystem

use the QEMU carrier: SOC_QEMU skips the whole tree and the carrier supplies includes and chip macros (see 4.1 and 7.1); the mock is the symbol’s only definition

no

Real board with B in bring-up (clock/UART/MPI)

do not stub: without B the board will not boot. Put the case on QEMU, or move B behind a replaceable interface (see section 11)

architecture change

For the same-SConscript case, do not use SrcRemove to edit someone else’s group: groups are global, and another SConscript may add it back; the test project compiling only the sources it names is the controllable approach.

STUB_<B> has to be promptless: a promptless symbol cannot be assigned in proj.conf, or the build fails at check_no_promptless_assign; its value can only come from default, so every test project that wants it must declare it. QEMU_HAL_DRIVER_ENABLED in example/test/hal_real/project/Kconfig.proj is that arrangement.

Where the mock lives

  • By default, the test project’s own mocks/: the expectations encode “how A’s test believes B is called”, not B’s contract; putting it in B’s group would also compile it into production firmware when B is enabled.

  • When several test projects share it, promote it to middleware/test_fwk/mocks/ — the existing mock_circular_buf, mock_ipc_hw and mock_bf0_hal_* live there.

  • Generated files are checked in and never hand-edited; commit cmock_config.yml and the generation command with them. See middleware/test_fwk/mocks/README.md for generation, :strippables and the size trade-off.

  • setUp() calls mock_b_Init(); tearDown() calls mock_b_Verify() / mock_b_Destroy(). With :enforce_strict_ordering, the test project defines GlobalExpectCount / GlobalVerifyOrder (the generated mock only declares them extern), and _CallCount() is not the call count — see 7.1.

Verification: prove B is not linked in

Check the symbols after a build:

arm-none-eabi-nm -C build_<board>/main.elf | grep -E ' <b_symbol>| mock_b'

The expectation is that none of B’s real functions are present and the mock’s symbols are the only definitions. Then reverse-verify: deliberately break one expectation and the case must FAIL — if the real implementation were linked, changing the mock would have no effect. See the end of section 6 for the general requirement.

If B is still pulled into the global build by another group or dependency, “turn B’s Kconfig off” is not enough: only STUB_<B> (so it compiles no sources) or a carrier-wide tree skip will do; nm is the final judge.

Long-term conventions

So that “any of these shapes” stops being a problem, define the module boundary like this:

  1. every module exposes its own include/, and its public headers do not depend on its own Kconfig;

  2. split SConscript groups by module; do not use depend=[] to bind A and B into one group (middleware/ipc_queue/common is the counterexample: ipc_queue.c and circular_buf.c are in one group with depend=[]);

  3. test projects always use an explicit source list, never “enable B’s Kconfig and then remove it”.

Most modules then fall into the first row; only the HAL/platform-related minority needs a carrier or STUB_<B>.


8. The binding File: Describing a Lab (the hardware team’s)

This file is usually not one you write. It describes which boards are plugged into that machine, with their serial ports and wiring — that is the job of whoever maintains the lab. A user only needs to know two things: that it exists, and that the platform names in it have to match what -p is given; if you would rather not touch it, just run with -p (see section 3).

testbed:
  - id: sf32lb52-lcd_n16r8_01
    platform: sf32lb52-lcd_n16r8      # must correspond to customer/boards/<name>
    runner: local                     # which Lab Agent holds it
    console:
      port: COM13
      # baud defaults to 1000000, the SDK console's baud rate
    connections:                       # corresponds to the testcase's harness_config.fixture
      - fixture: spi_nor_flash:spi1
        pinmap:
          - {pin: PA00, signal: CS}
      - fixture: bt_peer:ble           # an instrument, not a testbed: see section 6
        console: {port: COM9, baud: 1000000}

What a board can do is not written here. depends_on matches the board’s own declaration — customer/boards/<board>/<core>/features.yaml, which says which bus instances this board has (spi1, i2c2; an empty list is a legal declaration too, which is what the QEMU carrier has). The binding only says what is connected to what. Writing the same fact in two places is exactly how the two come to contradict each other.

# testcase.yaml: what it wants
    depends_on: [spi]                  # “there must be an spi” — not which bus
    harness_config:
      fixture: spi_nor_flash           # “a NOR flash is attached to the board” — not where it is attached

The test case writes a type name, the board writes instance names, and a type match accepts any instance of that type; writing an instance name (depends_on: [spi2], fixture: spi_nor_flash:spi2) anchors it exactly. Both axes use the same rule — because which bus has what attached to it is the board’s business, and the test case’s own code (BSP_USING_SPI1 and the like) has already settled it.

Same-named fixture = equivalent: when several testbeds offer the same fixture, a test case must reach the same conclusion whichever of them it lands on. If two boards do not satisfy that, they should not declare the same fixture.

The Lab Agent’s own settings (probe serial numbers, flashing method) are written in this file too; the agent reads all of it, and no part of it reaches the SDK side:

    jlink:
      # device: SF32LB52X_NOR     # if absent, read from customer/boards/<platform>/hcpu/rtconfig.py
      serial: "59605049"          # use -SelectEmuBySN to pick when there are several probes
      # wdt_script: tools/segger/halt_all_cpu_and_disable_all_wdt_56x.jlink
    flash:
      method: jlink               # jlink (probe) | sftool (UART)
    reset:
      method: jlink               # jlink (probe, default) | auto (the download brings it up) | manual (a person may press the button)

8.1 Field Quick Reference

If you are the one writing this file (you are the hardware team, say), only two things must be right: id and platform. The rest is either the agent’s own, or makes no difference to behaviour when read — the table marks which, so copying it will not go wrong.

A user’s only correspondence is one line: the name you give to -p has to equal some testbed’s platform.

Key

Who reads it

Notes

testbed[].id

agent

The testbed’s identifier within this run. It must not repeat within one file

testbed[].platform

agent

Decides whether a test case can land on this board. Must match the -p value exactly; the framework never adds a core suffix here. Convention: use the board name without a core suffix in both places (-p sf32lb52-lcd_a128r16) — only the build directory gets _hcpu appended. If you do include a suffix, include it in both places (-p <board>_hcpu and platform: <board>_hcpu)

testbed[].console

agent

{port, baud}. baud defaults to 1000000 (the SDK console is fixed at 1 Mbaud)

testbed[].connections[].fixture

agent

Only consulted when a test case writes harness_config.fixture. Write name, or name:param (spi_nor_flash:spi2) to anchor it exactly

testbed[].connections[].pinmap

none

Records how the wiring is done (which pin is CS/CLK). No code consumes it yet; writing it is for the hardware team to check the wiring against

testbed[].connections[].mux

agent (validation only)

Of the form mux_01.channel.3; used only to check that the mux it references really is declared under muxes:

testbed[].muxes[]

agent (id only)

Declares out-of-band switches (a relay and the like). Only id is read (for connections[].mux to reference); type / channel_num / runner are read by no code yet, and are kept for the fixture driver that will drive a relay later

testbed[].runner

agent (reporting only)

Which Lab Agent holds this testbed. It is reported in /testbeds, but takes no part in the allocation decision

testbed[].jlink / flash / reset

agent only

Probe, flashing, reset. The SDK side never sees this file — so a probe serial number in it is not a mistake; it is the agent’s own configuration

runner: (top level)

agent only

Machine-level settings (listen address, poll interval, buffer cap, probe path). The SDK side never reads them

One file, one reader: python tools/lab_agent/runner.py -c <f> reads all of it — both the testbed: part and the machine-level runner: block. So one file serves as both the lab’s hardware map and that machine’s runner config. Do not commit real COM ports.

The sub-keys of jlink: / flash: / reset: are in the annotated template tools/lab_agent/examples/runner.local.yaml — that one is written for people to copy from.


9. Wiring It Into CI

Reports are produced by default, so there is no need to write --report in your script; the logs and the report are both in this run’s timestamped directory, and the device.log / runner.log you need to look at on every failure are collected along with the ordinary artifacts (when: always, otherwise you get nothing precisely when it fails). test list --json can be used to generate the matrix (so board names are not hard-coded in the CI configuration).

In CI, use --report-dir to pin the report to a fixed path — once the directory carries a timestamp, the path test-out/sifli.xml no longer exists. Logs still get a directory per run (artifact globs are recursive, so they are unaffected):

test:
  script:
    - sdk.py test run -T example -p $PLATFORM --outdir test-out --report-dir test-out/reports
  artifacts:
    when: always
    reports:
      junit: test-out/reports/sifli.xml
    paths:
      - test-out/**/*.log
      - test-out/**/device.log

--report-suffix is for telling report filenames apart across parallel or repeated runs (the same as twister); without it the report overwrites the file of the same name under test-out/reports/ every time — that is deliberate, CI only cares about the last one. test-out/ is already in .gitignore.

(Only the hook is left in this change; no CI stage was enabled.)


10. Test Data and Credentials

Test code lives in the same repository as the code under test (one review has to be able to look at them together); test data that does not belong in git, and credentials, stay outside the repository. There are two mechanisms, in different states – do not mix them:

Chain

Holds

Stored where

State

Credentials

AP ssid/password, tokens and other non-wiring values

runner-side params.yaml (outside the repo)

P1 implemented, usable

Assets

golden files, captures, waveforms

in-repo manifest + external content store

P2 design only, not implemented

Both follow one rule: a test case writes logical names only (a fixture spec, a parameter key); the framework resolves the values and paths.

10.1 The credential chain (P1, implemented)

Three pieces of data, three responsibilities:

Data

Written in

Written by

Secret

What this lab can offer

binding (outside the repo)

the lab

no

Which options a fixture type has, and where each comes from

tools/sdk_test/fixture_types.yaml

framework maintainers (reviewed with the code)

no

The actual AP parameters and secret values

params.yaml (outside the repo)

the lab / the user

psk and anything marked secret

Only one type is parameterized today: wifi_ap (ssid is required; security is one of open/wpa2/wpa3, default wpa2; psk is required when security != open, and is secret). wifi_peer is the other Wi-Fi type, and it deliberately has no options: that instrument is a board running example/test/wifi_peer/, so the test itself chooses the SSID and the passphrase (ap.start ssid=... key=...) and nothing is taken from params.yaml.

A binding declares capability only – no ssid/psk:

# E:\code2\lab\sifli-lab.yaml (outside the repository)
testbed:
  - id: tb-52-wifi
    platform: sf32lb52-wlan-core_n16r16   # must match `sdk.py test run -p` exactly
    console: {port: COM8, baud: 1000000}
    connections:
      - fixture: wifi_ap:5g

Putting ssid/psk in a binding makes binding check fail; driver-private keys the contract does not mention only warn. For a parameterized fixture, the spec is an identity: when a test asks for wifi_ap:5g, the binding’s connection spec must equal it exactly – capability-subset matching is not used. The protocol is now PROTOCOL = 3, so mixing a new SDK with an old agent (or the reverse) gets the allocation request refused.

Minimal example:

# example/<name>/testcase.yaml
tests:
  sta_connect:
    harness: pytest
    harness_config:
      fixture: wifi_ap:5g
    params:                                  # only values that do not belong to a fixture
      cloud.token: {required: true, secret: true}
      upload.timeout_s: 30                   # a scalar is a default
    timeout: 120
# E:\code2\lab\params.yaml -- outside the repository, never committed
fixtures:
  "wifi_ap:5g":                              # the key is the spec exactly as the test wrote it; quote it because of the colon
    ssid: SiFli-Test-5G
    security: wpa2
    psk:
      value: "..."
      secret: true

params:                                      # same names as the testcase declaration, no params. prefix
  cloud.token:
    value: "..."
    secret: true

The secret flag on fixtures options is decided by the contract, so the file need not repeat it; params keys have no contract, so the file declares secret itself. When CI supplies a value through the environment, secret: true must still be in the testcase declaration – otherwise the value is neither redacted nor subject to the loopback guard.

On the pytest side:

def test_connect(dut):
    ap = dut.fixture_options("wifi_ap:5g")     # only the options this instance needs
    if ap["security"] == "open":
        dut.send_line(f'wifi join "{ap["ssid"]}"')
    else:
        dut.send_line(f'wifi join "{ap["ssid"]}" "{ap["psk"]}"')


def test_upload(dut, params):
    timeout = params["upload.timeout_s"]       # declared params keep their declared names

When security: open, psk is absent from the returned mapping (the conditional requirement does not hold). A misspelled spec raises “unknown fixture”; a misspelled option is a KeyError, never a silent None.

File discovery order (the first file that exists wins):

  1. --params-file <path>

  2. SIFLI_TEST_PARAMS_FILE

  3. %USERPROFILE%\.sifli\test-params.yaml (Windows) / ~/.sifli/test-params.yaml (POSIX)

Per-key precedence (highest first):

  1. --param KEY=VALUE (for debugging; it lands in shell history)

  2. SIFLI_TEST_PARAM_<KEY> (upper case, non-alphanumerics become _)

  3. params.yaml

  4. the default in the testcase or the contract

Keys are flattened first: fixtures.wifi_ap:5g.psk becomes SIFLI_TEST_PARAM_FIXTURES_WIFI_AP_5G_PSK. : also becomes _, so wifi_ap:5g and wifi_ap_5g collide; a collision is an error, not a guess.

Put the file’s location in your own shell profile, not in the repository’s export.ps1:

$env:SIFLI_TEST_PARAMS_FILE = 'E:\code2\lab\params.yaml'

Commands (none of them contact an agent):

# Is the configuration complete? Before any build; prints key names and sources, never values.
sdk.py test params check -T example --params-file E:/code2/lab/params.yaml
sdk.py test params check -T example --case <id> --unused --json
# Has the binding put a params-sourced key into the wiring?
sdk.py test binding check --file E:/code2/lab/sifli-lab.yaml
# Planning uses the same resolution and the same loopback rule as a run.
sdk.py test plan -T example -p sf32lb52-wlan-core_n16r16 --params-file E:/code2/lab/params.yaml
  • params check and test plan both accept --agent-url / --params-file / --param; --agent-url is used only for the loopback decision, and neither command contacts a Lab Agent. binding check takes its path from --file or SIFLI_TEST_BINDING; there is no default search.

  • params check exits non-zero (10) on a missing required key, listing the missing keys, the files it searched and the per-key overrides that would supply them. It does not skip.

  • test list --json gives each instance a params array of key names (fixture options expanded from the contract) and never a value – so it works on a machine with no credentials.

Redaction and known leak surfaces:

Host-side artifacts (device.log, runner.log, <fixture>.log, sifli.json, sifli.xml) are redacted in memory, including the failure path. Whenever any secret value is resolved, a plan fails unless the agent URL’s host is a loopback address (127.0.0.1 / ::1 / localhost); only an explicit SIFLI_TEST_ALLOW_REMOTE_SECRETS=1 lets it through.

That does not mean a password appears nowhere. P1 has three known leak surfaces:

  1. The test writes the psk to the DUT through POST /testbed/{id}/console/write, so it crosses the unauthenticated agent HTTP in clear text;

  2. The psk stays in the agent’s 4 MB in-memory console buffer until new output pushes it out or the agent restarts;

  3. The DUT’s wlan driver prints the password at debug level, so it enters the DUT-side log and the transcript the agent forwards; the forwarded copy on the host is redacted, the DUT’s other log backends are not.

P1 is therefore intended for a local or trusted lab network only. Removing 1/2 needs P3 (assembling the command on the agent side); removing the DUT’s own logging in 3 needs the firmware to disable that log, or the agent to redact at the source.

Discovering fixture vocabulary and pre-checking a lab:

  • The type catalogue lives in the repository (tools/sdk_test/fixture_types.yaml) and answers “which names and capability tokens may I write”:

    sdk.py test fixtures types
    

    Catalogue entries carry descriptions, capability vocabularies and option contracts only; they do not say how many devices a lab has – the inventory belongs to the binding.

  • What this lab actually offers (a parameterized fixture’s spec must match exactly, so this is the authoritative answer):

    sdk.py test fixtures list --agent-url http://127.0.0.1:8760
    sdk.py test fixtures list --file E:/code2/lab/sifli-lab.yaml
    
  • Check the case against the lab before building:

    sdk.py test plan -T example -p sf32lb52-wlan-core_n16r16 --check-fixtures
    

    A harness_config.fixture list means “all of these”: one testbed must offer all of them. skip / build_only cases are not pre-checked. An unreachable agent or an incomplete response is an error, never “the lab has no such fixture”.

  • A case naming a type that is not in the catalogue gets a warning (labs may define their own types); SIFLI_TEST_STRICT_FIXTURES=1 upgrades it. Unknown capability tokens of a known type also warn without blocking.

10.2 The asset chain (P2, design only, not implemented)

Large vectors (golden files, captures, waveforms) are designed as: a manifest in the repository, the bytes in an external content store, with a local sha256-addressed directory serving as both cache and verification basis. A fixture expresses capability only (what is wired on this board); it does not carry data.

P2 is not implemented: assets: in testcase.yaml, tools/sdk_test/assets.yaml, the pytest asset("name") fixture and sdk.py test assets list|fetch|verify|add are all unavailable today (assets: is rejected by the schema). Storage layout, sensitive vectors and verification rules are in docs/design/test_data_and_secrets.md section 8. No acceptance case needs a vector at present.

Do not commit large vectors to git: git history only grows, and a 200 MB file committed once stays in every clone forever, and deleting it afterwards does not help.


11. Known Limitations and Troubleshooting

Not implemented

Item

State

harness: shell

raises an explicit error, will not spin silently

backends/pc_sim.py

stub (the pc simulator is still at the design stage)

Multi-device scheduling (requirement 4)

the schema and the plugin interface support it; the actual scheduling is not done

Relay / power control

transport/relay.py has only the interface and raises RelayNotAvailable

backends/qemu.py

implemented: the QEMU carrier can run console/unity/pytest, see section 4

CMock stubbing cases

delivered on a follow-up branch; not in this tree yet, so the commands do not run — see 7.1 and middleware/test_fwk/mocks/README.md

Real-HAL cases

delivered: example/test/hal_real/ with two instances (hal_real.ptc, hal_real.crc), sdk.py test run -T example/test/hal_real, see section 7.2

Per-instance build.log

implemented: compiler output goes to disk instead of flooding the console

Test parameters and the credential chain (params: / fixture contract / params.yaml)

implemented (P1): params check, binding check, pytest’s params and dut.fixture_options, see section 10

Asset chain (assets: / assets.yaml / asset() / test assets)

not implemented (P2): design in docs/design/test_data_and_secrets.md section 8

Agent-side secret execution, agent authentication

not implemented (P3): P1’s psk still crosses unauthenticated agent HTTP in clear text, see section 10

Troubleshooting

  • Cannot reach the Lab Agent → terminal A was not started, or --agent-url is wrong.

  • every testbed matching the request is busy → somebody is holding it; the Lab Agent’s own python tools/lab_agent/runner.py -c <cfg> --list marks which testbeds are busy.

  • missing fixture(s) [...] (testbed offers: ...) → this lab does not have what the test case needs; both sides are listed in the message, so compare them directly.

  • A build failure is recorded as an ERROR for that test case and does not abort the whole round — so one round shows you every problem at once. at build is that case: the stage field in the terminal and in the artifacts tells you directly which stage failed (plan/build/open/run/close), with no guessing. The compiler’s own words are in build.log in the same directory (the failure message points at it too).

  • The serial port will not open: the Lab Agent side reports the port as occupied — check whether another terminal tool is connected to the same board.

  • Seeing console: N bytes retained, M trimmed from the head in a log → the serial output exceeded the backend’s 4 MB retention window and the head was cut off. This line appears only in the header of the instance runner.log; do not treat a trimmed device.log as the whole thing.

Two things you must remember

Written at the start of section 5; this is just the reminder: copy the expected strings out of the real output instead of deriving them from the source, and do not stub a dependency that is part of board bring-up (clock, UART, MPI, the whole HAL) — without it the board will not boot.