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'.
20 [ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
21 [ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
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)
28 # allow all.bash to avoid double-build of everything
30 if [ "$1" = "--no-rebuild" ]; then
33 echo '# Building packages and commands.'
34 time go install -a -v std
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.
43 # increase timeout for ARM up to 3 times the normal value
45 [ "$GOARCH" == "arm" ] && timeout_scale=3
47 echo '# Testing packages.'
48 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
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
56 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
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)
63 echo '# Testing race detector.'
64 go test -race -i runtime/race flag
65 go test -race -run=Output runtime/race
66 go test -race -short flag
72 builtin cd "$GOROOT"/src/$1 || exit 1
75 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
78 # GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
79 # Copyright (C) 2007 Free Software Foundation, Inc.
81 # $ set -e; (set -e; false; echo still here); echo subshell exit status $?
82 # subshell exit status 1
83 # # subshell stopped early, set exit status, but outer set -e didn't stop.
85 # $ set -e; (set -e; false; echo still here) || echo stopped
87 # # somehow the '|| echo stopped' broke the inner set -e.
89 # To avoid this bug, every command in a subshell should have '|| exit 1' on it.
90 # Strictly speaking, the test may be unnecessary on the final command of
91 # the subshell, but it aids later editing and may avoid future bash bugs.
93 [ "$CGO_ENABLED" != 1 ] ||
94 [ "$GOHOSTOS" == windows ] ||
95 (xcd ../misc/cgo/stdio
96 go run $GOROOT/test/run.go - . || exit 1
99 [ "$CGO_ENABLED" != 1 ] ||
100 (xcd ../misc/cgo/life
101 go run $GOROOT/test/run.go - . || exit 1
104 [ "$CGO_ENABLED" != 1 ] ||
105 (xcd ../misc/cgo/test
106 go test -ldflags '-linkmode=auto' || exit 1
107 # linkmode=internal fails on dragonfly since errno is a TLS relocation.
108 [ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1
109 case "$GOHOSTOS-$GOARCH" in
110 openbsd-386 | openbsd-amd64)
111 # test linkmode=external, but __thread not supported, so skip testtls.
112 go test -ldflags '-linkmode=external' || exit 1
114 darwin-386 | darwin-amd64)
115 # linkmode=external fails on OS X 10.6 and earlier == Darwin
119 *) go test -ldflags '-linkmode=external' || exit 1;;
122 dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64)
123 go test -ldflags '-linkmode=external' || exit 1
124 go test -ldflags '-linkmode=auto' ../testtls || exit 1
125 go test -ldflags '-linkmode=external' ../testtls || exit 1
129 # This tests cgo -godefs. That mode is not supported,
130 # so it's okay if it doesn't work on some systems.
131 # In particular, it works badly with clang on OS X.
132 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
133 (xcd ../misc/cgo/testcdefs
134 ./test.bash || exit 1
137 [ "$CGO_ENABLED" != 1 ] ||
138 [ "$GOHOSTOS" == windows ] ||
139 (xcd ../misc/cgo/testso
140 ./test.bash || exit 1
143 [ "$CGO_ENABLED" != 1 ] ||
144 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
145 (xcd ../misc/cgo/testasan
146 go run main.go || exit 1
149 [ "$CGO_ENABLED" != 1 ] ||
150 [ "$GOHOSTOS" == windows ] ||
151 (xcd ../misc/cgo/errors
152 ./test.bash || exit 1
159 [ "$GOARCH" == arm ] || # uses network, fails under QEMU
160 (xcd ../doc/articles/wiki
162 ./test.bash || exit 1
170 echo '#' ../misc/goplay
171 go build ../misc/goplay
174 [ "$GOARCH" == arm ] ||
175 (xcd ../test/bench/shootout
176 ./timing.sh -test || exit 1
179 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
182 echo '#' ../test/bench/go1
183 go test ../test/bench/go1 || exit 1
188 time go run run.go || exit 1
192 echo '# Checking API compatibility.'
193 time go run $GOROOT/src/cmd/api/run.go
196 echo ALL TESTS PASSED