Devon H. O'Dell | 553be84 | 2009-11-14 15:29:09 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Russ Cox | bbb00c6 | 2008-10-08 09:46:54 -0700 | [diff] [blame] | 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 | |
Shenghou Ma | 6d4da06 | 2012-03-10 03:42:23 +0800 | [diff] [blame] | 8 | eval $(go env) |
Shenghou Ma | 6f3f2d0 | 2014-04-29 14:43:10 -0400 | [diff] [blame] | 9 | export GOROOT # the api test requires GOROOT to be set. |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 10 | |
Russ Cox | 69fd2a4 | 2010-03-31 19:48:33 -0700 | [diff] [blame] | 11 | unset CDPATH # in case user has it set |
Shenghou Ma | 23322ab | 2012-03-21 00:47:27 +0800 | [diff] [blame] | 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 |
Devon H. O'Dell | 857d4cf | 2009-12-11 15:14:09 -0800 | [diff] [blame] | 14 | |
Russ Cox | da77679 | 2009-11-09 23:11:36 -0800 | [diff] [blame] | 15 | # no core files, please |
| 16 | ulimit -c 0 |
| 17 | |
Shenghou Ma | 329b27a | 2012-09-17 01:11:28 +0800 | [diff] [blame] | 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'. |
Russ Cox | e6e8945 | 2014-02-24 16:44:35 -0500 | [diff] [blame] | 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. |
Shenghou Ma | 329b27a | 2012-09-17 01:11:28 +0800 | [diff] [blame] | 27 | [ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n) |
Shenghou Ma | a1a414e | 2012-09-17 01:26:57 +0800 | [diff] [blame] | 28 | [ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d) |
Shenghou Ma | 329b27a | 2012-09-17 01:11:28 +0800 | [diff] [blame] | 29 | |
Benny Siegert | 8a4efed | 2013-06-17 19:31:58 +1000 | [diff] [blame] | 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 | |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 35 | # allow all.bash to avoid double-build of everything |
Russ Cox | 69fd2a4 | 2010-03-31 19:48:33 -0700 | [diff] [blame] | 36 | rebuild=true |
| 37 | if [ "$1" = "--no-rebuild" ]; then |
Russ Cox | 69fd2a4 | 2010-03-31 19:48:33 -0700 | [diff] [blame] | 38 | shift |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 39 | else |
| 40 | echo '# Building packages and commands.' |
| 41 | time go install -a -v std |
| 42 | echo |
Russ Cox | 69fd2a4 | 2010-03-31 19:48:33 -0700 | [diff] [blame] | 43 | fi |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 44 | |
Shenghou Ma | 34ace10 | 2012-04-04 23:14:54 +0800 | [diff] [blame] | 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 | |
Shenghou Ma | 0a517e4 | 2013-03-24 16:31:28 +0800 | [diff] [blame] | 50 | # increase timeout for ARM up to 3 times the normal value |
| 51 | timeout_scale=1 |
| 52 | [ "$GOARCH" == "arm" ] && timeout_scale=3 |
| 53 | |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 54 | echo '# Testing packages.' |
Shenghou Ma | 0a517e4 | 2013-03-24 16:31:28 +0800 | [diff] [blame] | 55 | time go test std -short -timeout=$(expr 120 \* $timeout_scale)s |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 56 | echo |
| 57 | |
Dmitriy Vyukov | 1304584 | 2014-03-06 13:16:14 +0400 | [diff] [blame] | 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. |
Rémy Oudompheng | aa1aaee | 2012-03-05 16:40:27 -0500 | [diff] [blame] | 60 | echo '# GOMAXPROCS=2 runtime -cpu=1,2,4' |
Shenghou Ma | 0ce56e60 | 2013-07-13 02:00:07 +0800 | [diff] [blame] | 61 | GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu=1,2,4 |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 62 | echo |
| 63 | |
| 64 | echo '# sync -cpu=10' |
Shenghou Ma | 0a517e4 | 2013-03-24 16:31:28 +0800 | [diff] [blame] | 65 | go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10 |
Russ Cox | 8290536 | 2012-02-04 00:54:08 -0500 | [diff] [blame] | 66 | |
Russ Cox | 6d888f1 | 2013-02-15 13:37:43 -0800 | [diff] [blame] | 67 | # Race detector only supported on Linux and OS X, |
| 68 | # and only on amd64, and only when cgo is enabled. |
Shenghou Ma | eec9614 | 2013-02-23 20:24:38 +0800 | [diff] [blame] | 69 | case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in |
Rémy Oudompheng | 475e7d0 | 2014-02-19 08:19:27 +0100 | [diff] [blame] | 70 | linux-linux-amd64-1 | darwin-darwin-amd64-1) |
Dmitriy Vyukov | 95329d4 | 2012-11-01 22:02:52 +0400 | [diff] [blame] | 71 | echo |
| 72 | echo '# Testing race detector.' |
Dmitriy Vyukov | 2791ef0 | 2013-08-12 22:04:10 +0400 | [diff] [blame] | 73 | go test -race -i runtime/race flag |
| 74 | go test -race -run=Output runtime/race |
Dmitriy Vyukov | 95329d4 | 2012-11-01 22:02:52 +0400 | [diff] [blame] | 75 | go test -race -short flag |
| 76 | esac |
| 77 | |
Russ Cox | bbb00c6 | 2008-10-08 09:46:54 -0700 | [diff] [blame] | 78 | xcd() { |
Ken Thompson | b379d54 | 2008-10-24 20:14:28 -0700 | [diff] [blame] | 79 | echo |
Russ Cox | c3f4319 | 2012-03-06 23:27:30 -0500 | [diff] [blame] | 80 | echo '#' $1 |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 81 | builtin cd "$GOROOT"/src/$1 || exit 1 |
Russ Cox | bbb00c6 | 2008-10-08 09:46:54 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 84 | # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||. |
| 85 | # |
| 86 | # $ bash --version |
| 87 | # GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12) |
| 88 | # Copyright (C) 2007 Free Software Foundation, Inc. |
| 89 | # |
| 90 | # $ set -e; (set -e; false; echo still here); echo subshell exit status $? |
| 91 | # subshell exit status 1 |
| 92 | # # subshell stopped early, set exit status, but outer set -e didn't stop. |
| 93 | # |
| 94 | # $ set -e; (set -e; false; echo still here) || echo stopped |
| 95 | # still here |
| 96 | # # somehow the '|| echo stopped' broke the inner set -e. |
| 97 | # |
| 98 | # To avoid this bug, every command in a subshell should have '|| exit 1' on it. |
| 99 | # Strictly speaking, the test may be unnecessary on the final command of |
| 100 | # the subshell, but it aids later editing and may avoid future bash bugs. |
| 101 | |
Russ Cox | c024239 | 2011-08-10 21:36:48 -0400 | [diff] [blame] | 102 | [ "$CGO_ENABLED" != 1 ] || |
Alex Brainman | 642c774 | 2011-02-09 12:37:08 +1100 | [diff] [blame] | 103 | [ "$GOHOSTOS" == windows ] || |
Russ Cox | 2d72b39 | 2009-10-03 11:33:51 -0700 | [diff] [blame] | 104 | (xcd ../misc/cgo/stdio |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 105 | go run $GOROOT/test/run.go - . || exit 1 |
Russ Cox | 2d72b39 | 2009-10-03 11:33:51 -0700 | [diff] [blame] | 106 | ) || exit $? |
| 107 | |
Russ Cox | c024239 | 2011-08-10 21:36:48 -0400 | [diff] [blame] | 108 | [ "$CGO_ENABLED" != 1 ] || |
Russ Cox | 0cd3475 | 2010-12-17 09:51:55 -0800 | [diff] [blame] | 109 | (xcd ../misc/cgo/life |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 110 | go run $GOROOT/test/run.go - . || exit 1 |
Russ Cox | 0cd3475 | 2010-12-17 09:51:55 -0800 | [diff] [blame] | 111 | ) || exit $? |
| 112 | |
Russ Cox | c024239 | 2011-08-10 21:36:48 -0400 | [diff] [blame] | 113 | [ "$CGO_ENABLED" != 1 ] || |
Russ Cox | ec713d6 | 2011-03-11 15:09:32 -0500 | [diff] [blame] | 114 | (xcd ../misc/cgo/test |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 115 | go test -ldflags '-linkmode=auto' || exit 1 |
Aulus Egnatius Varialus | 2b44b36 | 2013-09-04 15:19:21 -0700 | [diff] [blame] | 116 | # linkmode=internal fails on dragonfly since errno is a TLS relocation. |
| 117 | [ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1 |
Russ Cox | 3b85b72 | 2013-03-11 00:51:42 -0400 | [diff] [blame] | 118 | case "$GOHOSTOS-$GOARCH" in |
Ian Lance Taylor | 3197be4 | 2013-03-29 16:33:35 -0700 | [diff] [blame] | 119 | openbsd-386 | openbsd-amd64) |
Ian Lance Taylor | 30e29ee | 2013-03-27 13:27:35 -0700 | [diff] [blame] | 120 | # test linkmode=external, but __thread not supported, so skip testtls. |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 121 | go test -ldflags '-linkmode=external' || exit 1 |
Ian Lance Taylor | 30e29ee | 2013-03-27 13:27:35 -0700 | [diff] [blame] | 122 | ;; |
Ian Lance Taylor | 3197be4 | 2013-03-29 16:33:35 -0700 | [diff] [blame] | 123 | darwin-386 | darwin-amd64) |
| 124 | # linkmode=external fails on OS X 10.6 and earlier == Darwin |
| 125 | # 10.8 and earlier. |
| 126 | case $(uname -r) in |
| 127 | [0-9].* | 10.*) ;; |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 128 | *) go test -ldflags '-linkmode=external' || exit 1;; |
Ian Lance Taylor | 3197be4 | 2013-03-29 16:33:35 -0700 | [diff] [blame] | 129 | esac |
| 130 | ;; |
Shenghou Ma | d31d197 | 2014-04-21 00:08:59 -0400 | [diff] [blame] | 131 | dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | freebsd-arm | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64) |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 132 | go test -ldflags '-linkmode=external' || exit 1 |
| 133 | go test -ldflags '-linkmode=auto' ../testtls || exit 1 |
| 134 | go test -ldflags '-linkmode=external' ../testtls || exit 1 |
Russ Cox | 568e352 | 2014-04-15 15:52:02 -0400 | [diff] [blame] | 135 | |
Shenghou Ma | 560471f | 2014-04-15 23:54:04 -0400 | [diff] [blame] | 136 | case "$GOHOSTOS-$GOARCH" in |
Russ Cox | 568e352 | 2014-04-15 15:52:02 -0400 | [diff] [blame] | 137 | netbsd-386 | netbsd-amd64) ;; # no static linking |
Shenghou Ma | d31d197 | 2014-04-21 00:08:59 -0400 | [diff] [blame] | 138 | freebsd-arm) ;; # -fPIC compiled tls code will use __tls_get_addr instead |
| 139 | # of __aeabi_read_tp, however, on FreeBSD/ARM, __tls_get_addr |
| 140 | # is implemented in rtld-elf, so -fPIC isn't compatible with |
| 141 | # static linking on FreeBSD/ARM with clang. (cgo depends on |
| 142 | # -fPIC fundamentally.) |
Russ Cox | 568e352 | 2014-04-15 15:52:02 -0400 | [diff] [blame] | 143 | *) |
Shenghou Ma | 6f3f2d0 | 2014-04-29 14:43:10 -0400 | [diff] [blame] | 144 | if ! $CC -xc -o /dev/null -static - 2>/dev/null <<<'int main() {}' ; then |
| 145 | echo "No support for static linking found (lacks libc.a?), skip cgo static linking test." |
| 146 | else |
| 147 | go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../testtls || exit 1 |
| 148 | fi |
Russ Cox | 568e352 | 2014-04-15 15:52:02 -0400 | [diff] [blame] | 149 | ;; |
| 150 | esac |
| 151 | ;; |
Russ Cox | 3b85b72 | 2013-03-11 00:51:42 -0400 | [diff] [blame] | 152 | esac |
Russ Cox | ec713d6 | 2011-03-11 15:09:32 -0500 | [diff] [blame] | 153 | ) || exit $? |
| 154 | |
Russ Cox | 2ddb672 | 2013-08-02 14:58:27 -0400 | [diff] [blame] | 155 | # This tests cgo -godefs. That mode is not supported, |
| 156 | # so it's okay if it doesn't work on some systems. |
| 157 | # In particular, it works badly with clang on OS X. |
| 158 | [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] || |
Kevin Klues | f7dfeea | 2013-07-24 17:27:42 -0700 | [diff] [blame] | 159 | (xcd ../misc/cgo/testcdefs |
| 160 | ./test.bash || exit 1 |
| 161 | ) || exit $? |
| 162 | |
| 163 | [ "$CGO_ENABLED" != 1 ] || |
Dmitriy Vyukov | 11e73b8 | 2011-11-22 17:57:49 +0300 | [diff] [blame] | 164 | [ "$GOHOSTOS" == windows ] || |
Dmitriy Vyukov | 11e73b8 | 2011-11-22 17:57:49 +0300 | [diff] [blame] | 165 | (xcd ../misc/cgo/testso |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 166 | ./test.bash || exit 1 |
Dmitriy Vyukov | 11e73b8 | 2011-11-22 17:57:49 +0300 | [diff] [blame] | 167 | ) || exit $? |
| 168 | |
Dmitriy Vyukov | a8ad859 | 2013-06-12 18:47:16 +0400 | [diff] [blame] | 169 | [ "$CGO_ENABLED" != 1 ] || |
| 170 | [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] || |
| 171 | (xcd ../misc/cgo/testasan |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 172 | go run main.go || exit 1 |
Dmitriy Vyukov | a8ad859 | 2013-06-12 18:47:16 +0400 | [diff] [blame] | 173 | ) || exit $? |
| 174 | |
Ian Lance Taylor | f68c23e | 2013-09-03 21:15:15 -0700 | [diff] [blame] | 175 | [ "$CGO_ENABLED" != 1 ] || |
| 176 | [ "$GOHOSTOS" == windows ] || |
| 177 | (xcd ../misc/cgo/errors |
| 178 | ./test.bash || exit 1 |
| 179 | ) || exit $? |
| 180 | |
Rob Pike | 8d21004 | 2009-01-06 15:49:27 -0800 | [diff] [blame] | 181 | (xcd ../doc/progs |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 182 | time ./run || exit 1 |
Rob Pike | 8d21004 | 2009-01-06 15:49:27 -0800 | [diff] [blame] | 183 | ) || exit $? |
| 184 | |
Russ Cox | 6b33571 | 2011-03-27 23:39:42 -0400 | [diff] [blame] | 185 | [ "$GOARCH" == arm ] || # uses network, fails under QEMU |
Shenghou Ma | 90010f8 | 2012-03-08 06:23:56 +0800 | [diff] [blame] | 186 | (xcd ../doc/articles/wiki |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 187 | ./test.bash || exit 1 |
Alex Brainman | 3bfd35b | 2011-01-31 15:58:44 +1100 | [diff] [blame] | 188 | ) || exit $? |
Andrew Gerrand | add4e16 | 2011-01-26 14:56:52 +1000 | [diff] [blame] | 189 | |
Rob Pike | 6492cac | 2012-03-26 16:08:21 +1100 | [diff] [blame] | 190 | (xcd ../doc/codewalk |
Andrew Gerrand | fc32bfa | 2013-07-30 09:42:53 +1000 | [diff] [blame] | 191 | time ./run || exit 1 |
Rob Pike | 6492cac | 2012-03-26 16:08:21 +1100 | [diff] [blame] | 192 | ) || exit $? |
| 193 | |
Shenghou Ma | 90010f8 | 2012-03-08 06:23:56 +0800 | [diff] [blame] | 194 | echo |
Andrew Gerrand | 5f1af16 | 2013-08-01 13:49:00 +1000 | [diff] [blame] | 195 | echo '#' ../misc/goplay |
| 196 | go build ../misc/goplay |
Brad Fitzpatrick | 74d2e09 | 2013-08-02 19:14:13 -0700 | [diff] [blame] | 197 | rm -f goplay |
Andrew Gerrand | 06492d4 | 2010-10-21 10:46:10 +1100 | [diff] [blame] | 198 | |
Russ Cox | b7cb844 | 2010-09-22 15:30:42 +1000 | [diff] [blame] | 199 | [ "$GOARCH" == arm ] || |
Russ Cox | bcbb2f9 | 2011-12-13 17:46:54 -0500 | [diff] [blame] | 200 | (xcd ../test/bench/shootout |
Rémy Oudompheng | 475e7d0 | 2014-02-19 08:19:27 +0100 | [diff] [blame] | 201 | time ./timing.sh -test || exit 1 |
Rob Pike | 266a2c4 | 2009-08-09 14:31:05 -0700 | [diff] [blame] | 202 | ) || exit $? |
| 203 | |
Russ Cox | a5b2623 | 2013-03-15 12:39:14 -0400 | [diff] [blame] | 204 | [ "$GOOS" == openbsd ] || # golang.org/issue/5057 |
| 205 | ( |
Shenghou Ma | 90010f8 | 2012-03-08 06:23:56 +0800 | [diff] [blame] | 206 | echo |
| 207 | echo '#' ../test/bench/go1 |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 208 | go test ../test/bench/go1 || exit 1 |
Russ Cox | a5b2623 | 2013-03-15 12:39:14 -0400 | [diff] [blame] | 209 | ) || exit $? |
Russ Cox | 6e88755 | 2011-12-15 12:32:59 -0500 | [diff] [blame] | 210 | |
Russ Cox | bbb00c6 | 2008-10-08 09:46:54 -0700 | [diff] [blame] | 211 | (xcd ../test |
Dave Cheney | fa21df3 | 2012-11-15 13:59:46 +1100 | [diff] [blame] | 212 | unset GOMAXPROCS |
Russ Cox | 3a8845b | 2013-07-11 23:24:57 -0400 | [diff] [blame] | 213 | time go run run.go || exit 1 |
Russ Cox | 527669e | 2008-10-29 15:23:29 -0700 | [diff] [blame] | 214 | ) || exit $? |
Russ Cox | bbb00c6 | 2008-10-08 09:46:54 -0700 | [diff] [blame] | 215 | |
Brad Fitzpatrick | d5e97ea | 2013-08-07 13:49:37 -0700 | [diff] [blame] | 216 | echo |
| 217 | echo '# Checking API compatibility.' |
Russ Cox | b78410b | 2013-08-09 18:44:00 -0400 | [diff] [blame] | 218 | time go run $GOROOT/src/cmd/api/run.go |
Brad Fitzpatrick | f69132d | 2012-03-17 11:20:46 -0700 | [diff] [blame] | 219 | |
| 220 | echo |
Russ Cox | b9f9476 | 2011-02-14 09:27:02 -0500 | [diff] [blame] | 221 | echo ALL TESTS PASSED |