]> git.ipfire.org Git - thirdparty/strongswan.git/blob - scripts/test.sh
travis: Bump wolfSSL to 4.3.0
[thirdparty/strongswan.git] / scripts / test.sh
1 #!/bin/sh
2 # Build script for Travis CI
3
4 build_botan()
5 {
6 # same revision used in the build recipe of the testing environment
7 BOTAN_REV=2.12.1
8 BOTAN_DIR=$TRAVIS_BUILD_DIR/../botan
9
10 if test -d "$BOTAN_DIR"; then
11 return
12 fi
13
14 echo "$ build_botan()"
15
16 # if the leak detective is enabled we have to disable threading support
17 # (used for std::async) as that causes invalid frees somehow, the
18 # locking allocator causes a static leak via the first function that
19 # references it (e.g. crypter or hasher), so we disable that too
20 if test "$LEAK_DETECTIVE" = "yes"; then
21 BOTAN_CONFIG="--without-os-features=threads
22 --disable-modules=locking_allocator"
23 fi
24 # disable some larger modules we don't need for the tests
25 BOTAN_CONFIG="$BOTAN_CONFIG --disable-modules=pkcs11,tls,x509,xmss"
26
27 git clone https://github.com/randombit/botan.git $BOTAN_DIR &&
28 cd $BOTAN_DIR &&
29 git checkout -qf $BOTAN_REV &&
30 python ./configure.py --amalgamation $BOTAN_CONFIG &&
31 make -j4 libs >/dev/null &&
32 sudo make install >/dev/null &&
33 sudo ldconfig || exit $?
34 cd -
35 }
36
37 build_wolfssl()
38 {
39 WOLFSSL_REV=v4.3.0-stable
40 WOLFSSL_DIR=$TRAVIS_BUILD_DIR/../wolfssl
41
42 if test -d "$WOLFSSL_DIR"; then
43 return
44 fi
45
46 echo "$ build_wolfssl()"
47
48 WOLFSSL_CFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB"
49 WOLFSSL_CONFIG="--enable-keygen --enable-rsapss --enable-aesccm
50 --enable-aesctr --enable-des3 --enable-camellia
51 --enable-curve25519 --enable-ed25519"
52
53 git clone https://github.com/wolfSSL/wolfssl.git $WOLFSSL_DIR &&
54 cd $WOLFSSL_DIR &&
55 git checkout -qf $WOLFSSL_REV &&
56 ./autogen.sh &&
57 ./configure C_EXTRA_FLAGS="$WOLFSSL_CFLAGS" $WOLFSSL_CONFIG &&
58 make -j4 >/dev/null &&
59 sudo make install >/dev/null &&
60 sudo ldconfig || exit $?
61 cd -
62 }
63
64 build_tss2()
65 {
66 TSS2_REV=2.3.1
67 TSS2_PKG=tpm2-tss-$TSS2_REV
68 TSS2_DIR=$TRAVIS_BUILD_DIR/../$TSS2_PKG
69 TSS2_SRC=https://github.com/tpm2-software/tpm2-tss/releases/download/$TSS2_REV/$TSS2_PKG.tar.gz
70
71 if test -d "$TSS2_DIR"; then
72 return
73 fi
74
75 echo "$ build_tss2()"
76
77 # the default version of libgcrypt in Ubuntu 16.04 is too old
78 sudo apt-get update -qq && \
79 sudo apt-get install -qq libgcrypt20-dev &&
80 curl -L $TSS2_SRC | tar xz -C $TRAVIS_BUILD_DIR/.. &&
81 cd $TSS2_DIR &&
82 ./configure --disable-doxygen-doc &&
83 make -j4 >/dev/null &&
84 sudo make install >/dev/null &&
85 sudo ldconfig || exit $?
86 cd -
87 }
88
89 if test -z $TRAVIS_BUILD_DIR; then
90 TRAVIS_BUILD_DIR=$PWD
91 fi
92
93 cd $TRAVIS_BUILD_DIR
94
95 TARGET=check
96
97 DEPS="libgmp-dev"
98
99 CFLAGS="-g -O2 -Wall -Wno-format -Wno-format-security -Wno-pointer-sign -Werror"
100
101 case "$TEST" in
102 default)
103 # should be the default, but lets make sure
104 CONFIG="--with-printf-hooks=glibc"
105 ;;
106 openssl*)
107 CONFIG="--disable-defaults --enable-pki --enable-openssl --enable-pem"
108 export TESTS_PLUGINS="test-vectors pem openssl!"
109 DEPS="libssl-dev"
110 ;;
111 gcrypt)
112 CONFIG="--disable-defaults --enable-pki --enable-gcrypt --enable-pkcs1"
113 export TESTS_PLUGINS="test-vectors pkcs1 gcrypt!"
114 DEPS="libgcrypt11-dev"
115 ;;
116 botan)
117 CONFIG="--disable-defaults --enable-pki --enable-botan --enable-pem"
118 export TESTS_PLUGINS="test-vectors pem botan!"
119 # we can't use the old package that comes with Ubuntu so we build from
120 # the current master until 2.8.0 is released and then probably switch to
121 # that unless we need newer features (at least 2.7.0 plus PKCS#1 patch is
122 # currently required)
123 DEPS=""
124 if test "$1" = "deps"; then
125 build_botan
126 fi
127 ;;
128 wolfssl)
129 CONFIG="--disable-defaults --enable-pki --enable-wolfssl --enable-pem"
130 export TESTS_PLUGINS="test-vectors pem wolfssl!"
131 # build with custom options to enable all the features the plugin supports
132 DEPS=""
133 if test "$1" = "deps"; then
134 build_wolfssl
135 fi
136 ;;
137 printf-builtin)
138 CONFIG="--with-printf-hooks=builtin"
139 ;;
140 all|coverage|sonarcloud)
141 CONFIG="--enable-all --disable-android-dns --disable-android-log
142 --disable-kernel-pfroute --disable-keychain
143 --disable-lock-profiler --disable-padlock --disable-fuzzing
144 --disable-osx-attr --disable-tkm --disable-uci
145 --disable-soup --disable-unwind-backtraces
146 --disable-svc --disable-dbghelp-backtraces --disable-socket-win
147 --disable-kernel-wfp --disable-kernel-iph --disable-winhttp"
148 # not enabled on the build server
149 CONFIG="$CONFIG --disable-af-alg"
150 if test "$TEST" != "coverage"; then
151 CONFIG="$CONFIG --disable-coverage"
152 else
153 # not actually required but configure checks for it
154 DEPS="$DEPS lcov"
155 fi
156 DEPS="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
157 libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
158 libpcsclite-dev libpam0g-dev binutils-dev libunwind8-dev libnm-dev
159 libjson-c-dev iptables-dev python-pip libtspi-dev libsystemd-dev"
160 PYDEPS="pytest"
161 if test "$1" = "deps"; then
162 build_botan
163 build_wolfssl
164 build_tss2
165 fi
166 ;;
167 win*)
168 CONFIG="--disable-defaults --enable-svc --enable-ikev2
169 --enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
170 --enable-constraints --enable-revocation --enable-pem --enable-pkcs1
171 --enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
172 --enable-eap-tnc --enable-eap-ttls --enable-eap-identity
173 --enable-updown --enable-ext-auth --enable-libipsec
174 --enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
175 --enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
176 --enable-pki --enable-swanctl --enable-socket-win
177 --enable-kernel-iph --enable-kernel-wfp --enable-winhttp"
178 # no make check for Windows binaries unless we run on a windows host
179 if test "$APPVEYOR" != "True"; then
180 TARGET=
181 CCACHE=ccache
182 else
183 CONFIG="$CONFIG --enable-openssl"
184 CFLAGS="$CFLAGS -I/c/OpenSSL-$TEST/include"
185 LDFLAGS="-L/c/OpenSSL-$TEST"
186 export LDFLAGS
187 fi
188 CFLAGS="$CFLAGS -mno-ms-bitfields"
189 DEPS="gcc-mingw-w64-base"
190 case "$TEST" in
191 win64)
192 CONFIG="--host=x86_64-w64-mingw32 $CONFIG --enable-dbghelp-backtraces"
193 DEPS="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev $DEPS"
194 CC="$CCACHE x86_64-w64-mingw32-gcc"
195 ;;
196 win32)
197 CONFIG="--host=i686-w64-mingw32 $CONFIG"
198 DEPS="gcc-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev $DEPS"
199 CC="$CCACHE i686-w64-mingw32-gcc"
200 ;;
201 esac
202 ;;
203 osx)
204 # this causes a false positive in ip-packet.c since Xcode 8.3
205 CFLAGS="$CFLAGS -Wno-address-of-packed-member"
206 # use the same options as in the Homebrew Formula
207 CONFIG="--disable-defaults --enable-charon --enable-cmd --enable-constraints
208 --enable-curl --enable-eap-gtc --enable-eap-identity
209 --enable-eap-md5 --enable-eap-mschapv2 --enable-ikev1 --enable-ikev2
210 --enable-kernel-libipsec --enable-kernel-pfkey
211 --enable-kernel-pfroute --enable-nonce --enable-openssl
212 --enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
213 --enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
214 --enable-scepclient --enable-socket-default --enable-sshkey
215 --enable-stroke --enable-swanctl --enable-unity --enable-updown
216 --enable-x509 --enable-xauth-generic"
217 DEPS="bison gettext openssl curl"
218 BREW_PREFIX=$(brew --prefix)
219 export PATH=$BREW_PREFIX/opt/bison/bin:$PATH
220 export ACLOCAL_PATH=$BREW_PREFIX/opt/gettext/share/aclocal:$ACLOCAL_PATH
221 for pkg in openssl curl
222 do
223 PKG_CONFIG_PATH=$BREW_PREFIX/opt/$pkg/lib/pkgconfig:$PKG_CONFIG_PATH
224 CPPFLAGS="-I$BREW_PREFIX/opt/$pkg/include $CPPFLAGS"
225 LDFLAGS="-L$BREW_PREFIX/opt/$pkg/lib $LDFLAGS"
226 done
227 export PKG_CONFIG_PATH
228 export CPPFLAGS
229 export LDFLAGS
230 ;;
231 freebsd)
232 # use the options of the FreeBSD port (including options), except smp,
233 # which requires a patch but is deprecated anyway, only using the builtin
234 # printf hooks
235 CONFIG="--enable-kernel-pfkey --enable-kernel-pfroute --disable-scripts
236 --disable-kernel-netlink --enable-openssl --enable-eap-identity
237 --enable-eap-md5 --enable-eap-tls --enable-eap-mschapv2
238 --enable-eap-peap --enable-eap-ttls --enable-md4 --enable-blowfish
239 --enable-addrblock --enable-whitelist --enable-cmd --enable-curl
240 --enable-eap-aka --enable-eap-aka-3gpp2 --enable-eap-dynamic
241 --enable-eap-radius --enable-eap-sim --enable-eap-sim-file
242 --enable-gcm --enable-ipseckey --enable-kernel-libipsec
243 --enable-load-tester --enable-ldap --enable-mediation
244 --enable-mysql --enable-sqlite --enable-tpm --enable-unbound
245 --enable-unity --enable-xauth-eap --enable-xauth-pam
246 --with-printf-hooks=builtin --enable-attr-sql --enable-sql"
247 DEPS="gmp openldap-client libxml2 mysql80-client sqlite3 unbound ldns"
248 export GPERF=/usr/local/bin/gperf
249 export LEX=/usr/local/bin/flex
250 ;;
251 fuzzing)
252 CFLAGS="$CFLAGS -DNO_CHECK_MEMWIPE"
253 CONFIG="--enable-fuzzing --enable-static --disable-shared --disable-scripts
254 --enable-imc-test --enable-tnccs-20"
255 # don't run any of the unit tests
256 export TESTS_RUNNERS=
257 # prepare corpora
258 if test -z "$1"; then
259 if test -z "$FUZZING_CORPORA"; then
260 git clone --depth 1 https://github.com/strongswan/fuzzing-corpora.git fuzzing-corpora
261 export FUZZING_CORPORA=$TRAVIS_BUILD_DIR/fuzzing-corpora
262 fi
263 # these are about the same as those on OSS-Fuzz (except for the
264 # symbolize options and strip_path_prefix)
265 export ASAN_OPTIONS=redzone=16:handle_sigill=1:strict_string_check=1:\
266 allocator_release_to_os_interval_ms=500:strict_memcmp=1:detect_container_overflow=1:\
267 coverage=0:allocator_may_return_null=1:use_sigaltstack=1:detect_stack_use_after_return=1:\
268 alloc_dealloc_mismatch=0:detect_leaks=1:print_scariness=1:max_uar_stack_size_log=16:\
269 handle_abort=1:check_malloc_usable_size=0:quarantine_size_mb=10:detect_odr_violation=0:\
270 symbolize=1:handle_segv=1:fast_unwind_on_fatal=0:external_symbolizer_path=/usr/bin/llvm-symbolizer-3.5
271 fi
272 ;;
273 dist)
274 TARGET=distcheck
275 ;;
276 apidoc)
277 DEPS="doxygen"
278 CONFIG="--disable-defaults"
279 TARGET=apidoc
280 ;;
281 *)
282 echo "$0: unknown test $TEST" >&2
283 exit 1
284 ;;
285 esac
286
287 if test "$1" = "deps"; then
288 case "$TRAVIS_OS_NAME" in
289 linux)
290 sudo apt-get update -qq && \
291 sudo apt-get install -qq bison flex gperf gettext $DEPS
292 ;;
293 osx)
294 brew update && \
295 brew install $DEPS
296 ;;
297 freebsd)
298 pkg install -y automake autoconf libtool pkgconf && \
299 pkg install -y bison flex gperf gettext $DEPS
300 ;;
301 esac
302 exit $?
303 fi
304
305 if test "$1" = "pydeps"; then
306 test -z "$PYDEPS" || pip -q install --user $PYDEPS
307 exit $?
308 fi
309
310 CONFIG="$CONFIG
311 --disable-dependency-tracking
312 --enable-silent-rules
313 --enable-test-vectors
314 --enable-monolithic=${MONOLITHIC-no}
315 --enable-leak-detective=${LEAK_DETECTIVE-no}"
316
317 echo "$ ./autogen.sh"
318 ./autogen.sh || exit $?
319 echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
320 CC="$CC" CFLAGS="$CFLAGS" ./configure $CONFIG || exit $?
321
322 case "$TEST" in
323 apidoc)
324 exec 2>make.warnings
325 ;;
326 *)
327 ;;
328 esac
329
330 echo "$ make $TARGET"
331 case "$TEST" in
332 sonarcloud)
333 # there is an issue with the platform detection that causes sonarqube to
334 # fail on bionic with "ERROR: ld.so: object '...libinterceptor-${PLATFORM}.so'
335 # from LD_PRELOAD cannot be preloaded (cannot open shared object file)"
336 # https://jira.sonarsource.com/browse/CPP-2027
337 BW_PATH=$(dirname $(which build-wrapper-linux-x86-64))
338 cp $BW_PATH/libinterceptor-x86_64.so $BW_PATH/libinterceptor-haswell.so
339 # without target, coverage is currently not supported anyway because
340 # sonarqube only supports gcov, not lcov
341 build-wrapper-linux-x86-64 --out-dir bw-output make -j4 || exit $?
342 ;;
343 *)
344 make -j4 $TARGET || exit $?
345 ;;
346 esac
347
348 case "$TEST" in
349 apidoc)
350 if test -s make.warnings; then
351 cat make.warnings
352 exit 1
353 fi
354 rm make.warnings
355 ;;
356 sonarcloud)
357 sonar-scanner \
358 -Dsonar.projectKey=strongswan \
359 -Dsonar.projectVersion=$(git describe)+${TRAVIS_BUILD_NUMBER} \
360 -Dsonar.sources=. \
361 -Dsonar.cfamily.threads=2 \
362 -Dsonar.cfamily.build-wrapper-output=bw-output || exit $?
363 rm -r bw-output .scannerwork
364 ;;
365 *)
366 ;;
367 esac
368
369 # ensure there are no unignored build artifacts (or other changes) in the Git repo
370 unclean="$(git status --porcelain)"
371 if test -n "$unclean"; then
372 echo "Unignored build artifacts or other changes:"
373 echo "$unclean"
374 exit 1
375 fi