Mercurial > hg > sv-dependency-builds
comparison src/capnproto-0.6.0/super-test.sh @ 147:45360b968bf4
Cap'n Proto v0.6 + build for OSX
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Mon, 22 May 2017 10:01:37 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
146:206f0eb279b8 | 147:45360b968bf4 |
---|---|
1 #! /usr/bin/env bash | |
2 | |
3 set -euo pipefail | |
4 | |
5 doit() { | |
6 echo "@@@@ $@" | |
7 "$@" | |
8 } | |
9 | |
10 QUICK= | |
11 | |
12 PARALLEL=$(nproc 2>/dev/null || echo 1) | |
13 | |
14 while [ $# -gt 0 ]; do | |
15 case "$1" in | |
16 -j* ) | |
17 PARALLEL=${1#-j} | |
18 ;; | |
19 test ) | |
20 ;; # nothing | |
21 quick ) | |
22 QUICK=quick | |
23 ;; | |
24 caffeinate ) | |
25 # Re-run preventing sleep. | |
26 shift | |
27 exec caffeinate -ims $0 $@ | |
28 ;; | |
29 tmpdir ) | |
30 # Clone to a temp directory. | |
31 if [ "$#" -lt 2 ]; then | |
32 echo "usage: $0 tmpdir NAME [COMMAND]" >&2 | |
33 exit 1 | |
34 fi | |
35 DIR=/tmp/$2 | |
36 shift 2 | |
37 if [ -e $DIR ]; then | |
38 if [ "${DIR/*..*}" = "" ]; then | |
39 echo "NO DO NOT PUT .. IN THERE IT'S GOING TO GO IN /tmp AND I'M GONNA DELETE IT" >&2 | |
40 exit 1 | |
41 fi | |
42 if [ ! -e "$DIR/super-test.sh" ]; then | |
43 echo "$DIR exists and it doesn't look like one of mine." >&2 | |
44 exit 1 | |
45 fi | |
46 # make distcheck leaves non-writable files when it fails, so we need to chmod to be safe. | |
47 chmod -R +w $DIR | |
48 rm -rf $DIR | |
49 fi | |
50 git clone . $DIR | |
51 cd $DIR | |
52 exec ./super-test.sh "$@" | |
53 ;; | |
54 remote ) | |
55 if [ "$#" -lt 2 ]; then | |
56 echo "usage: $0 remote HOST [COMMAND]" >&2 | |
57 exit 1 | |
58 fi | |
59 HOST=$2 | |
60 shift 2 | |
61 echo "=========================================================================" | |
62 echo "Pushing code to $HOST..." | |
63 echo "=========================================================================" | |
64 BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
65 ssh $HOST '(chmod -fR +w tmp-test-capnp || true) && rm -rf tmp-test-capnp && mkdir tmp-test-capnp && git init tmp-test-capnp' | |
66 git push ssh://$HOST/~/tmp-test-capnp "$BRANCH:test" | |
67 ssh $HOST "cd tmp-test-capnp && git checkout test" | |
68 exec ssh $HOST "cd tmp-test-capnp && ./super-test.sh $@ && cd .. && rm -rf tmp-test-capnp" | |
69 ;; | |
70 compiler ) | |
71 if [ "$#" -lt 2 ]; then | |
72 echo "usage: $0 compiler CXX_NAME" >&2 | |
73 exit 1 | |
74 fi | |
75 export CXX="$2" | |
76 shift | |
77 ;; | |
78 clang ) | |
79 export CXX=clang++ | |
80 ;; | |
81 gcc-4.9 ) | |
82 export CXX=g++-4.9 | |
83 ;; | |
84 gcc-4.8 ) | |
85 export CXX=g++-4.8 | |
86 ;; | |
87 gcc-4.7 ) | |
88 export CXX=g++-4.7 | |
89 ;; | |
90 mingw ) | |
91 if [ "$#" -ne 2 ]; then | |
92 echo "usage: $0 mingw CROSS_HOST" >&2 | |
93 exit 1 | |
94 fi | |
95 CROSS_HOST=$2 | |
96 | |
97 cd c++ | |
98 test -e configure || doit autoreconf -i | |
99 test ! -e Makefile || (echo "ERROR: Directory unclean!" >&2 && false) | |
100 | |
101 export WINEPATH='Z:\usr\'"$CROSS_HOST"'\lib;Z:\usr\lib\gcc\'"$CROSS_HOST"'\6.3-win32;Z:'"$PWD"'\.libs' | |
102 | |
103 doit ./configure --host="$CROSS_HOST" --disable-shared CXXFLAGS='-static-libgcc -static-libstdc++' | |
104 | |
105 doit make -j$PARALLEL check | |
106 doit make distclean | |
107 rm -f *-mingw.exe | |
108 exit 0 | |
109 ;; | |
110 android ) | |
111 # To install Android SDK: | |
112 # - Download command-line tools: https://developer.android.com/studio/index.html#command-tools | |
113 # - Run $SDK_HOME/tools/bin/sdkmanager platform-tools 'platforms;android-25' 'system-images;android-25;google_apis;armeabi-v7a' emulator 'build-tools;25.0.2' ndk-bundle | |
114 # - Run $SDK_HOME/tools/bin/avdmanager create avd -n capnp -k 'system-images;android-25;google_apis;armeabi-v7a' -b google_apis/armeabi-v7a | |
115 # - Run $SDK_HOME/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm --api 24 --install-dir $TOOLCHAIN_HOME | |
116 if [ "$#" -ne 4 ]; then | |
117 echo "usage: $0 android SDK_HOME TOOLCHAIN_HOME CROSS_HOST" >&2 | |
118 exit 1 | |
119 fi | |
120 SDK_HOME=$2 | |
121 TOOLCHAIN_HOME=$3 | |
122 CROSS_HOST=$4 | |
123 | |
124 cd c++ | |
125 test -e configure || doit autoreconf -i | |
126 test ! -e Makefile || (echo "ERROR: Directory unclean!" >&2 && false) | |
127 doit ./configure --disable-shared | |
128 doit make -j$PARALLEL capnp capnpc-c++ | |
129 | |
130 cp capnp capnp-host | |
131 cp capnpc-c++ capnpc-c++-host | |
132 | |
133 export PATH="$TOOLCHAIN_HOME/bin:$PATH" | |
134 doit make distclean | |
135 doit ./configure --host="$CROSS_HOST" --with-external-capnp --disable-shared CXXFLAGS='-pie -fPIE' CAPNP=./capnp-host CAPNPC_CXX=./capnpc-c++-host | |
136 | |
137 doit make -j$PARALLEL | |
138 doit make -j$PARALLEL capnp-test | |
139 | |
140 echo "Starting emulator..." | |
141 trap 'kill $(jobs -p)' EXIT | |
142 # TODO(someday): Speed up with KVM? Then maybe we won't have to skip fuzz tests? | |
143 $SDK_HOME/emulator/emulator -avd capnp -no-window & | |
144 $SDK_HOME/platform-tools/adb 'wait-for-device' | |
145 echo "Waiting for localhost to be resolvable..." | |
146 doit $SDK_HOME/platform-tools/adb shell 'while ! ping -c 1 localhost > /dev/null 2>&1; do sleep 1; done' | |
147 # TODO(cleanup): With 'adb shell' I find I cannot put files anywhere, so I'm using 'su' a | |
148 # lot here. There is probably a better way. | |
149 doit $SDK_HOME/platform-tools/adb shell 'su 0 tee /data/capnp-test > /dev/null' < capnp-test | |
150 doit $SDK_HOME/platform-tools/adb shell 'su 0 chmod a+rx /data/capnp-test' | |
151 doit $SDK_HOME/platform-tools/adb shell 'cd /data && CAPNP_SKIP_FUZZ_TEST=1 su 0 /data/capnp-test && echo ANDROID_""TESTS_PASSED' | tee android-test.log | |
152 grep -q ANDROID_TESTS_PASSED android-test.log | |
153 | |
154 doit make distclean | |
155 rm -f capnp-host capnpc-c++-host | |
156 exit 0 | |
157 ;; | |
158 cmake ) | |
159 cd c++ | |
160 rm -rf cmake-build | |
161 mkdir cmake-build | |
162 cd cmake-build | |
163 doit cmake -G "Unix Makefiles" .. | |
164 doit make -j$PARALLEL check | |
165 exit 0 | |
166 ;; | |
167 exotic ) | |
168 echo "=========================================================================" | |
169 echo "MinGW 64-bit" | |
170 echo "=========================================================================" | |
171 "$0" mingw x86_64-w64-mingw32 | |
172 echo "=========================================================================" | |
173 echo "MinGW 32-bit" | |
174 echo "=========================================================================" | |
175 "$0" mingw i686-w64-mingw32 | |
176 echo "=========================================================================" | |
177 echo "Android" | |
178 echo "=========================================================================" | |
179 "$0" android /home/kenton/android-sdk-linux /home/kenton/android-24 arm-linux-androideabi | |
180 echo "=========================================================================" | |
181 echo "CMake" | |
182 echo "=========================================================================" | |
183 "$0" cmake | |
184 exit 0 | |
185 ;; | |
186 clean ) | |
187 rm -rf tmp-staging | |
188 cd c++ | |
189 if [ -e Makefile ]; then | |
190 doit make maintainer-clean | |
191 fi | |
192 rm -f capnproto-*.tar.gz samples/addressbook samples/addressbook.capnp.c++ \ | |
193 samples/addressbook.capnp.h | |
194 exit 0 | |
195 ;; | |
196 help ) | |
197 echo "usage: $0 [COMMAND]" | |
198 echo "commands:" | |
199 echo " test Runs tests (the default)." | |
200 echo " clang Runs tests using Clang compiler." | |
201 echo " gcc-4.7 Runs tests using gcc-4.7." | |
202 echo " gcc-4.8 Runs tests using gcc-4.8." | |
203 echo " gcc-4.9 Runs tests using gcc-4.9." | |
204 echo " remote HOST Runs tests on HOST via SSH." | |
205 echo " mingw Cross-compiles to MinGW and runs tests using WINE." | |
206 echo " android Cross-compiles to Android and runs tests using emulator." | |
207 echo " clean Delete temporary files that may be left after failure." | |
208 echo " help Prints this help text." | |
209 exit 0 | |
210 ;; | |
211 * ) | |
212 echo "unknown command: $1" >&2 | |
213 echo "try: $0 help" >&2 | |
214 exit 1 | |
215 ;; | |
216 esac | |
217 shift | |
218 done | |
219 | |
220 # Build optimized builds because they catch more problems, but also enable debugging macros. | |
221 # Enable lots of warnings and make sure the build breaks if they fire. Disable strict-aliasing | |
222 # because GCC warns about code that I know is OK. Disable sign-compare because I've fixed more | |
223 # sign-compare warnings than probably all other warnings combined and I've never seen it flag a | |
224 # real problem. Disable unused parameters because it's stupidly noisy and never a real problem. | |
225 # Enable expensive release-gating tests. | |
226 export CXXFLAGS="-O2 -DDEBUG -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -DCAPNP_EXPENSIVE_TESTS=1" | |
227 | |
228 STAGING=$PWD/tmp-staging | |
229 | |
230 rm -rf "$STAGING" | |
231 mkdir "$STAGING" | |
232 mkdir "$STAGING/bin" | |
233 mkdir "$STAGING/lib" | |
234 export PATH=$STAGING/bin:$PATH | |
235 export LD_LIBRARY_PATH=$STAGING/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} | |
236 export PKG_CONFIG_PATH=$STAGING/lib/pkgconfig | |
237 | |
238 if [ "$QUICK" = quick ]; then | |
239 echo "************************** QUICK TEST ***********************************" | |
240 fi | |
241 | |
242 echo "=========================================================================" | |
243 echo "Building c++" | |
244 echo "=========================================================================" | |
245 | |
246 # Apple now aliases gcc to clang, so probe to find out what compiler we're really using. | |
247 if (${CXX:-g++} -dM -E -x c++ /dev/null 2>&1 | grep -q '__clang__'); then | |
248 IS_CLANG=yes | |
249 DISABLE_OPTIMIZATION_IF_GCC= | |
250 else | |
251 IS_CLANG=no | |
252 DISABLE_OPTIMIZATION_IF_GCC=-O0 | |
253 fi | |
254 | |
255 if [ $IS_CLANG = yes ]; then | |
256 # Don't fail out on this ridiculous "argument unused during compilation" warning. | |
257 export CXXFLAGS="$CXXFLAGS -Wno-error=unused-command-line-argument" | |
258 else | |
259 # GCC emits uninitialized warnings all over and they seem bogus. We use valgrind to test for | |
260 # uninitialized memory usage later on. GCC 4 also emits strange bogus warnings with | |
261 # -Wstrict-overflow, so we disable it. | |
262 CXXFLAGS="$CXXFLAGS -Wno-maybe-uninitialized -Wno-strict-overflow" | |
263 fi | |
264 | |
265 cd c++ | |
266 doit autoreconf -i | |
267 doit ./configure --prefix="$STAGING" | |
268 doit make -j$PARALLEL check | |
269 | |
270 if [ $IS_CLANG = no ]; then | |
271 # Verify that generated code compiles with pedantic warnings. Make sure to treat capnp headers | |
272 # as system headers so warnings in them are ignored. | |
273 doit ${CXX:-g++} -isystem src -std=c++11 -fno-permissive -pedantic -Wall -Wextra -Werror \ | |
274 -c src/capnp/test.capnp.c++ -o /dev/null | |
275 fi | |
276 | |
277 echo "=========================================================================" | |
278 echo "Testing c++ install" | |
279 echo "=========================================================================" | |
280 | |
281 doit make install | |
282 | |
283 test "x$(which capnp)" = "x$STAGING/bin/capnp" | |
284 test "x$(which capnpc-c++)" = "x$STAGING/bin/capnpc-c++" | |
285 | |
286 cd samples | |
287 | |
288 doit capnp compile -oc++ addressbook.capnp -I"$STAGING"/include --no-standard-import | |
289 doit ${CXX:-g++} -std=c++11 addressbook.c++ addressbook.capnp.c++ -o addressbook \ | |
290 $CXXFLAGS $(pkg-config --cflags --libs capnp) | |
291 echo "@@@@ ./addressbook (in various configurations)" | |
292 ./addressbook write | ./addressbook read | |
293 ./addressbook dwrite | ./addressbook dread | |
294 rm addressbook addressbook.capnp.c++ addressbook.capnp.h | |
295 | |
296 doit capnp compile -oc++ calculator.capnp -I"$STAGING"/include --no-standard-import | |
297 doit ${CXX:-g++} -std=c++11 calculator-client.c++ calculator.capnp.c++ -o calculator-client \ | |
298 $CXXFLAGS $(pkg-config --cflags --libs capnp-rpc) | |
299 doit ${CXX:-g++} -std=c++11 calculator-server.c++ calculator.capnp.c++ -o calculator-server \ | |
300 $CXXFLAGS $(pkg-config --cflags --libs capnp-rpc) | |
301 rm -f /tmp/capnp-calculator-example-$$ | |
302 ./calculator-server unix:/tmp/capnp-calculator-example-$$ & | |
303 sleep 0.1 | |
304 ./calculator-client unix:/tmp/capnp-calculator-example-$$ | |
305 kill %+ | |
306 wait %+ || true | |
307 rm calculator-client calculator-server calculator.capnp.c++ calculator.capnp.h /tmp/capnp-calculator-example-$$ | |
308 | |
309 cd .. | |
310 | |
311 if [ "$QUICK" = quick ]; then | |
312 doit make maintainer-clean | |
313 rm -rf "$STAGING" | |
314 exit 0 | |
315 fi | |
316 | |
317 echo "=========================================================================" | |
318 echo "Testing --with-external-capnp" | |
319 echo "=========================================================================" | |
320 | |
321 doit make distclean | |
322 doit ./configure --prefix="$STAGING" --disable-shared \ | |
323 --with-external-capnp CAPNP=$STAGING/bin/capnp | |
324 doit make -j$PARALLEL check | |
325 | |
326 echo "=========================================================================" | |
327 echo "Testing --disable-reflection" | |
328 echo "=========================================================================" | |
329 | |
330 doit make distclean | |
331 doit ./configure --prefix="$STAGING" --disable-shared --disable-reflection \ | |
332 --with-external-capnp CAPNP=$STAGING/bin/capnp | |
333 doit make -j$PARALLEL check | |
334 doit make distclean | |
335 | |
336 # Test 32-bit build now while we have $STAGING available for cross-compiling. | |
337 if [ "x`uname -m`" = "xx86_64" ]; then | |
338 echo "=========================================================================" | |
339 echo "Testing 32-bit build" | |
340 echo "=========================================================================" | |
341 | |
342 if [[ "`uname`" =~ CYGWIN ]]; then | |
343 # It's just not possible to run cygwin32 binaries from within cygwin64. | |
344 | |
345 # Build as if we are cross-compiling, using the capnp we installed to $STAGING. | |
346 doit ./configure --prefix="$STAGING" --disable-shared --host=i686-pc-cygwin \ | |
347 --with-external-capnp CAPNP=$STAGING/bin/capnp | |
348 doit make -j$PARALLEL | |
349 doit make -j$PARALLEL capnp-test.exe | |
350 | |
351 # Expect a cygwin32 sshd to be listening at localhost port 2222, and use it | |
352 # to run the tests. | |
353 doit scp -P 2222 capnp-test.exe localhost:~/tmp-capnp-test.exe | |
354 doit ssh -p 2222 localhost './tmp-capnp-test.exe && rm tmp-capnp-test.exe' | |
355 | |
356 doit make distclean | |
357 | |
358 elif [ "x${CXX:-g++}" != "xg++-4.8" ]; then | |
359 doit ./configure CXX="${CXX:-g++} -m32" --disable-shared | |
360 doit make -j$PARALLEL check | |
361 doit make distclean | |
362 fi | |
363 fi | |
364 | |
365 echo "=========================================================================" | |
366 echo "Testing c++ uninstall" | |
367 echo "=========================================================================" | |
368 | |
369 doit ./configure --prefix="$STAGING" | |
370 doit make uninstall | |
371 | |
372 echo "=========================================================================" | |
373 echo "Testing c++ dist" | |
374 echo "=========================================================================" | |
375 | |
376 doit make -j$PARALLEL distcheck | |
377 doit make distclean | |
378 rm capnproto-*.tar.gz | |
379 | |
380 if [ "x`uname`" = xLinux ]; then | |
381 echo "=========================================================================" | |
382 echo "Testing generic Unix (no Linux-specific features)" | |
383 echo "=========================================================================" | |
384 | |
385 doit ./configure --disable-shared CXXFLAGS="$CXXFLAGS -DKJ_USE_FUTEX=0 -DKJ_USE_EPOLL=0" | |
386 doit make -j$PARALLEL check | |
387 doit make distclean | |
388 fi | |
389 | |
390 echo "=========================================================================" | |
391 echo "Testing with -fno-rtti and -fno-exceptions" | |
392 echo "=========================================================================" | |
393 | |
394 # GCC miscompiles capnpc-c++ when -fno-exceptions and -O2 are specified together. The | |
395 # miscompilation happens in one specific inlined call site of Array::dispose(), but this method | |
396 # is inlined in hundreds of other places without issue, so I have no idea how to narrow down the | |
397 # bug. Clang works fine. So, for now, we disable optimizations on GCC for -fno-exceptions tests. | |
398 | |
399 doit ./configure --disable-shared CXXFLAGS="$CXXFLAGS -fno-rtti" | |
400 doit make -j$PARALLEL check | |
401 doit make distclean | |
402 doit ./configure --disable-shared CXXFLAGS="$CXXFLAGS -fno-exceptions $DISABLE_OPTIMIZATION_IF_GCC" | |
403 doit make -j$PARALLEL check | |
404 doit make distclean | |
405 doit ./configure --disable-shared CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions $DISABLE_OPTIMIZATION_IF_GCC" | |
406 doit make -j$PARALLEL check | |
407 | |
408 # Valgrind is currently "experimental and mostly broken" on OSX and fails to run the full test | |
409 # suite, but I have it installed because it did manage to help me track down a bug or two. Anyway, | |
410 # skip it on OSX for now. | |
411 if [ "x`uname`" != xDarwin ] && which valgrind > /dev/null; then | |
412 doit make distclean | |
413 | |
414 echo "=========================================================================" | |
415 echo "Testing with valgrind" | |
416 echo "=========================================================================" | |
417 | |
418 doit ./configure --disable-shared CXXFLAGS="-g" | |
419 doit make -j$PARALLEL | |
420 doit make -j$PARALLEL capnp-test | |
421 # Running the fuzz tests under Valgrind is a great thing to do -- but it takes | |
422 # some 40 minutes. So, it needs to be done as a separate step of the release | |
423 # process, perhaps along with the AFL tests. | |
424 CAPNP_SKIP_FUZZ_TEST=1 doit valgrind --leak-check=full --track-fds=yes --error-exitcode=1 ./capnp-test | |
425 fi | |
426 | |
427 doit make maintainer-clean | |
428 | |
429 rm -rf "$STAGING" |