]> Cypherpunks.ru repositories - gostls13.git/blob - src/run.bash
[dev.garbage] runtime: Stop running gs during the GCscan phase.
[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 export GOROOT   # the api test requires GOROOT to be set.
10
11 unset CDPATH    # in case user has it set
12 unset GOPATH    # we disallow local import for non-local packages, if $GOROOT happens
13                 # to be under $GOPATH, then some tests below will fail
14
15 # no core files, please
16 ulimit -c 0
17
18 # Raise soft limits to hard limits for NetBSD/OpenBSD.
19 # We need at least 256 files and ~300 MB of bss.
20 # On OS X ulimit -S -n rejects 'unlimited'.
21 #
22 # Note that ulimit -S -n may fail if ulimit -H -n is set higher than a
23 # non-root process is allowed to set the high limit.
24 # This is a system misconfiguration and should be fixed on the
25 # broken system, not "fixed" by ignoring the failure here.
26 # See longer discussion on golang.org/issue/7381. 
27 [ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
28 [ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
29
30 # Thread count limit on NetBSD 7.
31 if ulimit -T &> /dev/null; then
32         [ "$(ulimit -H -T)" == "unlimited" ] || ulimit -S -T $(ulimit -H -T)
33 fi
34
35 # allow all.bash to avoid double-build of everything
36 rebuild=true
37 if [ "$1" == "--no-rebuild" ]; then
38         shift
39 else
40         echo '# Building packages and commands.'
41         time go install -a -v std
42         echo
43 fi
44
45 # we must unset GOROOT_FINAL before tests, because runtime/debug requires
46 # correct access to source code, so if we have GOROOT_FINAL in effect,
47 # at least runtime/debug test will fail.
48 unset GOROOT_FINAL
49
50 # increase timeout for ARM up to 3 times the normal value
51 timeout_scale=1
52 [ "$GOARCH" == "arm" ] && timeout_scale=3
53
54 echo '# Testing packages.'
55 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s -gcflags "$GO_GCFLAGS"
56 echo
57
58 # We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
59 # creation of first goroutines and first garbage collections in the parallel setting.
60 echo '# GOMAXPROCS=2 runtime -cpu=1,2,4'
61 GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu=1,2,4
62 echo
63
64 echo '# sync -cpu=10'
65 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
66
67 # Race detector only supported on Linux, FreeBSD and OS X,
68 # and only on amd64, and only when cgo is enabled.
69 # DISABLED until we get garbage collection working.
70 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED-XXX-DISABLED" in
71 linux-linux-amd64-1 | freebsd-freebsd-amd64-1 | darwin-darwin-amd64-1)
72         echo
73         echo '# Testing race detector.'
74         go test -race -i runtime/race flag
75         go test -race -run=Output runtime/race
76         go test -race -short flag
77 esac
78
79 xcd() {
80         echo
81         echo '#' $1
82         builtin cd "$GOROOT"/src/$1 || exit 1
83 }
84
85 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
86 #
87 #       $ bash --version
88 #       GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
89 #       Copyright (C) 2007 Free Software Foundation, Inc.
90 #
91 #       $ set -e; (set -e; false; echo still here); echo subshell exit status $?
92 #       subshell exit status 1
93 #       # subshell stopped early, set exit status, but outer set -e didn't stop.
94 #
95 #       $ set -e; (set -e; false; echo still here) || echo stopped
96 #       still here
97 #       # somehow the '|| echo stopped' broke the inner set -e.
98 #       
99 # To avoid this bug, every command in a subshell should have '|| exit 1' on it.
100 # Strictly speaking, the test may be unnecessary on the final command of
101 # the subshell, but it aids later editing and may avoid future bash bugs.
102
103 if [ "$GOOS" == "android" ]; then
104         # Disable cgo tests on android.
105         # They are not designed to run off the host.
106         # golang.org/issue/8345
107         CGO_ENABLED=0
108 fi
109
110 [ "$CGO_ENABLED" != 1 ] ||
111 [ "$GOHOSTOS" == windows ] ||
112 (xcd ../misc/cgo/stdio
113 go run $GOROOT/test/run.go - . || exit 1
114 ) || exit $?
115
116 [ "$CGO_ENABLED" != 1 ] ||
117 (xcd ../misc/cgo/life
118 go run $GOROOT/test/run.go - . || exit 1
119 ) || exit $?
120
121 [ "$CGO_ENABLED" != 1 ] ||
122 (xcd ../misc/cgo/test
123 # cgo tests inspect the traceback for runtime functions
124 export GOTRACEBACK=2
125 go test -ldflags '-linkmode=auto' || exit 1
126 # linkmode=internal fails on dragonfly since errno is a TLS relocation.
127 [ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1
128 case "$GOHOSTOS-$GOARCH" in
129 openbsd-386 | openbsd-amd64)
130         # test linkmode=external, but __thread not supported, so skip testtls.
131         go test -ldflags '-linkmode=external' || exit 1
132         ;;
133 darwin-386 | darwin-amd64)
134         # linkmode=external fails on OS X 10.6 and earlier == Darwin
135         # 10.8 and earlier.
136         case $(uname -r) in
137         [0-9].* | 10.*) ;;
138         *) go test -ldflags '-linkmode=external'  || exit 1;;
139         esac
140         ;;
141 android-arm | dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | freebsd-arm | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64)
142         go test -ldflags '-linkmode=external' || exit 1
143         go test -ldflags '-linkmode=auto' ../testtls || exit 1
144         go test -ldflags '-linkmode=external' ../testtls || exit 1
145         
146         case "$GOHOSTOS-$GOARCH" in
147         netbsd-386 | netbsd-amd64) ;; # no static linking
148         freebsd-arm) ;; # -fPIC compiled tls code will use __tls_get_addr instead
149                         # of __aeabi_read_tp, however, on FreeBSD/ARM, __tls_get_addr
150                         # is implemented in rtld-elf, so -fPIC isn't compatible with
151                         # static linking on FreeBSD/ARM with clang. (cgo depends on
152                         # -fPIC fundamentally.)
153         *)
154                 if ! $CC -xc -o /dev/null -static - 2>/dev/null <<<'int main() {}' ; then
155                         echo "No support for static linking found (lacks libc.a?), skip cgo static linking test."
156                 else
157                         go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../testtls || exit 1
158                         go test ../nocgo || exit 1
159                         go test -ldflags '-linkmode=external' ../nocgo || exit 1
160                         go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../nocgo || exit 1
161                 fi
162                 ;;
163         esac
164         ;;
165 esac
166 ) || exit $?
167
168 # This tests cgo -cdefs. That mode is not supported,
169 # so it's okay if it doesn't work on some systems.
170 # In particular, it works badly with clang on OS X.
171 # It doesn't work at all now that we disallow C code
172 # outside runtime. Once runtime has no C code it won't
173 # even be necessary.
174 # [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
175 # (xcd ../misc/cgo/testcdefs
176 # ./test.bash || exit 1
177 # ) || exit $?
178
179 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
180 (xcd ../misc/cgo/testgodefs
181 ./test.bash || exit 1
182 ) || exit $?
183
184 [ "$CGO_ENABLED" != 1 ] ||
185 [ "$GOHOSTOS" == windows ] ||
186 (xcd ../misc/cgo/testso
187 ./test.bash || exit 1
188 ) || exit $?
189
190 [ "$CGO_ENABLED" != 1 ] ||
191 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
192 (xcd ../misc/cgo/testasan
193 go run main.go || exit 1
194 ) || exit $?
195
196 [ "$CGO_ENABLED" != 1 ] ||
197 [ "$GOHOSTOS" == windows ] ||
198 (xcd ../misc/cgo/errors
199 ./test.bash || exit 1
200 ) || exit $?
201
202 [ "$GOOS" == nacl ] ||
203 [ "$GOOS" == android ] ||
204 (xcd ../doc/progs
205 time ./run || exit 1
206 ) || exit $?
207
208 [ "$GOOS" == android ] ||
209 [ "$GOOS" == nacl ] ||
210 [ "$GOARCH" == arm ] ||  # uses network, fails under QEMU
211 (xcd ../doc/articles/wiki
212 ./test.bash || exit 1
213 ) || exit $?
214
215 [ "$GOOS" == android ] ||
216 [ "$GOOS" == nacl ] ||
217 (xcd ../doc/codewalk
218 time ./run || exit 1
219 ) || exit $?
220
221 [ "$GOOS" == nacl ] ||
222 [ "$GOARCH" == arm ] ||
223 (xcd ../test/bench/shootout
224 time ./timing.sh -test || exit 1
225 ) || exit $?
226
227 [ "$GOOS" == android ] || # TODO(crawshaw): get this working
228 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
229 (
230 echo
231 echo '#' ../test/bench/go1
232 go test ../test/bench/go1 || exit 1
233 ) || exit $?
234
235 [ "$GOOS" == android ] ||
236 (xcd ../test
237 unset GOMAXPROCS
238 GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build -o runtest run.go || exit 1
239 time ./runtest || exit 1
240 rm -f runtest
241 ) || exit $?
242
243 [ "$GOOS" == android ] ||
244 [ "$GOOS" == nacl ] ||
245 (
246 echo
247 echo '# SKIPPING API CHECK UNTIL ALL SYSTEMS BUILD.'
248 # time go run $GOROOT/src/cmd/api/run.go || exit 1
249 ) || exit $?
250
251 echo
252 echo ALL TESTS PASSED