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.
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
14 # no core files, please
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'.
21 # Note that ulimit -S -n may fail if ulimit -H -n is set higher than a
22 # non-root process is allowed to set the high limit.
23 # This is a system misconfiguration and should be fixed on the
24 # broken system, not "fixed" by ignoring the failure here.
25 # See longer discussion on golang.org/issue/7381.
26 [ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
27 [ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
29 # Thread count limit on NetBSD 7.
30 if ulimit -T &> /dev/null; then
31 [ "$(ulimit -H -T)" == "unlimited" ] || ulimit -S -T $(ulimit -H -T)
34 # allow all.bash to avoid double-build of everything
36 if [ "$1" = "--no-rebuild" ]; then
39 echo '# Building packages and commands.'
40 time go install -a -v std
44 # we must unset GOROOT_FINAL before tests, because runtime/debug requires
45 # correct access to source code, so if we have GOROOT_FINAL in effect,
46 # at least runtime/debug test will fail.
49 # increase timeout for ARM up to 3 times the normal value
51 [ "$GOARCH" == "arm" ] && timeout_scale=3
53 echo '# Testing packages.'
54 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
57 # We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
58 # creation of first goroutines and first garbage collections in the parallel setting.
59 echo '# GOMAXPROCS=2 runtime -cpu=1,2,4'
60 GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu=1,2,4
64 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
66 # Race detector only supported on Linux and OS X,
67 # and only on amd64, and only when cgo is enabled.
68 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
69 linux-linux-amd64-1 | darwin-darwin-amd64-1)
71 echo '# Testing race detector.'
72 go test -race -i runtime/race flag
73 go test -race -run=Output runtime/race
74 go test -race -short flag
80 builtin cd "$GOROOT"/src/$1 || exit 1
83 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
86 # GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
87 # Copyright (C) 2007 Free Software Foundation, Inc.
89 # $ set -e; (set -e; false; echo still here); echo subshell exit status $?
90 # subshell exit status 1
91 # # subshell stopped early, set exit status, but outer set -e didn't stop.
93 # $ set -e; (set -e; false; echo still here) || echo stopped
95 # # somehow the '|| echo stopped' broke the inner set -e.
97 # To avoid this bug, every command in a subshell should have '|| exit 1' on it.
98 # Strictly speaking, the test may be unnecessary on the final command of
99 # the subshell, but it aids later editing and may avoid future bash bugs.
101 [ "$CGO_ENABLED" != 1 ] ||
102 [ "$GOHOSTOS" == windows ] ||
103 (xcd ../misc/cgo/stdio
104 go run $GOROOT/test/run.go - . || exit 1
107 [ "$CGO_ENABLED" != 1 ] ||
108 (xcd ../misc/cgo/life
109 go run $GOROOT/test/run.go - . || exit 1
112 [ "$CGO_ENABLED" != 1 ] ||
113 (xcd ../misc/cgo/test
114 go test -ldflags '-linkmode=auto' || exit 1
115 # linkmode=internal fails on dragonfly since errno is a TLS relocation.
116 [ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1
117 case "$GOHOSTOS-$GOARCH" in
118 openbsd-386 | openbsd-amd64)
119 # test linkmode=external, but __thread not supported, so skip testtls.
120 go test -ldflags '-linkmode=external' || exit 1
122 darwin-386 | darwin-amd64)
123 # linkmode=external fails on OS X 10.6 and earlier == Darwin
127 *) go test -ldflags '-linkmode=external' || exit 1;;
130 dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | freebsd-arm | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64)
131 go test -ldflags '-linkmode=external' || exit 1
132 go test -ldflags '-linkmode=auto' ../testtls || exit 1
133 go test -ldflags '-linkmode=external' ../testtls || exit 1
135 case "$GOHOSTOS-$GOARCH" in
136 netbsd-386 | netbsd-amd64) ;; # no static linking
137 freebsd-arm) ;; # -fPIC compiled tls code will use __tls_get_addr instead
138 # of __aeabi_read_tp, however, on FreeBSD/ARM, __tls_get_addr
139 # is implemented in rtld-elf, so -fPIC isn't compatible with
140 # static linking on FreeBSD/ARM with clang. (cgo depends on
141 # -fPIC fundamentally.)
143 go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../testtls || exit 1
150 # This tests cgo -godefs. That mode is not supported,
151 # so it's okay if it doesn't work on some systems.
152 # In particular, it works badly with clang on OS X.
153 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
154 (xcd ../misc/cgo/testcdefs
155 ./test.bash || exit 1
158 [ "$CGO_ENABLED" != 1 ] ||
159 [ "$GOHOSTOS" == windows ] ||
160 (xcd ../misc/cgo/testso
161 ./test.bash || exit 1
164 [ "$CGO_ENABLED" != 1 ] ||
165 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
166 (xcd ../misc/cgo/testasan
167 go run main.go || exit 1
170 [ "$CGO_ENABLED" != 1 ] ||
171 [ "$GOHOSTOS" == windows ] ||
172 (xcd ../misc/cgo/errors
173 ./test.bash || exit 1
180 [ "$GOARCH" == arm ] || # uses network, fails under QEMU
181 (xcd ../doc/articles/wiki
182 ./test.bash || exit 1
190 echo '#' ../misc/goplay
191 go build ../misc/goplay
194 [ "$GOARCH" == arm ] ||
195 (xcd ../test/bench/shootout
196 time ./timing.sh -test || exit 1
199 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
202 echo '#' ../test/bench/go1
203 go test ../test/bench/go1 || exit 1
208 time go run run.go || exit 1
212 echo '# Checking API compatibility.'
213 time go run $GOROOT/src/cmd/api/run.go
216 echo ALL TESTS PASSED