]> Cypherpunks.ru repositories - gostls13.git/blob - src/run.bash
cmd/gc: correct liveness for fat variables
[gostls13.git] / src / run.bash
1 #!/usr/bin/env bash
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
8 eval $(go env)
9
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
13
14 # no core files, please
15 ulimit -c 0
16
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)
22
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)
26 fi
27
28 # allow all.bash to avoid double-build of everything
29 rebuild=true
30 if [ "$1" = "--no-rebuild" ]; then
31         shift
32 else
33         echo '# Building packages and commands.'
34         time go install -a -v std
35         echo
36 fi
37
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.
41 unset GOROOT_FINAL
42
43 # increase timeout for ARM up to 3 times the normal value
44 timeout_scale=1
45 [ "$GOARCH" == "arm" ] && timeout_scale=3
46
47 echo '# Testing packages.'
48 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
49 echo
50
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
53 echo
54
55 echo '# sync -cpu=10'
56 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
57
58 # Race detector only supported on Linux and OS X,
59 # and only on amd64, and only when cgo is enabled.
60 # Disabled due to golang.org/issue/7334; remove XXX below to reenable.
61 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
62 XXXlinux-linux-amd64-1 | XXXdarwin-darwin-amd64-1)
63         echo
64         echo '# Testing race detector.'
65         go test -race -i runtime/race flag
66         go test -race -run=Output runtime/race
67         go test -race -short flag
68 esac
69
70 xcd() {
71         echo
72         echo '#' $1
73         builtin cd "$GOROOT"/src/$1 || exit 1
74 }
75
76 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
77 #
78 #       $ bash --version
79 #       GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
80 #       Copyright (C) 2007 Free Software Foundation, Inc.
81 #
82 #       $ set -e; (set -e; false; echo still here); echo subshell exit status $?
83 #       subshell exit status 1
84 #       # subshell stopped early, set exit status, but outer set -e didn't stop.
85 #
86 #       $ set -e; (set -e; false; echo still here) || echo stopped
87 #       still here
88 #       # somehow the '|| echo stopped' broke the inner set -e.
89 #       
90 # To avoid this bug, every command in a subshell should have '|| exit 1' on it.
91 # Strictly speaking, the test may be unnecessary on the final command of
92 # the subshell, but it aids later editing and may avoid future bash bugs.
93
94 [ "$CGO_ENABLED" != 1 ] ||
95 [ "$GOHOSTOS" == windows ] ||
96 (xcd ../misc/cgo/stdio
97 go run $GOROOT/test/run.go - . || exit 1
98 ) || exit $?
99
100 [ "$CGO_ENABLED" != 1 ] ||
101 (xcd ../misc/cgo/life
102 go run $GOROOT/test/run.go - . || exit 1
103 ) || exit $?
104
105 [ "$CGO_ENABLED" != 1 ] ||
106 (xcd ../misc/cgo/test
107 go test -ldflags '-linkmode=auto' || exit 1
108 # linkmode=internal fails on dragonfly since errno is a TLS relocation.
109 [ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1
110 case "$GOHOSTOS-$GOARCH" in
111 openbsd-386 | openbsd-amd64)
112         # test linkmode=external, but __thread not supported, so skip testtls.
113         go test -ldflags '-linkmode=external' || exit 1
114         ;;
115 darwin-386 | darwin-amd64)
116         # linkmode=external fails on OS X 10.6 and earlier == Darwin
117         # 10.8 and earlier.
118         case $(uname -r) in
119         [0-9].* | 10.*) ;;
120         *) go test -ldflags '-linkmode=external'  || exit 1;;
121         esac
122         ;;
123 dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64)
124         go test -ldflags '-linkmode=external' || exit 1
125         go test -ldflags '-linkmode=auto' ../testtls || exit 1
126         go test -ldflags '-linkmode=external' ../testtls || exit 1
127 esac
128 ) || exit $?
129
130 # This tests cgo -godefs. That mode is not supported,
131 # so it's okay if it doesn't work on some systems.
132 # In particular, it works badly with clang on OS X.
133 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
134 (xcd ../misc/cgo/testcdefs
135 ./test.bash || exit 1
136 ) || exit $?
137
138 [ "$CGO_ENABLED" != 1 ] ||
139 [ "$GOHOSTOS" == windows ] ||
140 (xcd ../misc/cgo/testso
141 ./test.bash || exit 1
142 ) || exit $?
143
144 [ "$CGO_ENABLED" != 1 ] ||
145 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
146 (xcd ../misc/cgo/testasan
147 go run main.go || exit 1
148 ) || exit $?
149
150 [ "$CGO_ENABLED" != 1 ] ||
151 [ "$GOHOSTOS" == windows ] ||
152 (xcd ../misc/cgo/errors
153 ./test.bash || exit 1
154 ) || exit $?
155
156 (xcd ../doc/progs
157 time ./run || exit 1
158 ) || exit $?
159
160 [ "$GOARCH" == arm ] ||  # uses network, fails under QEMU
161 (xcd ../doc/articles/wiki
162 make clean || exit 1
163 ./test.bash || exit 1
164 ) || exit $?
165
166 (xcd ../doc/codewalk
167 time ./run || exit 1
168 ) || exit $?
169
170 echo
171 echo '#' ../misc/goplay
172 go build ../misc/goplay
173 rm -f goplay
174
175 [ "$GOARCH" == arm ] ||
176 (xcd ../test/bench/shootout
177 ./timing.sh -test || exit 1
178 ) || exit $?
179
180 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
181 (
182 echo
183 echo '#' ../test/bench/go1
184 go test ../test/bench/go1 || exit 1
185 ) || exit $?
186
187 (xcd ../test
188 unset GOMAXPROCS
189 time go run run.go || exit 1
190 ) || exit $?
191
192 echo
193 echo '# Checking API compatibility.'
194 time go run $GOROOT/src/cmd/api/run.go
195
196 echo
197 echo ALL TESTS PASSED