]> Cypherpunks.ru repositories - gostls13.git/blob - src/run.bash
build: break builds
[gostls13.git] / src / run.bash
1 #!/usr/bin/env bash
2 # Copyright 2009 The Go Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
5
6 set -e
7
8 eval $(go env)
9
10 unset CDPATH    # in case user has it set
11 unset GOPATH    # we disallow local import for non-local packages, if $GOROOT happens
12                 # to be under $GOPATH, then some tests below will fail
13
14 # no core files, please
15 ulimit -c 0
16
17 # Raise soft limits to hard limits for NetBSD/OpenBSD.
18 # We need at least 256 files and ~300 MB of bss.
19 # On OS X ulimit -S -n rejects 'unlimited'.
20 [ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
21 [ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
22
23 # Thread count limit on NetBSD 7.
24 if ulimit -T &> /dev/null; then
25         [ "$(ulimit -H -T)" == "unlimited" ] || ulimit -S -T $(ulimit -H -T)
26 fi
27
28 # allow all.bash to avoid double-build of everything
29 rebuild=true
30 if [ "$1" = "--no-rebuild" ]; then
31         shift
32 else
33         echo '# Building packages and commands.'
34         time go install -a -v std
35         echo
36 fi
37
38 # we must unset GOROOT_FINAL before tests, because runtime/debug requires
39 # correct access to source code, so if we have GOROOT_FINAL in effect,
40 # at least runtime/debug test will fail.
41 unset GOROOT_FINAL
42
43 # increase timeout for ARM up to 3 times the normal value
44 timeout_scale=1
45 [ "$GOARCH" == "arm" ] && timeout_scale=3
46
47 echo '# Testing packages.'
48 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
49 echo
50
51 echo '# GOMAXPROCS=2 runtime -cpu=1,2,4'
52 GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu=1,2,4
53 echo
54
55 echo '# sync -cpu=10'
56 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
57
58 # Race detector only supported on Linux and OS X,
59 # and only on amd64, and only when cgo is enabled.
60 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
61 linux-linux-amd64-1 | darwin-darwin-amd64-1)
62         echo
63         echo '# Testing race detector.'
64         go test -race -i flag
65         go test -race -short flag
66 esac
67
68 xcd() {
69         echo
70         echo '#' $1
71         builtin cd "$GOROOT"/src/$1 || exit 1
72 }
73
74 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
75 #
76 #       $ bash --version
77 #       GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
78 #       Copyright (C) 2007 Free Software Foundation, Inc.
79 #
80 #       $ set -e; (set -e; false; echo still here); echo subshell exit status $?
81 #       subshell exit status 1
82 #       # subshell stopped early, set exit status, but outer set -e didn't stop.
83 #
84 #       $ set -e; (set -e; false; echo still here) || echo stopped
85 #       still here
86 #       # somehow the '|| echo stopped' broke the inner set -e.
87 #       
88 # To avoid this bug, every command in a subshell should have '|| exit 1' on it.
89 # Strictly speaking, the test may be unnecessary on the final command of
90 # the subshell, but it aids later editing and may avoid future bash bugs.
91
92 [ "$CGO_ENABLED" != 1 ] ||
93 [ "$GOHOSTOS" == windows ] ||
94 (xcd ../misc/cgo/stdio
95 go run $GOROOT/test/run.go - . || exit 1
96 ) || exit $?
97
98 [ "$CGO_ENABLED" != 1 ] ||
99 (xcd ../misc/cgo/life
100 go run $GOROOT/test/run.go - . || exit 1
101 ) || exit $?
102
103 [ "$CGO_ENABLED" != 1 ] ||
104 (xcd ../misc/cgo/test
105 go test -ldflags '-linkmode=auto' || exit 1
106 go test -ldflags '-linkmode=internal' || exit 1
107 case "$GOHOSTOS-$GOARCH" in
108 openbsd-386 | openbsd-amd64)
109         # test linkmode=external, but __thread not supported, so skip testtls.
110         go test -ldflags '-linkmode=external' || exit 1
111         ;;
112 darwin-386 | darwin-amd64)
113         # linkmode=external fails on OS X 10.6 and earlier == Darwin
114         # 10.8 and earlier.
115         case $(uname -r) in
116         [0-9].* | 10.*) ;;
117         *) go test -ldflags '-linkmode=external'  || exit 1;;
118         esac
119         ;;
120 freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | netbsd-386 | netbsd-amd64)
121         go test -ldflags '-linkmode=external' || exit 1
122         go test -ldflags '-linkmode=auto' ../testtls || exit 1
123         go test -ldflags '-linkmode=external' ../testtls || exit 1
124 esac
125 ) || exit $?
126
127 [ "$CGO_ENABLED" != 1 ] ||
128 (xcd ../misc/cgo/testcdefs
129 ./test.bash || exit 1
130 ) || exit $?
131
132 [ "$CGO_ENABLED" != 1 ] ||
133 [ "$GOHOSTOS" == windows ] ||
134 (xcd ../misc/cgo/testso
135 ./test.bash || exit 1
136 ) || exit $?
137
138 [ "$CGO_ENABLED" != 1 ] ||
139 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
140 (xcd ../misc/cgo/testasan
141 go run main.go || exit 1
142 ) || exit $?
143
144 (xcd ../doc/progs
145 time ./run || exit 1
146 ) || exit $?
147
148 [ "$GOARCH" == arm ] ||  # uses network, fails under QEMU
149 (xcd ../doc/articles/wiki
150 make clean || exit 1
151 ./test.bash || exit 1
152 ) || exit $?
153
154 (xcd ../doc/codewalk
155 # TODO: test these too.
156 go build pig.go || exit 1
157 go build urlpoll.go || exit 1
158 rm -f pig urlpoll
159 ) || exit $?
160
161 echo
162 echo '#' ../misc/dashboard/builder ../misc/goplay
163 go build ../misc/dashboard/builder ../misc/goplay
164
165 [ "$GOARCH" == arm ] ||
166 (xcd ../test/bench/shootout
167 ./timing.sh -test || exit 1
168 ) || exit $?
169
170 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
171 (
172 echo
173 echo '#' ../test/bench/go1
174 go test ../test/bench/go1 || exit 1
175 ) || exit $?
176
177 (xcd ../test
178 unset GOMAXPROCS
179 time go run run.go || exit 1
180 ) || exit $?
181
182 echo
183 echo '# Checking API compatibility.'
184 go tool api -c $GOROOT/api/go1.txt,$GOROOT/api/go1.1.txt -next $GOROOT/api/next.txt -except $GOROOT/api/except.txt
185
186 echo
187 echo ALL TESTS PASSED
188
189 exit 1