aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLion Kortlepel <[email protected]>2026-01-14 23:49:24 +0100
committerLion Kortlepel <[email protected]>2026-01-14 23:49:24 +0100
commita61536f9d34daf94b2824eb2f3098df5f732163f (patch)
tree7fa1ef16c951e3484d46ec1aef0930957a7c10f1 /scripts
parentca071e9ee92ea9eb139726bf8fa5433ad374fba8 (diff)
downloadqueue-a61536f9d34daf94b2824eb2f3098df5f732163f.tar.zst
queue-a61536f9d34daf94b2824eb2f3098df5f732163f.zip
tests: achieve 100% coverage in library code
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/test_coverage.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/test_coverage.sh b/scripts/test_coverage.sh
new file mode 100755
index 0000000..a097db5
--- /dev/null
+++ b/scripts/test_coverage.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# This file is mostly AI generated.
+set -eu
+
+# Absolute paths
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+ROOT_DIR="$SCRIPT_DIR/.."
+COVERAGE_DIR="$ROOT_DIR/coverage"
+
+# Clean and prepare coverage dir
+rm -rf "$COVERAGE_DIR"
+mkdir -p "$COVERAGE_DIR"
+cd "$COVERAGE_DIR"
+
+# Build test binary with coverage instrumentation
+# Also disable asserts because they do not count for us
+gcc -Wall -Wextra -fprofile-arcs -ftest-coverage \
+ -DNDEBUG \
+ ../ls_queue.h ../tests/tests.c -I../tests -I.. -o tests_cov_tmp
+
+# Run test binary (generates .gcda files here)
+./tests_cov_tmp
+
+# Generate coverage reports (all output local to coverage/)
+gcovr --root .. --object-directory . --exclude-directories tests --output coverage.txt
+gcovr --root .. --object-directory . --exclude-directories tests --html --html-details -o coverage.html
+
+echo "Coverage summary: $COVERAGE_DIR/coverage.txt"
+echo "HTML report: $COVERAGE_DIR/coverage.html"