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.'
65 go test -race -short flag
71 builtin cd "$GOROOT"/src/$1 || exit 1
74 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
77 # GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
78 # Copyright (C) 2007 Free Software Foundation, Inc.
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.
84 # $ set -e; (set -e; false; echo still here) || echo stopped
86 # # somehow the '|| echo stopped' broke the inner set -e.
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.
92 [ "$CGO_ENABLED" != 1 ] ||
93 [ "$GOHOSTOS" == windows ] ||
94 (xcd ../misc/cgo/stdio
95 go run $GOROOT/test/run.go - . || exit 1
98 [ "$CGO_ENABLED" != 1 ] ||
100 go run $GOROOT/test/run.go - . || exit 1
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
112 darwin-386 | darwin-amd64)
113 # linkmode=external fails on OS X 10.6 and earlier == Darwin
117 *) go test -ldflags '-linkmode=external' || exit 1;;
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
127 [ "$CGO_ENABLED" != 1 ] ||
128 (xcd ../misc/cgo/testcdefs
129 ./test.bash || exit 1
132 [ "$CGO_ENABLED" != 1 ] ||
133 [ "$GOHOSTOS" == windows ] ||
134 (xcd ../misc/cgo/testso
135 ./test.bash || exit 1
138 [ "$CGO_ENABLED" != 1 ] ||
139 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
140 (xcd ../misc/cgo/testasan
141 go run main.go || exit 1
148 [ "$GOARCH" == arm ] || # uses network, fails under QEMU
149 (xcd ../doc/articles/wiki
151 ./test.bash || exit 1
155 # TODO: test these too.
156 go build pig.go || exit 1
157 go build urlpoll.go || exit 1
162 echo '#' ../misc/dashboard/builder ../misc/goplay
163 go build ../misc/dashboard/builder ../misc/goplay
165 [ "$GOARCH" == arm ] ||
166 (xcd ../test/bench/shootout
167 ./timing.sh -test || exit 1
170 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
173 echo '#' ../test/bench/go1
174 go test ../test/bench/go1 || exit 1
179 time go run run.go || exit 1
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
187 echo ALL TESTS PASSED