Tests
Run them
Section titled “Run them”cmake --preset devcmake --build --preset devctest --preset devThe dev preset builds in Debug with AddressSanitizer and UndefinedBehaviorSanitizer, so a test that reads freed memory or overflows fails even if its assertions pass. To build the tests in another configuration, set -DMUSACAD_BUILD_TESTS=ON.
What runs
Section titled “What runs”| Test | What it checks |
|---|---|
| The unit tests (Catch2) | The geometry kernel, the store, snapshots, the command processor and every command, file reading and writing, dimensions, hatches, text. Commands are driven through the processor with no window. |
cli_check | The real program, run with no display: --help, --version, --check and --plot exit with the documented codes and write real output. |
header_hygiene_scan | The public core headers include no Qt, Vulkan, OpenGL or third-party geometry library, so the core stays independent of them. |
The unit tests are split across several binaries so that each one links quickly under the sanitizers. New test files go in the _musacad_test_files list in tests/CMakeLists.txt.
ThreadSanitizer
Section titled “ThreadSanitizer”The concurrency code (the triple buffer, the message queue, the geometry engine) is tested again under ThreadSanitizer:
cmake --preset tsan && cmake --build --preset tsanctest --preset tsanOn recent Linux kernels ThreadSanitizer can stop at startup with FATAL: ThreadSanitizer: unexpected memory mapping, because address-space randomisation is stronger than it expects. Lower it for the session:
sudo sysctl -w vm.mmap_rnd_bits=28or, without root, run the build and the tests with randomisation turned off for that process:
setarch "$(uname -m)" -R cmake --build --preset tsansetarch "$(uname -m)" -R ctest --preset tsanOnly cli_check runs the Qt program, and Qt and glib have races of their own there; tools/tsan.supp silences those for that one test. The concurrency tests run with no suppressions, so a race in Musa CAD’s own code always fails.
Self-tests in a real window
Section titled “Self-tests in a real window”Some checks need the real window and a GPU, so they run on a desktop rather than in CI:
| Variable | What it does |
|---|---|
MUSACAD_SELFTEST=1 | Opens the window, runs a set of checks (deleting, modifying, dialogs, saving, layers, annotation, grips, Dynamic Input and more) and prints [selftest] overall: PASS or FAIL. |
MUSACAD_SMOKE=1 | Shows the window and quits: a clean start. |
MUSACAD_DUMP_UI=1 | Prints the window’s widget tree, ribbon included, and quits. |
These hooks start from a fresh install’s settings and put the user’s saved Dynamic Input preference back afterwards.
For the AddressSanitizer smoke run of the full program, the windowing and graphics libraries report leaks of their own; point LeakSanitizer at tools/lsan.supp:
MUSACAD_SMOKE=1 LSAN_OPTIONS=suppressions=tools/lsan.supp ./build/dev/bin/musacad_app