# Test map ## Top-level test directories | Path | Runner | Purpose | |---|---|---| | `tests/unittests/` | cmocka via `make check` | Unit tests with stubbed dependencies. | | `tests/functionaltests/` | custom binary, runs against a real cproof | End-to-end behaviour tests. | | `tests/bench/` | custom benches, one binary per runner | Database / flatfile / long-message benchmarks. | | `tests/prof_cmocka.h` | — | Thin cmocka wrapper used by all unit tests. | ## `tests/unittests/` layout - `unittests.c` — single test runner. Registers every test via `cmocka_unit_test()` / `cmocka_unit_test_setup_teardown()`. - `helpers.c` / `helpers.h` — shared test utilities. - `test_.c` + `test_.h` — paired test files. The header declares each test function; the runner includes the header to register it. - Per-module subdirectories carry **stubs** for that module's public symbols: | Stub directory | Stubs for | |---|---| | `tests/unittests/chatlog/` | `src/chatlog.c` | | `tests/unittests/command/` | `src/command/` | | `tests/unittests/config/` | `src/config/` (accounts, cafile, etc.) | | `tests/unittests/database/` | `src/database.c` | | `tests/unittests/event/` | `src/event/` | | `tests/unittests/log/` | `src/log.c` | | `tests/unittests/omemo/` | `src/omemo/` | | `tests/unittests/otr/` | `src/otr/` | | `tests/unittests/pgp/` | `src/pgp/` | | `tests/unittests/plugins/` | `src/plugins/` | | `tests/unittests/tools/` | `src/tools/` | | `tests/unittests/ui/` | `src/ui/` | | `tests/unittests/xmpp/` | `src/xmpp/` | | `tests/unittests/unittests/` | top-level utility stubs | Branch-specific stubs (e.g. `tests/unittests/ai/` on `feat/ai`) are not listed here — see `wip/` for branch notes. Each stub file is named `stub_.c`. See `testing/stubs.md` for when to add or extend a stub. ## `tests/functionaltests/` layout - `functionaltests.c` — runner. - `proftest.c` / `proftest.h` — fixture: spawns cproof under PTY, talks XMPP. - `test_.c` — feature suites: connect, disconnect, message, presence, carbons, roster, history, ping, autoping, lastactivity, software, disco, receipts, rooms, muc, chat_session, export_import. Functional tests require: - A test XMPP server reachable from the test harness. - A pre-baked `.profrc` (see recent perf work). - See `testing/functional-tests.md` for prerequisites and runner flags. ## `tests/bench/` layout Each runner is a separate directory + binary: | Runner | Measures | |---|---| | `bench_runner` | Combined runner for general bench scenarios. | | `bench_export_import` | Database export/import throughput. | | `bench_failure_modes` | Flatfile parser failure / recovery paths. | | `bench_long_messages` | Flatfile parser with very long messages. | | `gen_history` | Generates synthetic chat history for benches. | See `testing/bench.md` for invocation and interpretation.