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.
9 export GOROOT # the api test requires GOROOT to be set.
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
15 # no core files, please
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'.
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)
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)
35 # allow all.bash to avoid double-build of everything
37 if [ "$1" == "--no-rebuild" ]; then
40 echo '# Building packages and commands.'
41 time go install -a -v std
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.
50 # increase timeout for ARM up to 3 times the normal value
52 [ "$GOARCH" == "arm" ] && timeout_scale=3
54 echo '# Testing packages.'
55 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s -gcflags "$GO_GCFLAGS"
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
65 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
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)
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
82 builtin cd "$GOROOT"/src/$1 || exit 1
85 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
88 # GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
89 # Copyright (C) 2007 Free Software Foundation, Inc.
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.
95 # $ set -e; (set -e; false; echo still here) || echo stopped
97 # # somehow the '|| echo stopped' broke the inner set -e.
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.
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
110 [ "$CGO_ENABLED" != 1 ] ||
111 [ "$GOHOSTOS" == windows ] ||
112 (xcd ../misc/cgo/stdio
113 go run $GOROOT/test/run.go - . || exit 1
116 [ "$CGO_ENABLED" != 1 ] ||
117 (xcd ../misc/cgo/life
118 go run $GOROOT/test/run.go - . || exit 1
121 [ "$CGO_ENABLED" != 1 ] ||
122 (xcd ../misc/cgo/test
123 # cgo tests inspect the traceback for runtime functions
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
133 darwin-386 | darwin-amd64)
134 # linkmode=external fails on OS X 10.6 and earlier == Darwin
138 *) go test -ldflags '-linkmode=external' || exit 1;;
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
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.)
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."
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
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
174 # [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
175 # (xcd ../misc/cgo/testcdefs
176 # ./test.bash || exit 1
179 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
180 (xcd ../misc/cgo/testgodefs
181 ./test.bash || exit 1
184 [ "$CGO_ENABLED" != 1 ] ||
185 [ "$GOHOSTOS" == windows ] ||
186 (xcd ../misc/cgo/testso
187 ./test.bash || exit 1
190 [ "$CGO_ENABLED" != 1 ] ||
191 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
192 (xcd ../misc/cgo/testasan
193 go run main.go || exit 1
196 [ "$CGO_ENABLED" != 1 ] ||
197 [ "$GOHOSTOS" == windows ] ||
198 (xcd ../misc/cgo/errors
199 ./test.bash || exit 1
202 [ "$GOOS" == nacl ] ||
203 [ "$GOOS" == android ] ||
208 [ "$GOOS" == android ] ||
209 [ "$GOOS" == nacl ] ||
210 [ "$GOARCH" == arm ] || # uses network, fails under QEMU
211 (xcd ../doc/articles/wiki
212 ./test.bash || exit 1
215 [ "$GOOS" == android ] ||
216 [ "$GOOS" == nacl ] ||
221 [ "$GOOS" == nacl ] ||
222 [ "$GOARCH" == arm ] ||
223 (xcd ../test/bench/shootout
224 time ./timing.sh -test || exit 1
227 [ "$GOOS" == android ] || # TODO(crawshaw): get this working
228 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
231 echo '#' ../test/bench/go1
232 go test ../test/bench/go1 || exit 1
235 [ "$GOOS" == android ] ||
238 GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build -o runtest run.go || exit 1
239 time ./runtest || exit 1
243 [ "$GOOS" == android ] ||
244 [ "$GOOS" == nacl ] ||
247 echo '# SKIPPING API CHECK UNTIL ALL SYSTEMS BUILD.'
248 # time go run $GOROOT/src/cmd/api/run.go || exit 1
252 echo ALL TESTS PASSED