summaryrefslogtreecommitdiff
path: root/tools
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
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')
-rwxr-xr-xtools/check15
-rwxr-xr-xtools/checkcov70
-rwxr-xr-xtools/tests8
3 files changed, 93 insertions, 0 deletions
diff --git a/tools/check b/tools/check
new file mode 100755
index 0000000..a6c5d20
--- /dev/null
+++ b/tools/check
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+types="Debug Release Coverage"
+
+mkdir build
+cd build
+
+for type in $types
+do
+ rm -rf $type
+ cmake .. -B $type -DCMAKE_BUILD_TYPE=$type
+done
+
+cd ..
+fossil ls | entr -c tools/tests $types
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
+}
+'
diff --git a/tools/tests b/tools/tests
new file mode 100755
index 0000000..66ac467
--- /dev/null
+++ b/tools/tests
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+types=$*
+
+for type in $types
+do
+ tools/checkcov $type
+done