2009-11-14 16:29:09 -07:00
|
|
|
#!/usr/bin/env bash
|
2008-10-08 10:46:54 -06:00
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2012-03-09 12:42:23 -07:00
|
|
|
eval $(go env)
|
2014-04-29 12:43:10 -06:00
|
|
|
export GOROOT # the api test requires GOROOT to be set.
|
2012-02-03 22:54:08 -07:00
|
|
|
|
2010-03-31 20:48:33 -06:00
|
|
|
unset CDPATH # in case user has it set
|
2012-03-20 10:47:27 -06:00
|
|
|
unset GOPATH # we disallow local import for non-local packages, if $GOROOT happens
|
|
|
|
# to be under $GOPATH, then some tests below will fail
|
2009-12-11 16:14:09 -07:00
|
|
|
|
2009-11-10 00:11:36 -07:00
|
|
|
# no core files, please
|
|
|
|
ulimit -c 0
|
|
|
|
|
2012-09-16 11:11:28 -06:00
|
|
|
# Raise soft limits to hard limits for NetBSD/OpenBSD.
|
|
|
|
# We need at least 256 files and ~300 MB of bss.
|
|
|
|
# On OS X ulimit -S -n rejects 'unlimited'.
|
2014-02-24 14:44:35 -07:00
|
|
|
#
|
|
|
|
# Note that ulimit -S -n may fail if ulimit -H -n is set higher than a
|
|
|
|
# non-root process is allowed to set the high limit.
|
|
|
|
# This is a system misconfiguration and should be fixed on the
|
|
|
|
# broken system, not "fixed" by ignoring the failure here.
|
|
|
|
# See longer discussion on golang.org/issue/7381.
|
2012-09-16 11:11:28 -06:00
|
|
|
[ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
|
2012-09-16 11:26:57 -06:00
|
|
|
[ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
|
2012-09-16 11:11:28 -06:00
|
|
|
|
2013-06-17 03:31:58 -06:00
|
|
|
# Thread count limit on NetBSD 7.
|
|
|
|
if ulimit -T &> /dev/null; then
|
|
|
|
[ "$(ulimit -H -T)" == "unlimited" ] || ulimit -S -T $(ulimit -H -T)
|
|
|
|
fi
|
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
# allow all.bash to avoid double-build of everything
|
2010-03-31 20:48:33 -06:00
|
|
|
rebuild=true
|
2014-05-20 10:10:19 -06:00
|
|
|
if [ "$1" == "--no-rebuild" ]; then
|
2010-03-31 20:48:33 -06:00
|
|
|
shift
|
2012-02-03 22:54:08 -07:00
|
|
|
else
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '##### Building packages and commands.'
|
2012-01-30 21:43:46 -07:00
|
|
|
time go install -a -v std
|
2012-02-03 22:54:08 -07:00
|
|
|
echo
|
2011-02-14 07:27:02 -07:00
|
|
|
fi
|
2008-11-20 11:54:11 -07:00
|
|
|
|
2012-04-04 09:14:54 -06:00
|
|
|
# we must unset GOROOT_FINAL before tests, because runtime/debug requires
|
|
|
|
# correct access to source code, so if we have GOROOT_FINAL in effect,
|
|
|
|
# at least runtime/debug test will fail.
|
|
|
|
unset GOROOT_FINAL
|
|
|
|
|
2014-12-22 18:09:38 -07:00
|
|
|
# TODO(adg): create an environment variable and to permit the builders to
|
|
|
|
# specify the timeout scale.
|
2013-03-24 02:31:28 -06:00
|
|
|
timeout_scale=1
|
2014-12-22 18:09:38 -07:00
|
|
|
# the freebsd-* builders are slow, and there's no easy way to make them faster.
|
|
|
|
[ "$GOOS" == "freebsd" ] && timeout_scale=2
|
|
|
|
# increase timeout for ARM up to 3 times the normal value
|
2013-03-24 02:31:28 -06:00
|
|
|
[ "$GOARCH" == "arm" ] && timeout_scale=3
|
|
|
|
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '##### Testing packages.'
|
2014-09-24 13:42:47 -06:00
|
|
|
time go test std -short -timeout=$(expr 120 \* $timeout_scale)s -gcflags "$GO_GCFLAGS"
|
2012-01-30 21:43:46 -07:00
|
|
|
echo
|
2012-02-03 22:54:08 -07:00
|
|
|
|
2014-03-06 02:16:14 -07:00
|
|
|
# We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
|
|
|
|
# creation of first goroutines and first garbage collections in the parallel setting.
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '##### GOMAXPROCS=2 runtime -cpu=1,2,4'
|
2013-07-12 12:00:07 -06:00
|
|
|
GOMAXPROCS=2 go test runtime -short -timeout=$(expr 300 \* $timeout_scale)s -cpu=1,2,4
|
2012-01-30 21:43:46 -07:00
|
|
|
echo
|
2012-02-03 22:54:08 -07:00
|
|
|
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '##### sync -cpu=10'
|
2013-03-24 02:31:28 -06:00
|
|
|
go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
|
2008-12-04 13:51:36 -07:00
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
xcd() {
|
|
|
|
echo
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '#####' $1
|
2013-07-11 21:24:57 -06:00
|
|
|
builtin cd "$GOROOT"/src/$1 || exit 1
|
2012-02-03 22:54:08 -07:00
|
|
|
}
|
2012-01-30 21:43:46 -07:00
|
|
|
|
2013-07-11 21:24:57 -06:00
|
|
|
# NOTE: "set -e" cannot help us in subshells. It works until you test it with ||.
|
|
|
|
#
|
|
|
|
# $ bash --version
|
|
|
|
# GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
|
|
|
|
# Copyright (C) 2007 Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# $ set -e; (set -e; false; echo still here); echo subshell exit status $?
|
|
|
|
# subshell exit status 1
|
|
|
|
# # subshell stopped early, set exit status, but outer set -e didn't stop.
|
|
|
|
#
|
|
|
|
# $ set -e; (set -e; false; echo still here) || echo stopped
|
|
|
|
# still here
|
|
|
|
# # somehow the '|| echo stopped' broke the inner set -e.
|
|
|
|
#
|
|
|
|
# To avoid this bug, every command in a subshell should have '|| exit 1' on it.
|
|
|
|
# Strictly speaking, the test may be unnecessary on the final command of
|
|
|
|
# the subshell, but it aids later editing and may avoid future bash bugs.
|
|
|
|
|
2014-07-08 16:41:07 -06:00
|
|
|
if [ "$GOOS" == "android" ]; then
|
|
|
|
# Disable cgo tests on android.
|
|
|
|
# They are not designed to run off the host.
|
|
|
|
# golang.org/issue/8345
|
|
|
|
CGO_ENABLED=0
|
|
|
|
fi
|
|
|
|
|
2011-08-10 19:36:48 -06:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
2011-02-08 18:37:08 -07:00
|
|
|
[ "$GOHOSTOS" == windows ] ||
|
2009-10-03 12:33:51 -06:00
|
|
|
(xcd ../misc/cgo/stdio
|
2013-07-11 21:24:57 -06:00
|
|
|
go run $GOROOT/test/run.go - . || exit 1
|
2009-10-03 12:33:51 -06:00
|
|
|
) || exit $?
|
|
|
|
|
2011-08-10 19:36:48 -06:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
2010-12-17 10:51:55 -07:00
|
|
|
(xcd ../misc/cgo/life
|
2013-07-11 21:24:57 -06:00
|
|
|
go run $GOROOT/test/run.go - . || exit 1
|
2010-12-17 10:51:55 -07:00
|
|
|
) || exit $?
|
|
|
|
|
2011-08-10 19:36:48 -06:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
2011-03-11 13:09:32 -07:00
|
|
|
(xcd ../misc/cgo/test
|
runtime: keep g->syscallsp consistent after cgo->Go callbacks
Normally, the caller to runtime.entersyscall() must not return before
calling runtime.exitsyscall(), lest g->syscallsp become a dangling
pointer. runtime.cgocallbackg() violates this constraint. To work around
this, save g->syscallsp and g->syscallpc around cgo->Go callbacks, then
restore them after calling runtime.entersyscall(), which restores the
syscall stack frame pointer saved by cgocall. This allows the GC to
correctly trace a goroutine that is currently returning from a
Go->cgo->Go chain.
This also adds a check to proc.c that panics if g->syscallsp is clearly
invalid. It is not 100% foolproof, as it will not catch a case where the
stack was popped then pushed back beyond g->syscallsp, but it does catch
the present cgo issue and makes existing tests fail without the bugfix.
Fixes #7978.
LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, minux, bradfitz, iant, gobot, rsc
CC=golang-codereviews, rsc
https://golang.org/cl/131910043
2014-09-24 11:20:25 -06:00
|
|
|
# cgo tests inspect the traceback for runtime functions
|
2014-11-19 18:52:58 -07:00
|
|
|
extlink=0
|
runtime: keep g->syscallsp consistent after cgo->Go callbacks
Normally, the caller to runtime.entersyscall() must not return before
calling runtime.exitsyscall(), lest g->syscallsp become a dangling
pointer. runtime.cgocallbackg() violates this constraint. To work around
this, save g->syscallsp and g->syscallpc around cgo->Go callbacks, then
restore them after calling runtime.entersyscall(), which restores the
syscall stack frame pointer saved by cgocall. This allows the GC to
correctly trace a goroutine that is currently returning from a
Go->cgo->Go chain.
This also adds a check to proc.c that panics if g->syscallsp is clearly
invalid. It is not 100% foolproof, as it will not catch a case where the
stack was popped then pushed back beyond g->syscallsp, but it does catch
the present cgo issue and makes existing tests fail without the bugfix.
Fixes #7978.
LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, minux, bradfitz, iant, gobot, rsc
CC=golang-codereviews, rsc
https://golang.org/cl/131910043
2014-09-24 11:20:25 -06:00
|
|
|
export GOTRACEBACK=2
|
2013-07-11 21:24:57 -06:00
|
|
|
go test -ldflags '-linkmode=auto' || exit 1
|
2013-09-04 16:19:21 -06:00
|
|
|
# linkmode=internal fails on dragonfly since errno is a TLS relocation.
|
|
|
|
[ "$GOHOSTOS" == dragonfly ] || go test -ldflags '-linkmode=internal' || exit 1
|
2014-12-16 16:34:55 -07:00
|
|
|
# TODO(austin): Add linux-ppc64(le) once external linking works (issue #8912)
|
2013-03-10 22:51:42 -06:00
|
|
|
case "$GOHOSTOS-$GOARCH" in
|
2013-03-29 17:33:35 -06:00
|
|
|
openbsd-386 | openbsd-amd64)
|
2013-03-27 14:27:35 -06:00
|
|
|
# test linkmode=external, but __thread not supported, so skip testtls.
|
2013-07-11 21:24:57 -06:00
|
|
|
go test -ldflags '-linkmode=external' || exit 1
|
2014-11-19 18:52:58 -07:00
|
|
|
extlink=1
|
2013-03-27 14:27:35 -06:00
|
|
|
;;
|
2013-03-29 17:33:35 -06:00
|
|
|
darwin-386 | darwin-amd64)
|
|
|
|
# linkmode=external fails on OS X 10.6 and earlier == Darwin
|
|
|
|
# 10.8 and earlier.
|
|
|
|
case $(uname -r) in
|
|
|
|
[0-9].* | 10.*) ;;
|
2014-11-19 18:52:58 -07:00
|
|
|
*)
|
|
|
|
go test -ldflags '-linkmode=external' || exit 1
|
|
|
|
extlink=1
|
|
|
|
;;
|
2013-03-29 17:33:35 -06:00
|
|
|
esac
|
|
|
|
;;
|
2014-07-08 16:41:07 -06:00
|
|
|
android-arm | dragonfly-386 | dragonfly-amd64 | freebsd-386 | freebsd-amd64 | freebsd-arm | linux-386 | linux-amd64 | linux-arm | netbsd-386 | netbsd-amd64)
|
2013-07-11 21:24:57 -06:00
|
|
|
go test -ldflags '-linkmode=external' || exit 1
|
|
|
|
go test -ldflags '-linkmode=auto' ../testtls || exit 1
|
|
|
|
go test -ldflags '-linkmode=external' ../testtls || exit 1
|
2014-11-19 18:52:58 -07:00
|
|
|
extlink=1
|
2014-04-15 13:52:02 -06:00
|
|
|
|
2014-04-15 21:54:04 -06:00
|
|
|
case "$GOHOSTOS-$GOARCH" in
|
2014-04-15 13:52:02 -06:00
|
|
|
netbsd-386 | netbsd-amd64) ;; # no static linking
|
2014-04-20 22:08:59 -06:00
|
|
|
freebsd-arm) ;; # -fPIC compiled tls code will use __tls_get_addr instead
|
|
|
|
# of __aeabi_read_tp, however, on FreeBSD/ARM, __tls_get_addr
|
|
|
|
# is implemented in rtld-elf, so -fPIC isn't compatible with
|
|
|
|
# static linking on FreeBSD/ARM with clang. (cgo depends on
|
|
|
|
# -fPIC fundamentally.)
|
2014-04-15 13:52:02 -06:00
|
|
|
*)
|
2014-04-29 12:43:10 -06:00
|
|
|
if ! $CC -xc -o /dev/null -static - 2>/dev/null <<<'int main() {}' ; then
|
|
|
|
echo "No support for static linking found (lacks libc.a?), skip cgo static linking test."
|
|
|
|
else
|
|
|
|
go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../testtls || exit 1
|
2014-05-20 22:36:50 -06:00
|
|
|
go test ../nocgo || exit 1
|
|
|
|
go test -ldflags '-linkmode=external' ../nocgo || exit 1
|
|
|
|
go test -ldflags '-linkmode=external -extldflags "-static -pthread"' ../nocgo || exit 1
|
2014-04-29 12:43:10 -06:00
|
|
|
fi
|
2014-04-15 13:52:02 -06:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2013-03-10 22:51:42 -06:00
|
|
|
esac
|
2011-03-11 13:09:32 -07:00
|
|
|
) || exit $?
|
|
|
|
|
2014-11-19 18:52:58 -07:00
|
|
|
# Race detector only supported on Linux, FreeBSD and OS X,
|
|
|
|
# and only on amd64, and only when cgo is enabled.
|
|
|
|
# Delayed until here so we know whether to try external linking.
|
|
|
|
case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
|
|
|
|
linux-linux-amd64-1 | freebsd-freebsd-amd64-1 | darwin-darwin-amd64-1)
|
|
|
|
echo
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '##### Testing race detector.'
|
2014-11-19 18:52:58 -07:00
|
|
|
go test -race -i runtime/race flag os/exec
|
|
|
|
go test -race -run=Output runtime/race
|
|
|
|
go test -race -short flag os/exec
|
|
|
|
|
|
|
|
# Test with external linking; see issue 9133.
|
|
|
|
if [ "$extlink" = 1 ]; then
|
|
|
|
go test -race -short -ldflags=-linkmode=external flag os/exec
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
|
2014-08-12 08:13:52 -06:00
|
|
|
[ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
|
|
|
|
(xcd ../misc/cgo/testgodefs
|
|
|
|
./test.bash || exit 1
|
|
|
|
) || exit $?
|
|
|
|
|
2011-11-22 07:57:49 -07:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
|
|
|
[ "$GOHOSTOS" == windows ] ||
|
|
|
|
(xcd ../misc/cgo/testso
|
2013-07-11 21:24:57 -06:00
|
|
|
./test.bash || exit 1
|
2011-11-22 07:57:49 -07:00
|
|
|
) || exit $?
|
|
|
|
|
2013-06-12 08:47:16 -06:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
|
|
|
[ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
|
|
|
|
(xcd ../misc/cgo/testasan
|
2013-07-11 21:24:57 -06:00
|
|
|
go run main.go || exit 1
|
2013-06-12 08:47:16 -06:00
|
|
|
) || exit $?
|
|
|
|
|
2013-09-03 22:15:15 -06:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
|
|
|
[ "$GOHOSTOS" == windows ] ||
|
|
|
|
(xcd ../misc/cgo/errors
|
|
|
|
./test.bash || exit 1
|
|
|
|
) || exit $?
|
|
|
|
|
2014-05-20 10:10:19 -06:00
|
|
|
[ "$GOOS" == nacl ] ||
|
2014-07-08 16:41:07 -06:00
|
|
|
[ "$GOOS" == android ] ||
|
2009-01-06 16:49:27 -07:00
|
|
|
(xcd ../doc/progs
|
2013-07-11 21:24:57 -06:00
|
|
|
time ./run || exit 1
|
2009-01-06 16:49:27 -07:00
|
|
|
) || exit $?
|
|
|
|
|
2014-07-08 16:41:07 -06:00
|
|
|
[ "$GOOS" == android ] ||
|
2014-05-20 10:10:19 -06:00
|
|
|
[ "$GOOS" == nacl ] ||
|
2011-03-27 21:39:42 -06:00
|
|
|
[ "$GOARCH" == arm ] || # uses network, fails under QEMU
|
2012-03-07 15:23:56 -07:00
|
|
|
(xcd ../doc/articles/wiki
|
2013-07-11 21:24:57 -06:00
|
|
|
./test.bash || exit 1
|
2011-01-30 21:58:44 -07:00
|
|
|
) || exit $?
|
2011-01-25 21:56:52 -07:00
|
|
|
|
2014-07-08 16:41:07 -06:00
|
|
|
[ "$GOOS" == android ] ||
|
2014-05-20 10:10:19 -06:00
|
|
|
[ "$GOOS" == nacl ] ||
|
2012-03-25 23:08:21 -06:00
|
|
|
(xcd ../doc/codewalk
|
2013-07-29 17:42:53 -06:00
|
|
|
time ./run || exit 1
|
2012-03-25 23:08:21 -06:00
|
|
|
) || exit $?
|
|
|
|
|
2014-05-20 10:10:19 -06:00
|
|
|
[ "$GOOS" == nacl ] ||
|
2010-09-21 23:30:42 -06:00
|
|
|
[ "$GOARCH" == arm ] ||
|
2011-12-13 15:46:54 -07:00
|
|
|
(xcd ../test/bench/shootout
|
2014-02-19 00:19:27 -07:00
|
|
|
time ./timing.sh -test || exit 1
|
2009-08-09 15:31:05 -06:00
|
|
|
) || exit $?
|
|
|
|
|
2014-07-08 16:41:07 -06:00
|
|
|
[ "$GOOS" == android ] || # TODO(crawshaw): get this working
|
2013-03-15 10:39:14 -06:00
|
|
|
[ "$GOOS" == openbsd ] || # golang.org/issue/5057
|
|
|
|
(
|
2012-03-07 15:23:56 -07:00
|
|
|
echo
|
2014-12-10 08:45:59 -07:00
|
|
|
echo '#####' ../test/bench/go1
|
2013-07-11 21:24:57 -06:00
|
|
|
go test ../test/bench/go1 || exit 1
|
2013-03-15 10:39:14 -06:00
|
|
|
) || exit $?
|
2011-12-15 10:32:59 -07:00
|
|
|
|
2014-07-08 16:41:07 -06:00
|
|
|
[ "$GOOS" == android ] ||
|
2008-10-08 10:46:54 -06:00
|
|
|
(xcd ../test
|
2012-11-14 19:59:46 -07:00
|
|
|
unset GOMAXPROCS
|
2014-05-20 10:10:19 -06:00
|
|
|
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build -o runtest run.go || exit 1
|
|
|
|
time ./runtest || exit 1
|
|
|
|
rm -f runtest
|
2008-10-29 16:23:29 -06:00
|
|
|
) || exit $?
|
2008-10-08 10:46:54 -06:00
|
|
|
|
2014-07-08 16:41:07 -06:00
|
|
|
[ "$GOOS" == android ] ||
|
2014-05-20 10:10:19 -06:00
|
|
|
[ "$GOOS" == nacl ] ||
|
|
|
|
(
|
2013-08-07 14:49:37 -06:00
|
|
|
echo
|
2014-12-05 14:24:20 -07:00
|
|
|
time go run $GOROOT/src/cmd/api/run.go || exit 1
|
2014-05-20 10:10:19 -06:00
|
|
|
) || exit $?
|
2012-03-17 12:20:46 -06:00
|
|
|
|
2011-02-14 07:27:02 -07:00
|
|
|
echo
|
|
|
|
echo ALL TESTS PASSED
|