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