From: Wouter Wijngaards Date: Thu, 13 Sep 2018 10:24:08 +0000 (+0000) Subject: - unit test has clang analysis. X-Git-Tag: release-1.8.1rc1~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=635df9c80629cff457646eb6276db686e62c8e26;p=thirdparty%2Funbound.git - unit test has clang analysis. git-svn-id: file:///svn/unbound/trunk@4901 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index c963297a5..3463096b8 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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 index 000000000..20a62a3e3 --- /dev/null +++ b/testdata/clang-analysis.tdir/clang-analysis.dsc @@ -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 index 000000000..6242a8c99 --- /dev/null +++ b/testdata/clang-analysis.tdir/clang-analysis.test @@ -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