mirror of
https://github.com/Cacti/spine.git
synced 2026-10-28 23:56:43 +09:00
Split out of #542. Tests and CI only, no source file is touched, so this cannot conflict with anything currently open. Verified in a clean `ubuntu:24.04` container against develop as it stands. **Unit** — 39 cmocka assertions across three binaries, run with `make -C tests/unit`: ``` tests: 16 test(s) run. PASSED tests: 20 test(s) run. PASSED tests: 3 test(s) run. PASSED ``` `test_safety_fixes.c` covers the allocation, bounds and reap paths; `test_build_fixes.c` covers `regex_replace` and the config defaults; `test_util_strings.c` covers `strpos`. **Fuzz** — a `get_namebyhost` target with a 26-input corpus, built with `-fsanitize=fuzzer,address,undefined`: ``` #2000 DONE cov: 64 ft: 85 corp: 11/48b ``` **Integration** — the SNMPv3 fixture polls a live `snmpd` container and asserts on the rows spine wrote to `poller_output` rather than on its exit code, plus scripted checks for CLI argument handling, the script server reap, and `output_regex` column detection. **Not included.** The `fuzz_icmp_reply` target stays on #542, because it calls `spine_icmp_classify_reply()`, which that PR adds. Everything else stands on its own here. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
26 lines
1.0 KiB
Bash
Executable File
26 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Reports which lines of the poller the integration fixture actually reaches.
|
|
#
|
|
# Builds spine with gcov instrumentation in a single stage so the .gcda files
|
|
# survive in the container, runs the fixture, then reports per-file coverage.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
out=${1:-/tmp/spine-coverage}
|
|
|
|
cleanup() { docker compose -f docker-compose.yml -f docker-compose.coverage.yml down -v --remove-orphans >/dev/null 2>&1 || true; }
|
|
trap cleanup EXIT
|
|
cleanup
|
|
|
|
docker compose -f docker-compose.yml -f docker-compose.coverage.yml up --build -d
|
|
sid=$(docker compose -f docker-compose.yml -f docker-compose.coverage.yml ps -qa spine)
|
|
docker wait "$sid" >/dev/null
|
|
|
|
rm -rf "$out" && mkdir -p "$out"
|
|
docker cp "$sid:/src" "$out/src"
|
|
|
|
docker run --rm -v "$out/src:/src" debian:bookworm-slim sh -c '
|
|
apt-get update -qq >/dev/null 2>&1 && apt-get install -y -qq gcc >/dev/null 2>&1
|
|
cd /src && gcov -n *.c 2>/dev/null | grep -B1 "^Lines executed" | grep -A1 "^File .\(poller\|ping\|snmp\|util\|php\)\.c"
|
|
'
|