Skip to main content

doctest-selftest

:::warning [UNTESTED] — host-run only This is a host unit-test example, not a firmware demo: the binary builds and runs on native_sim and exits 0. It has never run on real E1M silicon, and there is no board-specific behaviour to bench-verify — doctest is a pure C++ test framework with no hardware surface. :::

A minimal doctest 2.4.11 unit-test binary: three TEST_CASEs (6 assertions) over a trivial clamp() helper — the same suite as catch2-selftest, on a lighter framework.

Source: examples/testing/doctest-selftest/.

What it does

Runs the test cases from a custom main() driving doctest::Context (DOCTEST_CONFIG_IMPLEMENT, not ..._WITH_MAIN), and prints [doctest-selftest] done only when zero assertions fail. No <alp/*> wrapper — just doctest's own API.

doctest is vendored verbatim as a single header, so it has no Kconfig knob of its own; the loader emits a documentation-only comment line for the entry.

:::note Include order matters "doctest_config.h" must be included before <doctest/doctest.h>. :::

board.yaml

libraries:
- name: doctest
cores: [m55_hp]

som:
sku: E1M-AEN801

preset: e1m-evk
cores:
m55_hp:
app: ./src
peripherals: []

diagnostics:
log_level: info

som.sku and preset are present only so the project generator has a SoM to derive the baseline SoC config from.

Expected output

[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
[doctest] test cases: 3 | 3 passed | 0 failed | 0 skipped
[doctest] assertions: 6 | 6 passed | 0 failed |
[doctest] Status: SUCCESS!
[doctest-selftest] done

See also

Questions about this page? Discuss in Community Forum