d21deaedc790bd608c1a6d79229348972e027fe8
[strongswan.git] / scripts / test.sh
1 #!/bin/sh
2 # Build script for Travis CI
3
4 if test -z $TRAVIS_BUILD_DIR; then
5 TRAVIS_BUILD_DIR=$PWD
6 fi
7
8 cd $TRAVIS_BUILD_DIR
9
10 TARGET=check
11
12 DEPS="libgmp-dev"
13
14 CFLAGS="-g -O2 -Wall -Wno-format -Wno-format-security -Wno-pointer-sign -Werror"
15
16 case "$TEST" in
17 default)
18 # should be the default, but lets make sure
19 CONFIG="--with-printf-hooks=glibc"
20 ;;
21 openssl)
22 CONFIG="--disable-defaults --enable-pki --enable-openssl"
23 DEPS="libssl-dev"
24 ;;
25 gcrypt)
26 CONFIG="--disable-defaults --enable-pki --enable-gcrypt --enable-pkcs1"
27 DEPS="libgcrypt11-dev"
28 ;;
29 printf-builtin)
30 CONFIG="--with-printf-hooks=builtin"
31 ;;
32 all)
33 CONFIG="--enable-all --disable-android-dns --disable-android-log
34 --disable-dumm --disable-kernel-pfroute --disable-keychain
35 --disable-lock-profiler --disable-maemo --disable-padlock
36 --disable-osx-attr --disable-tkm --disable-uci --disable-aikgen
37 --disable-systemd --disable-soup --disable-unwind-backtraces
38 --disable-svc --disable-dbghelp-backtraces --disable-socket-win
39 --disable-kernel-wfp --disable-kernel-iph --disable-winhttp"
40 if test "$LEAK_DETECTIVE" = "yes"; then
41 # libgcrypt can't be deinitialized
42 CONFIG="$CONFIG --disable-gcrypt"
43 fi
44 if test "$MONOLITHIC" = "yes"; then
45 # Ubuntu 12.04 does not provide a proper -liptc pkg-config
46 CONFIG="$CONFIG --disable-forecast --disable-connmark"
47 fi
48 # not enabled on the build server
49 CONFIG="$CONFIG --disable-af-alg"
50 # TODO: enable? perhaps via coveralls.io (cpp-coveralls)?
51 CONFIG="$CONFIG --disable-coverage"
52 DEPS="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
53 libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
54 libnm-glib-dev libnm-glib-vpn-dev libpcsclite-dev libpam0g-dev
55 binutils-dev libunwind7-dev libjson0-dev iptables-dev python-pip"
56 PYDEPS="pytest"
57 ;;
58 win*)
59 CONFIG="--disable-defaults --enable-svc --enable-ikev2
60 --enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
61 --enable-constraints --enable-revocation --enable-pem --enable-pkcs1
62 --enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
63 --enable-eap-tnc --enable-eap-ttls --enable-eap-identity
64 --enable-updown --enable-ext-auth
65 --enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
66 --enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
67 --enable-pki --enable-swanctl --enable-socket-win"
68 # no make check for Windows binaries
69 TARGET=
70 CFLAGS="$CFLAGS -mno-ms-bitfields"
71 DEPS="gcc-mingw-w64-base mingw-w64-dev"
72 case "$TEST" in
73 win64)
74 CONFIG="--host=x86_64-w64-mingw32 $CONFIG"
75 DEPS="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 $DEPS"
76 CC="x86_64-w64-mingw32-gcc"
77 ;;
78 win32)
79 CONFIG="--host=i686-w64-mingw32 $CONFIG"
80 DEPS="gcc-mingw-w64-i686 binutils-mingw-w64-i686 $DEPS"
81 CC="i686-w64-mingw32-gcc"
82 ;;
83 esac
84 ;;
85 dist)
86 TARGET=distcheck
87 ;;
88 *)
89 echo "$0: unknown test $TEST" >&2
90 exit 1
91 ;;
92 esac
93
94 if test "$1" = "deps"; then
95 sudo apt-get install -qq $DEPS
96 exit $?
97 fi
98
99 if test "$1" = "pydeps"; then
100 test -z "$PYDEPS" || sudo pip -q install $PYDEPS
101 exit $?
102 fi
103
104 CONFIG="$CONFIG
105 --enable-silent-rules
106 --enable-test-vectors
107 --enable-monolithic=${MONOLITHIC-no}
108 --enable-leak-detective=${LEAK_DETECTIVE-no}"
109
110 echo "$ CC="$CC" CFLAGS="$CFLAGS" ./configure $CONFIG && make $TARGET"
111 CC="$CC" CFLAGS="$CFLAGS" ./configure $CONFIG && make -j4 $TARGET