travis: Properly pass back result of make
[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-padlock
36 --disable-osx-attr --disable-tkm --disable-uci
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 # Ubuntu 14.04 does provide a too old libtss2-dev
41 CONFIG="$CONFIG --disable-aikpub2 --disable-tss-tss2"
42 # not enabled on the build server
43 CONFIG="$CONFIG --disable-af-alg"
44 # TODO: enable? perhaps via coveralls.io (cpp-coveralls)?
45 CONFIG="$CONFIG --disable-coverage"
46 DEPS="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
47 libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
48 libnm-glib-dev libnm-glib-vpn-dev libpcsclite-dev libpam0g-dev
49 binutils-dev libunwind8-dev libjson0-dev iptables-dev python-pip
50 libtspi-dev"
51 PYDEPS="pytest"
52 ;;
53 win*)
54 CONFIG="--disable-defaults --enable-svc --enable-ikev2
55 --enable-ikev1 --enable-static --enable-test-vectors --enable-nonce
56 --enable-constraints --enable-revocation --enable-pem --enable-pkcs1
57 --enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
58 --enable-eap-tnc --enable-eap-ttls --enable-eap-identity
59 --enable-updown --enable-ext-auth
60 --enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
61 --enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
62 --enable-pki --enable-swanctl --enable-socket-win"
63 # no make check for Windows binaries
64 TARGET=
65 CFLAGS="$CFLAGS -mno-ms-bitfields"
66 DEPS="gcc-mingw-w64-base"
67 case "$TEST" in
68 win64)
69 CONFIG="--host=x86_64-w64-mingw32 $CONFIG"
70 DEPS="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev $DEPS"
71 CC="x86_64-w64-mingw32-gcc"
72 ;;
73 win32)
74 CONFIG="--host=i686-w64-mingw32 $CONFIG"
75 DEPS="gcc-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev $DEPS"
76 CC="i686-w64-mingw32-gcc"
77 ;;
78 esac
79 ;;
80 osx)
81 # use the same options as in the Homebrew Formula
82 CONFIG="--disable-defaults --enable-charon --enable-cmd --enable-constraints
83 --enable-curl --enable-eap-gtc --enable-eap-identity
84 --enable-eap-md5 --enable-eap-mschapv2 --enable-ikev1 --enable-ikev2
85 --enable-kernel-libipsec --enable-kernel-pfkey
86 --enable-kernel-pfroute --enable-nonce --enable-openssl
87 --enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
88 --enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
89 --enable-scepclient --enable-socket-default --enable-sshkey
90 --enable-stroke --enable-swanctl --enable-unity --enable-updown
91 --enable-x509 --enable-xauth-generic"
92 DEPS="bison gettext openssl curl"
93 BREW_PREFIX=$(brew --prefix)
94 export PATH=$BREW_PREFIX/opt/bison/bin:$PATH
95 export ACLOCAL_PATH=$BREW_PREFIX/opt/gettext/share/aclocal:$ACLOCAL_PATH
96 for pkg in openssl curl
97 do
98 PKG_CONFIG_PATH=$BREW_PREFIX/opt/$PKG/lib/pkgconfig:$PKG_CONFIG_PATH
99 CPPFLAGS="-I$BREW_PREFIX/opt/$pkg/include $CPPFLAGS"
100 LDFLAGS="-L$BREW_PREFIX/opt/$pkg/lib $LDFLAGS"
101 done
102 export PKG_CONFIG_PATH
103 export CPPFLAGS
104 export LDFLAGS
105 ;;
106 dist)
107 TARGET=distcheck
108 ;;
109 apidoc)
110 DEPS="doxygen"
111 CONFIG="--disable-defaults"
112 TARGET=apidoc
113 ;;
114 *)
115 echo "$0: unknown test $TEST" >&2
116 exit 1
117 ;;
118 esac
119
120 if test "$1" = "deps"; then
121 case "$TRAVIS_OS_NAME" in
122 linux)
123 sudo apt-get update -qq && \
124 sudo apt-get install -qq bison flex gperf gettext $DEPS
125 ;;
126 osx)
127 brew update && \
128 # workaround for issue #6352
129 brew uninstall --force libtool && brew install libtool && \
130 brew install $DEPS
131 ;;
132 esac
133 exit $?
134 fi
135
136 if test "$1" = "pydeps"; then
137 test -z "$PYDEPS" || sudo pip -q install $PYDEPS
138 exit $?
139 fi
140
141 CONFIG="$CONFIG
142 --disable-dependency-tracking
143 --enable-silent-rules
144 --enable-test-vectors
145 --enable-monolithic=${MONOLITHIC-no}
146 --enable-leak-detective=${LEAK_DETECTIVE-no}"
147
148 echo "$ ./autogen.sh"
149 ./autogen.sh || exit $?
150 echo "$ CC=$CC CFLAGS=\"$CFLAGS\" ./configure $CONFIG"
151 CC="$CC" CFLAGS="$CFLAGS" ./configure $CONFIG || exit $?
152
153 case "$TEST" in
154 apidoc)
155 exec 2>make.warnings
156 ;;
157 *)
158 ;;
159 esac
160
161 echo "$ make $TARGET"
162 make -j4 $TARGET || exit $?
163
164 case "$TEST" in
165 apidoc)
166 if test -s make.warnings; then
167 cat make.warnings
168 exit 1
169 fi
170 ;;
171 *)
172 ;;
173 esac