]> Cypherpunks.ru repositories - gostls13.git/blob - src/run.bash
runtime, cmd/ld, cmd/5l, run.bash: enable external linking on FreeBSD/ARM.
[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 #
21 # Note that ulimit -S -n may fail if ulimit -H -n is set higher than a
22 # non-root process is allowed to set the high limit.
23 # This is a system misconfiguration and should be fixed on the
24 # broken system, not "fixed" by ignoring the failure here.
25 # See longer discussion on golang.org/issue/7381. 
26 [ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
27 [ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
28
29 # Thread count limit on NetBSD 7.
30 if ulimit -T &> /dev/null; then
31         [ "$(ulimit -H -T)" == "unlimited" ] || ulimit -S -T $(ulimit -H -T)
32 fi
33
34 # allow all.bash to avoid double-build of everything
35 rebuild=true
36 if [ "$1" = "--no-rebuild" ]; then
37         shift
38 else
39         echo '# Building packages and commands.'
40         time go install -a -v std
41         echo
42 fi
43
44 # we must unset GOROOT_FINAL before tests, because runtime/debug requires
45 # correct access to source code, so if we have GOROOT_FINAL in effect,
46 # at least runtime/debug test will fail.
47 unset GOROOT_FINAL
48
49 # increase timeout for ARM up to 3 times the normal value
50 timeout_scale=1
51 [ "$GOARCH" == "arm" ] && timeout_scale=3
52
53 echo '# Testing packages.'
54 time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
55 echo
56
57 # We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
58 # creation of first goroutines and first garbage collections in the parallel setting.
59 echo '# GOMAXPROCS=2 runtime -cpu=1,2,4'
60 GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu=1,2,4
61 echo
62
63 echo '# sync -cpu=10'
64 go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
65
66 # Race detector only supported on Linux and OS X,
67 # and only on amd64, and only when cgo is enabled.
68 case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
69 linux-linux-amd64-1 | darwin-darwin-amd64-1)
70         echo
71         echo '# Testing race detector.'
72         go test -race -i runtime/race flag
73         go test -race -run=Output runtime/race
74         go test -race -short flag
75 esac
76
77 xcd() {
78         echo
79         echo '#' $1
80         builtin cd "$GOROOT"/src/$1 || exit 1
81 }
82
83 # NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
84 #
85 #       $ bash --version
86 #       GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
87 #       Copyright (C) 2007 Free Software Foundation, Inc.
88 #
89 #       $ set -e; (set -e; false; echo still here); echo subshell exit status $?
90 #       subshell exit status 1
91 #       # subshell stopped early, set exit status, but outer set -e didn't stop.
92 #
93 #       $ set -e; (set -e; false; echo still here) || echo stopped
94 #       still here
95 #       # somehow the '|| echo stopped' broke the inner set -e.
96 #       
97 # To avoid this bug, every command in a subshell should have '|| exit 1' on it.
98 # Strictly speaking, the test may be unnecessary on the final command of
99 # the subshell, but it aids later editing and may avoid future bash bugs.
100
101 [ "$CGO_ENABLED" != 1 ] ||
102 [ "$GOHOSTOS" == windows ] ||
103 (xcd ../misc/cgo/stdio
104 go run $GOROOT/test/run.go - . || exit 1
105 ) || exit $?
106
107 [ "$CGO_ENABLED" != 1 ] ||
108 (xcd ../misc/cgo/life
109 go run $GOROOT/test/run.go - . || exit 1
110 ) || exit $?
111
112 [ "$CGO_ENABLED" != 1 ] ||
113 (xcd ../misc/cgo/test
114 go test -ldflags '-linkmode=auto' || exit 1
115 # linkmode=internal fails on dragonfly since errno is a TLS relocation.
116 [ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1
117 case "$GOHOSTOS-$GOARCH" in
118 openbsd-386 | openbsd-amd64)
119         # test linkmode=external, but __thread not supported, so skip testtls.
120         go test -ldflags '-linkmode=external' || exit 1
121         ;;
122 darwin-386 | darwin-amd64)
123         # linkmode=external fails on OS X 10.6 and earlier == Darwin
124         # 10.8 and earlier.
125         case $(uname -r) in
126         [0-9].* | 10.*) ;;
127         *) go test -ldflags '-linkmode=external'  || exit 1;;
128         esac
129         ;;
130 dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | freebsd-arm | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64)
131         go test -ldflags '-linkmode=external' || exit 1
132         go test -ldflags '-linkmode=auto' ../testtls || exit 1
133         go test -ldflags '-linkmode=external' ../testtls || exit 1
134         
135         case "$GOHOSTOS-$GOARCH" in
136         netbsd-386 | netbsd-amd64) ;; # no static linking
137         freebsd-arm) ;; # -fPIC compiled tls code will use __tls_get_addr instead
138                         # of __aeabi_read_tp, however, on FreeBSD/ARM, __tls_get_addr
139                         # is implemented in rtld-elf, so -fPIC isn't compatible with
140                         # static linking on FreeBSD/ARM with clang. (cgo depends on
141                         # -fPIC fundamentally.)
142         *)
143                 go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../testtls || exit 1
144                 ;;
145         esac
146         ;;
147 esac
148 ) || exit $?
149
150 # This tests cgo -godefs. That mode is not supported,
151 # so it's okay if it doesn't work on some systems.
152 # In particular, it works badly with clang on OS X.
153 [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
154 (xcd ../misc/cgo/testcdefs
155 ./test.bash || exit 1
156 ) || exit $?
157
158 [ "$CGO_ENABLED" != 1 ] ||
159 [ "$GOHOSTOS" == windows ] ||
160 (xcd ../misc/cgo/testso
161 ./test.bash || exit 1
162 ) || exit $?
163
164 [ "$CGO_ENABLED" != 1 ] ||
165 [ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
166 (xcd ../misc/cgo/testasan
167 go run main.go || exit 1
168 ) || exit $?
169
170 [ "$CGO_ENABLED" != 1 ] ||
171 [ "$GOHOSTOS" == windows ] ||
172 (xcd ../misc/cgo/errors
173 ./test.bash || exit 1
174 ) || exit $?
175
176 (xcd ../doc/progs
177 time ./run || exit 1
178 ) || exit $?
179
180 [ "$GOARCH" == arm ] ||  # uses network, fails under QEMU
181 (xcd ../doc/articles/wiki
182 ./test.bash || exit 1
183 ) || exit $?
184
185 (xcd ../doc/codewalk
186 time ./run || exit 1
187 ) || exit $?
188
189 echo
190 echo '#' ../misc/goplay
191 go build ../misc/goplay
192 rm -f goplay
193
194 [ "$GOARCH" == arm ] ||
195 (xcd ../test/bench/shootout
196 time ./timing.sh -test || exit 1
197 ) || exit $?
198
199 [ "$GOOS" == openbsd ] || # golang.org/issue/5057
200 (
201 echo
202 echo '#' ../test/bench/go1
203 go test ../test/bench/go1 || exit 1
204 ) || exit $?
205
206 (xcd ../test
207 unset GOMAXPROCS
208 time go run run.go || exit 1
209 ) || exit $?
210
211 echo
212 echo '# Checking API compatibility.'
213 time go run $GOROOT/src/cmd/api/run.go
214
215 echo
216 echo ALL TESTS PASSED