Building and testing¶
This is the contributor / maintainer build doc: the CMake preset catalogue for developing the library and reproducing CI lanes locally. If you are consuming SolidSyslog in your own product (CMake or non-CMake), start at Adding it to your build instead.
All builds use CMake presets. Output goes to build/<preset>/.
TDD loop - debug / clang-debug¶
The everyday build for writing and running tests. The active preset depends on the devcontainer
service in use (debug for gcc, clang-debug for clang).
In VS Code, Ctrl+Shift+B runs the build and test and reports pass/fail in the terminal.
Clang build - clang-debug¶
Builds with Clang 19 as a second compiler, catching portability issues not caught by GCC.
When using the gcc devcontainer (normal development), run from a host terminal:
docker compose -f .devcontainer/docker-compose.yml run --rm clang cmake --preset clang-debug
docker compose -f .devcontainer/docker-compose.yml run --rm clang cmake --build --preset clang-debug --target junit
When using the clang devcontainer, Ctrl+Shift+B builds with clang-debug directly.
See Container images for how to switch.
C99 portability - c99¶
The public claim is that the Core compiles as C99. This preset is what proves
it: Core/ alone (SOLIDSYSLOG_PLATFORMS empty), at -std=c99, library only.
With no platform pack in the build, no feature-test macro or vendor header is
involved and the check is purely a language one. CMAKE_C_EXTENSIONS=OFF
selects -std=c99 rather than CMake's default -std=gnu99, and the project's
standing -Wpedantic -Werror then fails the build on anything ISO C99 forbids,
naming the file:line. Double-underscore spellings such as __typeof__ are
reserved identifiers and compile anywhere; no choice of standard catches those.
That the Core needs no POSIX is a separate property, proven by the FreeRTOS cross lanes that build it with no host platform at all.
Platform packs are best-effort C99 rather than guaranteed: Platform/StdAtomic is
C11 by construction, and a future pack may deliberately require more. The
c99-platforms preset builds the POSIX and OpenSSL packs at C99 as a drift
check, and defines _POSIX_C_SOURCE=200809L because strict ISO mode makes glibc
hide its POSIX declarations. Pinning that version rather than reaching for
_DEFAULT_SOURCE asserts the POSIX pack needs nothing beyond POSIX.1-2008. The
remaining packs are unchecked.
CI runs both presets as the build-c99 lane on every pull request.
Sanitizers - sanitize¶
Catches memory errors, use-after-free, and undefined behaviour at runtime.
Coverage - coverage¶
Builds with Clang's source-based instrumentation, runs every test executable
registered with junit, and reports lines, branches and MC/DC over the library
source with llvm-cov. Needs Clang and the LLVM tools, so run it in the
cpputest-clang image; the GCC images have neither.
Open build/coverage/report/coverage-report/index.html for the genhtml report,
which lists each file with its line and branch counts, and
build/coverage/report/mcdc-report/index.html for llvm-cov's own, which shows
each decision's conditions and the test vectors that exercised them. The report
covers every test executable registered with junit, not only the main one, so
a pack tested from its own executable counts. CI publishes the same reports as
measured on main at Coverage, so what the gate saw can
be read without building it. scripts/coverage_summary.py prints the same
measurement as a table per pack and applies the gate:
scripts/coverage_summary.py build/coverage/coverage.filtered.info \
--llvm-json build/coverage/coverage.llvm.json
The CI gate is 99% on lines, 99% on branches and 99% on MC/DC, over all packs together. A tracefile with no branch data, or a summary with no MC/DC conditions, fails the gate rather than skipping it. The target is 100%.
Static analysis - tidy¶
Runs clang-tidy on all source files. All warnings are errors.
Checks are configured in .clang-tidy.
cppcheck - cppcheck¶
Runs cppcheck static analysis on all source files.
Include-what-you-use - iwyu (advisory)¶
Runs include-what-you-use over the source set to flag missing or unused
#include directives. It inherits clang-debug, so use the clang (or
cpputest-freertos) image, not the gcc image.
Note the --target iwyu: building the bare preset does not run the tool.
IWYU is advisory, not a gate. The CI lane, analyze-iwyu, runs on every PR but
does not block the build; its findings land in the iwyu-report artifact. Sweep
that at release cleanup. See local-checks.md for the full pre-PR
check budget.
Windows build - msvc-debug¶
Builds with MSVC as a portability check against GCC and Clang. Requires a Windows
environment with MSVC, CMake 3.25+, and vcpkg. The VCPKG_ROOT environment variable
must point to the vcpkg installation.
CppUTest and OpenSSL are not installed beforehand. The repository's vcpkg.json lists
them, and the configure installs them into the build directory's vcpkg_installed/,
at the versions the manifest's builtin-baseline resolves. The first configure builds
OpenSSL from source, which takes several minutes; later ones, in any build directory,
restore it from vcpkg's binary cache.
The vcpkg checkout must be at or past that baseline. vcpkg fetches neither the baseline
commit nor the version database it needs, so against an older checkout the configure
fails with failed to git show versions/baseline.json or no version database entry.
Move the checkout to the baseline and bootstrap it again, here and whenever the
baseline moves:
git -C "$VCPKG_ROOT" fetch origin
git -C "$VCPKG_ROOT" checkout <builtin-baseline>
"$VCPKG_ROOT/bootstrap-vcpkg.bat"
A checkout that follows a branch can git pull in place of the first two commands;
anything at or past the baseline will do.
On GitHub Actions (windows-latest) the same configure runs through the
vcpkg-configure action, which first moves the runner's vcpkg checkout to the baseline
and caches the built packages between runs.
POSIX-specific code (senders, message queue buffer, clock, hostname, PID) is excluded
by the existing SOLIDSYSLOG_POSIX CMake guards. The core library and portable tests
build and pass with MSVC.
Release - release¶
Optimised build with no instrumentation. Used for the install target.
FreeRTOS cross - freertos-cross¶
ARM cross-build for FreeRTOS targets running under qemu-system-arm
(Cortex-M3, mps2-an385). Uses the freertos-target devcontainer service
or a host with arm-none-eabi-gcc + qemu-system-arm on PATH.
The ELF lands at
build/freertos-cross/Bdd/Targets/FreeRtos/SolidSyslogBddTarget.elf.
See Bdd/Targets/FreeRtos/README.md for run /
GDB-attach instructions and Bdd/README.md for driving
it under Behave + the syslog-ng oracle.
FreeRTOS + lwIP cross - freertos-cross-lwip¶
The lwIP-networking twin of freertos-cross: same ARM Cortex-M3 / mps2-an385
cross-build, but with SOLIDSYSLOG_BDD_TARGET=FREERTOS_LWIP (instead of the
default FreeRTOS-Plus-TCP) and the Bdd/Targets/FreeRtosLwip/ tunables. Drives the
bdd-freertos-lwipraw-mbedtls-fatfs-syslogng CI lane.
cmake --preset freertos-cross-lwip
cmake --build --preset freertos-cross-lwip --target SolidSyslogBddTargetLwip
The ELF lands at
build/freertos-cross-lwip/Bdd/Targets/FreeRtosLwip/SolidSyslogBddTargetLwip.elf.
CMSIS-RTOS2 + lwIP Sockets cross - cmsis-cross-lwip¶
The same ARM Cortex-M3 / mps2-an385 cross-build over a different pack set:
SOLIDSYSLOG_BDD_TARGET=CMSIS_LWIP, CmsisRtos;LwipSocket;MbedTls;LittleFs;StdAtomic,
and the Bdd/Targets/CmsisLwip/ tunables. Drives the bdd-cmsisrtos-lwipsocket-mbedtls-littlefs-syslogng CI
lane.
cmake --preset cmsis-cross-lwip
cmake --build --preset cmsis-cross-lwip --target SolidSyslogBddTargetCmsis
The ELF lands at
build/cmsis-cross-lwip/Bdd/Targets/CmsisLwip/SolidSyslogBddTargetCmsis.elf.
See Bdd/Targets/CmsisLwip/README.md for run / GDB-attach instructions.
cmsis-cross-lwip-wolfssl builds the same target with SOLIDSYSLOG_PLATFORMS
naming WolfSsl and not MbedTls. wolfSSL is compiled from the source tree at
WOLFSSL_SOURCE_DIR, which the cross image exports, under the target's own
user_settings.h. It drives the bdd-cmsisrtos-lwipsocket-wolfssl-littlefs-syslogng CI lane.
cmake --preset cmsis-cross-lwip-wolfssl
cmake --build --preset cmsis-cross-lwip-wolfssl --target SolidSyslogBddTargetCmsis
cmsis-cross-lwip-norflash builds the same target with
SOLIDSYSLOG_BDD_TARGET=CMSIS_LWIP_NOR_FLASH: its store is directly on a NOR
flash, so SOLIDSYSLOG_PLATFORMS names SpiNorFlash and not LittleFs. The
machine has no flash, and the target simulates the part. It drives the
bdd-cmsisrtos-lwipsocket-mbedtls-norflash-syslogng CI lane.
cmake --preset cmsis-cross-lwip-norflash
cmake --build --preset cmsis-cross-lwip-norflash --target SolidSyslogBddTargetCmsis
NUCLEO-F767ZI - nucleo-f767zi-*¶
ARM cross-builds for the NUCLEO-F767ZI board (STM32F767ZI, Cortex-M7 with the
hard-float ABI), under that board's toolchain file. Three are the cross BDD
targets above built with SOLIDSYSLOG_BDD_BOARD=NucleoF767zi, with the same
packs and tunables. nucleo-f767zi-cmsis-lwip names one pack more,
SpiNorFlash, the flash under its LittleFS. A fourth,
nucleo-f767zi-cmsis-lwip-norflash, is that target again with
SOLIDSYSLOG_BDD_TARGET=CMSIS_LWIP_NOR_FLASH: its store is directly on the
flash, so it names SpiNorFlash and not LittleFs. The fifth is the bring-up
firmware, which carries no SolidSyslog: SOLIDSYSLOG_PLATFORMS is empty and
the image does not link the library.
| Preset | Builds | Build target | ELF |
|---|---|---|---|
nucleo-f767zi-lwip |
The freertos-cross-lwip target |
SolidSyslogBddTargetLwip |
build/nucleo-f767zi-lwip/Bdd/Targets/FreeRtosLwip/SolidSyslogBddTargetLwip.elf |
nucleo-f767zi-cmsis-lwip |
The cmsis-cross-lwip target |
SolidSyslogBddTargetCmsis |
build/nucleo-f767zi-cmsis-lwip/Bdd/Targets/CmsisLwip/SolidSyslogBddTargetCmsis.elf |
nucleo-f767zi-cmsis-lwip-norflash |
The cmsis-cross-lwip target, with its store on the NOR flash and no filesystem |
SolidSyslogBddTargetCmsis |
build/nucleo-f767zi-cmsis-lwip-norflash/Bdd/Targets/CmsisLwip/SolidSyslogBddTargetCmsis.elf |
nucleo-f767zi-plustcp |
The freertos-cross target |
SolidSyslogBddTarget |
build/nucleo-f767zi-plustcp/Bdd/Targets/FreeRtos/SolidSyslogBddTarget.elf |
nucleo-f767zi-bringup |
The bring-up firmware | SolidSyslogNucleoF767ziBringup |
build/nucleo-f767zi-bringup/Bdd/Targets/Boards/NucleoF767zi/Bringup/SolidSyslogNucleoF767ziBringup.elf, with a raw .bin beside it |
cmake --preset nucleo-f767zi-lwip
cmake --build --preset nucleo-f767zi-lwip --target SolidSyslogBddTargetLwip
ST's HAL driver and CMSIS device files come from STM32F7_HAL_DRIVER_PATH and
STM32F7_CMSIS_DEVICE_PATH, which the cross image exports. The board's network
addresses are cache variables, and default to ones that reach nothing. CI
builds each image in its build-nucleo-* lane and never runs it.
Bdd/Targets/Boards/NucleoF767zi/README.md covers the address variables,
flashing and the target checklist.
Tunable overrides - tunable-override-debug / msvc-tunable-override¶
Both build against Tests/Fixtures/TunableOverrides.h, proving
SOLIDSYSLOG_USER_TUNABLES_FILE overrides the defaults and giving the host BDD
targets the message size the path-MTU feature needs. The commands live in
BDD testing, where they are used.
tunable-override-wolfssl is the Linux one again with SOLIDSYSLOG_PLATFORMS
naming WolfSsl and not OpenSsl, so the BDD target takes its at-rest
policies from the wolfSSL pack. It needs WOLFSSL_DIR, which the cpputest
image exports.
Installing the library¶
cmake --preset release
cmake --build --preset release
cmake --install build/release --prefix /your/install/path
This installs the static library to lib/ and the public headers to include/.
BDD tests - Behave¶
End-to-end tests run against per-target oracle pairs. The Linux pair uses the
behave-linux devcontainer service; switch to it by changing
"service": "behave-linux" in .devcontainer/devcontainer.json and
rebuilding, or run from the gcc container:
In the behave-linux container, Ctrl+Shift+B runs behave Bdd/features/ automatically.
For the FreeRTOS pair (cross-build the BDD target ELF, then drive QEMU through
Behave inside freertos-target), see Bdd/README.md.
See BDD testing for architecture details and the BDD_TARGET /
@freertoswip contract.
JUnit XML output¶
The junit target runs the tests and writes a JUnit-format XML file to the build directory.
The VxWorks 6.4 tests write theirs to vxworks64/ beneath it, so CI reports them as a group
of their own. Used by the VS Code test explorer and the CI pipeline.