LEFT | RIGHT |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright 2009 The Go Authors. All rights reserved. | 2 # Copyright 2009 The Go Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style | 3 # Use of this source code is governed by a BSD-style |
4 # license that can be found in the LICENSE file. | 4 # license that can be found in the LICENSE file. |
5 | 5 |
6 set -e | 6 set -e |
7 | 7 |
8 eval $(go env) | 8 eval $(go env) |
9 | 9 |
10 unset CDPATH # in case user has it set | 10 unset CDPATH # in case user has it set |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 # increase timeout for ARM up to 3 times the normal value | 43 # increase timeout for ARM up to 3 times the normal value |
44 timeout_scale=1 | 44 timeout_scale=1 |
45 [ "$GOARCH" == "arm" ] && timeout_scale=3 | 45 [ "$GOARCH" == "arm" ] && timeout_scale=3 |
46 | 46 |
47 echo '# Testing packages.' | 47 echo '# Testing packages.' |
48 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s | 48 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s |
49 echo | 49 echo |
50 | 50 |
51 echo '# GOMAXPROCS=2 runtime -cpu=1,2,4' | 51 echo '# GOMAXPROCS=2 runtime -cpu=1,2,4' |
52 GOMAXPROCS=2 go test runtime -short -timeout=$(expr 240 \* $timeout_scale)s -cpu
=1,2,4 | 52 GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu
=1,2,4 |
53 echo | 53 echo |
54 | 54 |
55 echo '# sync -cpu=10' | 55 echo '# sync -cpu=10' |
56 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10 | 56 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10 |
57 | 57 |
58 # Race detector only supported on Linux and OS X, | 58 # Race detector only supported on Linux and OS X, |
59 # and only on amd64, and only when cgo is enabled. | 59 # and only on amd64, and only when cgo is enabled. |
60 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in | 60 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in |
61 linux-linux-amd64-1 | darwin-darwin-amd64-1) | 61 linux-linux-amd64-1 | darwin-darwin-amd64-1) |
62 echo | 62 echo |
63 echo '# Testing race detector.' | 63 echo '# Testing race detector.' |
64 » go test -race -i flag | 64 » go test -race -i runtime/race flag |
| 65 » go test -race -run=Output runtime/race |
65 go test -race -short flag | 66 go test -race -short flag |
66 esac | 67 esac |
67 | 68 |
68 xcd() { | 69 xcd() { |
69 echo | 70 echo |
70 echo '#' $1 | 71 echo '#' $1 |
71 » builtin cd "$GOROOT"/src/$1 | 72 » builtin cd "$GOROOT"/src/$1 || exit 1 |
72 } | 73 } |
| 74 |
| 75 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||
. |
| 76 # |
| 77 # $ bash --version |
| 78 # GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12) |
| 79 # Copyright (C) 2007 Free Software Foundation, Inc. |
| 80 # |
| 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. |
| 84 # |
| 85 # $ set -e; (set -e; false; echo still here) || echo stopped |
| 86 # still here |
| 87 # # somehow the '|| echo stopped' broke the inner set -e. |
| 88 #······· |
| 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. |
73 | 92 |
74 [ "$CGO_ENABLED" != 1 ] || | 93 [ "$CGO_ENABLED" != 1 ] || |
75 [ "$GOHOSTOS" == windows ] || | 94 [ "$GOHOSTOS" == windows ] || |
76 (xcd ../misc/cgo/stdio | 95 (xcd ../misc/cgo/stdio |
77 go run $GOROOT/test/run.go - . | 96 go run $GOROOT/test/run.go - . || exit 1 |
78 ) || exit $? | 97 ) || exit $? |
79 | 98 |
80 [ "$CGO_ENABLED" != 1 ] || | 99 [ "$CGO_ENABLED" != 1 ] || |
81 (xcd ../misc/cgo/life | 100 (xcd ../misc/cgo/life |
82 go run $GOROOT/test/run.go - . | 101 go run $GOROOT/test/run.go - . || exit 1 |
83 ) || exit $? | 102 ) || exit $? |
84 | 103 |
85 [ "$CGO_ENABLED" != 1 ] || | 104 [ "$CGO_ENABLED" != 1 ] || |
86 (xcd ../misc/cgo/test | 105 (xcd ../misc/cgo/test |
87 set -e | 106 go test -ldflags '-linkmode=auto' || exit 1 |
88 go test -ldflags '-linkmode=auto' | 107 go test -ldflags '-linkmode=internal' || exit 1 |
89 go test -ldflags '-linkmode=internal' | |
90 case "$GOHOSTOS-$GOARCH" in | 108 case "$GOHOSTOS-$GOARCH" in |
91 openbsd-386 | openbsd-amd64) | 109 openbsd-386 | openbsd-amd64) |
92 # test linkmode=external, but __thread not supported, so skip testtls. | 110 # test linkmode=external, but __thread not supported, so skip testtls. |
93 » go test -ldflags '-linkmode=external' | 111 » go test -ldflags '-linkmode=external' || exit 1 |
94 ;; | 112 ;; |
95 darwin-386 | darwin-amd64) | 113 darwin-386 | darwin-amd64) |
96 # linkmode=external fails on OS X 10.6 and earlier == Darwin | 114 # linkmode=external fails on OS X 10.6 and earlier == Darwin |
97 # 10.8 and earlier. | 115 # 10.8 and earlier. |
98 case $(uname -r) in | 116 case $(uname -r) in |
99 [0-9].* | 10.*) ;; | 117 [0-9].* | 10.*) ;; |
100 » *) go test -ldflags '-linkmode=external' ;; | 118 » *) go test -ldflags '-linkmode=external' || exit 1;; |
101 esac | 119 esac |
102 ;; | 120 ;; |
103 freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | linux-arm | netbsd-386 |
netbsd-amd64) | 121 freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | linux-arm | netbsd-386 |
netbsd-amd64) |
104 » go test -ldflags '-linkmode=external' | 122 » go test -ldflags '-linkmode=external' || exit 1 |
105 » go test -ldflags '-linkmode=auto' ../testtls | 123 » go test -ldflags '-linkmode=auto' ../testtls || exit 1 |
106 » go test -ldflags '-linkmode=external' ../testtls | 124 » go test -ldflags '-linkmode=external' ../testtls || exit 1 |
107 esac | 125 esac |
| 126 ) || exit $? |
| 127 |
| 128 # This tests cgo -godefs. That mode is not supported, |
| 129 # so it's okay if it doesn't work on some systems. |
| 130 # In particular, it works badly with clang on OS X. |
| 131 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] || |
| 132 (xcd ../misc/cgo/testcdefs |
| 133 ./test.bash || exit 1 |
108 ) || exit $? | 134 ) || exit $? |
109 | 135 |
110 [ "$CGO_ENABLED" != 1 ] || | 136 [ "$CGO_ENABLED" != 1 ] || |
111 (xcd ../misc/cgo/testshared | 137 (xcd ../misc/cgo/testshared |
112 set -e | 138 set -e |
113 # Shared library tests are only run on linux/arm, because | 139 # Shared library tests are only run on linux/arm, because |
114 # only ARM supports building shared libraries without special | 140 # only ARM supports building shared libraries without special |
115 # build flags to gc and cc | 141 # build flags to gc and cc |
116 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in | 142 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in |
117 linux-linux-arm-1) | 143 linux-linux-arm-1) |
118 echo | 144 echo |
119 echo '# Testing go shared libraries.' | 145 echo '# Testing go shared libraries.' |
120 ./test.bash | 146 ./test.bash |
121 esac | 147 esac |
122 ) || exit $? | 148 ) || exit $? |
123 | 149 |
124 [ "$CGO_ENABLED" != 1 ] || | 150 [ "$CGO_ENABLED" != 1 ] || |
125 [ "$GOHOSTOS" == windows ] || | 151 [ "$GOHOSTOS" == windows ] || |
126 (xcd ../misc/cgo/testso | 152 (xcd ../misc/cgo/testso |
127 ./test.bash | 153 ./test.bash || exit 1 |
128 ) || exit $? | 154 ) || exit $? |
129 | 155 |
130 [ "$CGO_ENABLED" != 1 ] || | 156 [ "$CGO_ENABLED" != 1 ] || |
131 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] || | 157 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] || |
132 (xcd ../misc/cgo/testasan | 158 (xcd ../misc/cgo/testasan |
133 go run main.go | 159 go run main.go || exit 1 |
134 ) || exit $? | 160 ) || exit $? |
135 | 161 |
136 (xcd ../doc/progs | 162 (xcd ../doc/progs |
137 time ./run | 163 time ./run || exit 1 |
138 ) || exit $? | 164 ) || exit $? |
139 | 165 |
140 [ "$GOARCH" == arm ] || # uses network, fails under QEMU | 166 [ "$GOARCH" == arm ] || # uses network, fails under QEMU |
141 (xcd ../doc/articles/wiki | 167 (xcd ../doc/articles/wiki |
142 make clean | 168 make clean || exit 1 |
143 ./test.bash | 169 ./test.bash || exit 1 |
144 ) || exit $? | 170 ) || exit $? |
145 | 171 |
146 (xcd ../doc/codewalk | 172 (xcd ../doc/codewalk |
147 # TODO: test these too. | 173 time ./run || exit 1 |
148 set -e | 174 ) || exit $? |
149 go build pig.go | 175 |
150 go build urlpoll.go | 176 echo |
151 rm -f pig urlpoll | 177 echo '#' ../misc/goplay |
152 ) || exit $? | 178 go build ../misc/goplay |
153 | 179 rm -f goplay |
154 echo | |
155 echo '#' ../misc/dashboard/builder ../misc/goplay | |
156 go build ../misc/dashboard/builder ../misc/goplay | |
157 | 180 |
158 [ "$GOARCH" == arm ] || | 181 [ "$GOARCH" == arm ] || |
159 (xcd ../test/bench/shootout | 182 (xcd ../test/bench/shootout |
160 ./timing.sh -test | 183 ./timing.sh -test || exit 1 |
161 ) || exit $? | 184 ) || exit $? |
162 | 185 |
163 [ "$GOOS" == openbsd ] || # golang.org/issue/5057 | 186 [ "$GOOS" == openbsd ] || # golang.org/issue/5057 |
164 ( | 187 ( |
165 echo | 188 echo |
166 echo '#' ../test/bench/go1 | 189 echo '#' ../test/bench/go1 |
167 go test ../test/bench/go1 | 190 go test ../test/bench/go1 || exit 1 |
168 ) || exit $? | 191 ) || exit $? |
169 | 192 |
170 (xcd ../test | 193 (xcd ../test |
171 unset GOMAXPROCS | 194 unset GOMAXPROCS |
172 time go run run.go | 195 time go run run.go || exit 1 |
173 ) || exit $? | 196 ) || exit $? |
174 | 197 |
175 echo | 198 echo |
176 echo '# Checking API compatibility.' | 199 echo '# Checking API compatibility.' |
177 go tool api -c $GOROOT/api/go1.txt,$GOROOT/api/go1.1.txt -next $GOROOT/api/next.
txt -except $GOROOT/api/except.txt | 200 time go run $GOROOT/src/cmd/api/run.go |
178 | 201 |
179 echo | 202 echo |
180 echo ALL TESTS PASSED | 203 echo ALL TESTS PASSED |
LEFT | RIGHT |