Skip to content

Commit 256cf6d

Browse files
committed
Clang static code analysis tpkg
1 parent f0f6829 commit 256cf6d

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

.github/workflows/testsuite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Set up Cygwin
5757
uses: cygwin/cygwin-install-action@master
5858
with:
59-
packages: make gcc-g++ bash libtool automake autoconf libssl-devel bind-utils
59+
packages: make gcc-g++ bash libtool automake autoconf libssl-devel bind-utils clang
6060
- uses: actions/checkout@main
6161
with:
6262
submodules: recursive
@@ -87,7 +87,7 @@ jobs:
8787
- name: Get the qemu container
8888
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
8989
- name: "${{ matrix.platform }}: Build and test"
90-
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"
90+
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"
9191

9292

9393
# BSDs:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
BaseName: 33-clang-analysis
2+
Version: 1.0
3+
Description: clang analysis
4+
CreationDate: Wed 12 Sep 16:00:26 CEST 2018
5+
Maintainer: Wouter Wijngaards
6+
Category:
7+
Component:
8+
Depends:
9+
Help:
10+
Pre:
11+
Post:
12+
Test: 33-clang-analysis.test
13+
AuxFiles:
14+
Passed:
15+
Failure:
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# #-- clang-analysis.test --#
2+
# source the master var file when it's there
3+
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
4+
# use .tpkg.var.test for in test variable passing
5+
[ -f .tpkg.var.test ] && source .tpkg.var.test
6+
# common functions
7+
. ../common.sh
8+
9+
if test ! -x "`which clang 2>&1`"; then
10+
echo "No clang in path"
11+
exit 0
12+
fi
13+
#echo "have clang"
14+
15+
# read value from Makefile
16+
# $1: result variable name
17+
# $2: string on Makefile
18+
# $3: Makefile location
19+
read_value () {
20+
x=`grep "$2" $3 | sed -e "s/$2//"`
21+
echo eval $1="'""$x""'"
22+
eval $1="'""$x""'"
23+
# print what we just read
24+
#echo $1"="'"'"`eval echo '$'$1`"'"'
25+
}
26+
27+
PRE="../.."
28+
# read some values from the Makefile
29+
read_value srcdir '^srcdir[ ]*= *' $PRE/Makefile
30+
read_value CPPFLAGS '^CPPFLAGS = *' $PRE/Makefile
31+
read_value LIBOBJS '^LIBOBJS = *' $PRE/Makefile
32+
33+
#echo dir is $dir
34+
# turn libobjs into C files
35+
compatfiles=`echo "$LIBOBJS" | sed -e 's?..LIBOBJDIR.?compat/?g' -e 's/.U.o/.c/g'`
36+
echo compatfiles are $compatfiles
37+
#echo
38+
39+
echo "cd $PRE -- cd $srcdir"
40+
cd $PRE; cd $srcdir
41+
# check the files in the srcdir
42+
fail="no"
43+
for x in *.c $compatfiles; do
44+
echo clang --analyze $CPPFLAGS $x
45+
plist=`basename $x .c`.plist
46+
rm -rf $plist
47+
clang --analyze $CPPFLAGS $x 2>&1 | tee tmp.$$
48+
if grep -e warning -e error tmp.$$ >/dev/null; then
49+
fail="yes"
50+
fails="$fails $x"
51+
fi
52+
rm -rf $plist tmp.$$
53+
done
54+
55+
echo
56+
if test "$fail" = "yes"; then
57+
echo "Failures"
58+
echo "create reports in file.plist dir with clang --analyze --analyzer-output html $CPPFLAGS""$fails"
59+
exit 1
60+
fi
61+
echo "OK"
62+
exit 0

0 commit comments

Comments
 (0)