]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- unit test has clang analysis.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 13 Sep 2018 10:24:08 +0000 (10:24 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 13 Sep 2018 10:24:08 +0000 (10:24 +0000)
git-svn-id: file:///svn/unbound/trunk@4901 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testdata/clang-analysis.tdir/clang-analysis.dsc [new file with mode: 0644]
testdata/clang-analysis.tdir/clang-analysis.test [new file with mode: 0644]

index c963297a5387cd84adfbace5a30689b6f89268ec..3463096b85769ac7880f439ffad5e76b7636e630 100644 (file)
@@ -9,6 +9,7 @@
          irregular program stop.
        - Free memory leak in config strlist append.
        - make sure nsec3 comparison salt is initialized.
+       - unit test has clang analysis.
 
 11 September 2018: Wouter
        - Fixed unused return value warnings in contrib/fastrpz.patch for
diff --git a/testdata/clang-analysis.tdir/clang-analysis.dsc b/testdata/clang-analysis.tdir/clang-analysis.dsc
new file mode 100644 (file)
index 0000000..20a62a3
--- /dev/null
@@ -0,0 +1,15 @@
+BaseName: 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: clang-analysis.test
+AuxFiles:
+Passed:
+Failure:
diff --git a/testdata/clang-analysis.tdir/clang-analysis.test b/testdata/clang-analysis.tdir/clang-analysis.test
new file mode 100644 (file)
index 0000000..6242a8c
--- /dev/null
@@ -0,0 +1,69 @@
+# #-- 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//"`
+       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
+read_value DNSCRYPT_SRC '^DNSCRYPT_SRC= *' $PRE/Makefile
+read_value DNSTAP_SRC '^DNSTAP_SRC= *' $PRE/Makefile
+read_value WITH_PYTHONMODULE '^WITH_PYTHONMODULE= *' $PRE/Makefile
+read_value WINAPPS '^WINAPPS= *' $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
+if test "$WITH_PYTHONMODULE" = "yes"; then PYTHONMOD_SRC="pythonmod/*.c"; fi
+if test ! -z "$WINAPPS"; then WIN_SRC="winrc/*.c"; fi
+
+cd $PRE; cd $srcdir
+# check the files in the srcdir
+fail="no"
+for x in cachedb/*.c daemon/*.c dns64/*.c $DNSCRYPT_SRC $DNSTAP_SRC edns-subnet/*.c ipsecmod/*.c iterator/*.c libunbound/*.c $PYTHONMOD_SRC respip/*.c services/*.c services/*/*.c sldns/*.c smallapp/*.c util/*.c validator/*.c $WIN_SRC $compatfiles testcode/*.c; do
+       if test "$x" = "util/configlexer.c"; then continue; fi
+       if test "$x" = "util/configparser.c"; then continue; fi
+       if test "$x" = "testcode/signit.c"; then continue; fi
+       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