]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Clang static code analysis tpkg
authorWillem Toorop <willem@nlnetlabs.nl>
Tue, 18 Nov 2025 13:04:26 +0000 (14:04 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Tue, 18 Nov 2025 13:04:26 +0000 (14:04 +0100)
.github/workflows/testsuite.yml
test/33-clang-analysis.tpkg/33-clang-analysis.dsc [new file with mode: 0644]
test/33-clang-analysis.tpkg/33-clang-analysis.test [new file with mode: 0644]

index 624b58c9f36d97c0eabebc2cbf9863dd3980f8b2..add49d0c7f18f7bddfd5c2e6569cd20dce44aa87 100644 (file)
@@ -56,7 +56,7 @@ jobs:
       - name: Set up Cygwin
         uses: cygwin/cygwin-install-action@master
         with:
-            packages: make gcc-g++ bash libtool automake autoconf libssl-devel bind-utils
+            packages: make gcc-g++ bash libtool automake autoconf libssl-devel bind-utils clang
       - uses: actions/checkout@main
         with:
           submodules: recursive
@@ -87,7 +87,7 @@ jobs:
       - name: Get the qemu container
         run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
       - name: "${{ matrix.platform }}: Build and test"
-        run: docker run --rm --interactive --mount type=bind,source=$(pwd),target=/host ${{ matrix.platform }}/alpine sh -c "apk add make gcc libc-dev libtool automake autoconf openssl-dev m4 indent bash bind-tools && cd /host && libtoolize -vci && autoreconf -vfi && ./configure && make test"
+        run: docker run --rm --interactive --mount type=bind,source=$(pwd),target=/host ${{ matrix.platform }}/alpine sh -c "apk add make gcc libc-dev libtool automake autoconf openssl-dev m4 indent bash bind-tools clang && cd /host && libtoolize -vci && autoreconf -vfi && ./configure && make test"
 
 
 #  BSDs:
diff --git a/test/33-clang-analysis.tpkg/33-clang-analysis.dsc b/test/33-clang-analysis.tpkg/33-clang-analysis.dsc
new file mode 100644 (file)
index 0000000..2d95f35
--- /dev/null
@@ -0,0 +1,15 @@
+BaseName: 33-clang-analysis
+Version: 1.0
+Description: clang analysis
+CreationDate: Wed 12 Sep 16:00:26 CEST 2018
+Maintainer: Wouter Wijngaards
+Category:
+Component:
+Depends:
+Help:
+Pre:
+Post:
+Test: 33-clang-analysis.test
+AuxFiles:
+Passed:
+Failure:
diff --git a/test/33-clang-analysis.tpkg/33-clang-analysis.test b/test/33-clang-analysis.tpkg/33-clang-analysis.test
new file mode 100644 (file)
index 0000000..dfb7595
--- /dev/null
@@ -0,0 +1,62 @@
+# #-- clang-analysis.test --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+# common functions
+. ../common.sh
+
+if test ! -x "`which clang 2>&1`"; then
+       echo "No clang in path"
+       exit 0
+fi
+#echo "have clang"
+
+# read value from Makefile
+# $1: result variable name
+# $2: string on Makefile
+# $3: Makefile location
+read_value () {
+       x=`grep "$2" $3 | sed -e "s/$2//"`
+       echo eval $1="'""$x""'"
+       eval $1="'""$x""'"
+       # print what we just read
+       #echo $1"="'"'"`eval echo '$'$1`"'"'
+}
+
+PRE="../.."
+# read some values from the Makefile
+read_value srcdir '^srcdir[    ]*= *' $PRE/Makefile
+read_value CPPFLAGS '^CPPFLAGS = *' $PRE/Makefile
+read_value LIBOBJS '^LIBOBJS           = *' $PRE/Makefile
+
+#echo dir is $dir
+# turn libobjs into C files
+compatfiles=`echo "$LIBOBJS" | sed -e 's?..LIBOBJDIR.?compat/?g' -e 's/.U.o/.c/g'`
+echo compatfiles are $compatfiles
+#echo
+
+echo "cd $PRE -- cd $srcdir"
+cd $PRE; cd $srcdir
+# check the files in the srcdir
+fail="no"
+for x in *.c $compatfiles; do
+       echo clang --analyze $CPPFLAGS $x
+       plist=`basename $x .c`.plist
+       rm -rf $plist
+       clang --analyze $CPPFLAGS $x 2>&1 | tee tmp.$$
+       if grep -e warning -e error tmp.$$ >/dev/null; then
+               fail="yes"
+               fails="$fails $x"
+       fi
+       rm -rf $plist tmp.$$
+done
+
+echo
+if test "$fail" = "yes"; then
+       echo "Failures"
+       echo "create reports in file.plist dir with     clang --analyze --analyzer-output html $CPPFLAGS""$fails"
+       exit 1
+fi
+echo "OK"
+exit 0