summaryrefslogtreecommitdiff
path: root/tools/checkcov
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-08-20 16:04:41 +0000
committerpeter <peter@pmikkelsen.com>2026-08-20 16:04:41 +0000
commit3be992e3f45dcfd9f8a45fa447de3abb710819b7 (patch)
tree6cf02c89acdb0fbf12c20f03ea190a0047221db9 /tools/checkcov
parent3a81615601bf37ffc4f7b570030709ac0782e2ed (diff)
Adapt a different coding style (no typedef'ed structs, C90...), and start working on a test setup.
FossilOrigin-Name: ebb73df5fc58859b6e985c5ec84196bdd09f639dbcdc69e706f6b17652a2d413
Diffstat (limited to 'tools/checkcov')
-rwxr-xr-xtools/checkcov70
1 files changed, 70 insertions, 0 deletions
diff --git a/tools/checkcov b/tools/checkcov
new file mode 100755
index 0000000..6f2775a
--- /dev/null
+++ b/tools/checkcov
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+cd build/$1
+
+case "$1" in
+ Coverage)
+ rm -rf CMakeFiles/aplwc.dir/src/*
+ ;;
+ *)
+ ;;
+esac
+
+cmake --build .
+ctest
+
+case "$1" in
+ Coverage)
+ ;;
+ *)
+ exit 0
+ ;;
+esac
+
+gcov -tg CMakeFiles/aplwc.dir/src/*.gcno | awk '
+BEGIN {
+ FS=":"
+}
+
+function miss(t){
+ printf("%c %s:%d %s\n", t, file, line, src)
+}
+
+/^condition outcomes covered [0-9]+\/[1-9][0-9]*/ {
+ if($0 ~ /0\//)
+ skip_cond = 1
+ else
+ skip_cond = 0
+ next
+}
+
+/^condition .* not covered/ {
+ if(!skip_cond){
+ miss("C")
+ print $0
+ }
+ next
+}
+
+{
+ hits = $1
+ line = $2
+ gsub(/ /, "", hits)
+ gsub(/ /, "", line)
+
+ if(line == 0)
+ file=$NF
+
+ src = ""
+ for(n = 3; n <= NF; n++)
+ src = src $n
+
+ if(hits == "-")
+ next
+ if(hits ~ /^[1-9][0-9]*\*?$/)
+ next
+
+ miss("L")
+ next
+}
+'