|
libwebsockets
Lightweight C library for HTML5 websockets
|
lws can be built with gcov-format coverage instrumentation, with gcc or clang, and a script summarizes what the ctest run actually executed.
-DLWS_WITH_GCOV=1 adds -fprofile-arcs -ftest-coverage to every object in the tree. Each test process writes its counters (.gcda files next to the objects) when it exits normally; ctest just runs the tests as usual. Tests that are killed, or time out, flush nothing and so contribute nothing.
make coverage runs scripts/coverage-report.py, which drives gcov (or llvm-cov gcov for a clang-built tree) over every .gcno in the build tree, merges the results per source file and prints, for lib/:
Counters accumulate across runs until the .gcda files are deleted (find . -name '*.gcda' -delete in the build tree), so a report after running a single test shows only what that test reached.
The script runs from the build directory and takes the compiler and the source directory from its CMakeCache.txt. Options:
LWS_GCOV="llvm-cov gcov" in the environment overrides the reader matched to the compiler.
It only reports. It exits 0 even when it cannot find a reader or read some of the data files, and says so in the output.
The coverage configuration in .sai.json builds distro_recommended instrumented on the rocky9-ca/aarch64-a72a55-rk3588/clang platform, with fault injection, http stream compression (deflate and brotli) and ws permessage-deflate forced on so their tests are in the run, then runs ctest and prints the report into the job log; build/coverage-summary.json is kept as an artifact. A clang-built tree needs llvm-cov on the builder to read the counters; without it the report says so and the job is not affected. The builder also needs the brotli development package.
lws-api-test-http-compression is the transfer check for the compression paths: it serves a generated multi-megabyte text file named after its own sha256 and fetches it back over h1 and h2c with each content-encoding, decoding client-side and checking the digest against the name.