2009-11-14 15:29:09 -08:00
|
|
|
#!/usr/bin/env bash
|
2008-10-08 09:46:54 -07: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-10 03:42:23 +08:00
|
|
|
eval $(go env)
|
2012-02-04 00:54:08 -05:00
|
|
|
|
2010-03-31 19:48:33 -07:00
|
|
|
unset CDPATH # in case user has it set
|
2012-03-21 00:47:27 +08: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 15:14:09 -08:00
|
|
|
|
2009-11-09 23:11:36 -08:00
|
|
|
# no core files, please
|
|
|
|
|
ulimit -c 0
|
|
|
|
|
|
2012-09-17 01:11:28 +08: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'.
|
|
|
|
|
[ "$(ulimit -H -n)" == "unlimited" ] || ulimit -S -n $(ulimit -H -n)
|
2012-09-17 01:26:57 +08:00
|
|
|
[ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
|
2012-09-17 01:11:28 +08:00
|
|
|
|
2013-06-17 19:31:58 +10: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-04 00:54:08 -05:00
|
|
|
# allow all.bash to avoid double-build of everything
|
2010-03-31 19:48:33 -07:00
|
|
|
rebuild=true
|
|
|
|
|
if [ "$1" = "--no-rebuild" ]; then
|
|
|
|
|
shift
|
2012-02-04 00:54:08 -05:00
|
|
|
else
|
|
|
|
|
echo '# Building packages and commands.'
|
2012-01-30 23:43:46 -05:00
|
|
|
time go install -a -v std
|
2012-02-04 00:54:08 -05:00
|
|
|
echo
|
2011-02-14 09:27:02 -05:00
|
|
|
fi
|
2008-11-20 10:54:11 -08:00
|
|
|
|
2012-04-04 23:14:54 +08: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
|
|
|
|
|
|
2013-03-24 16:31:28 +08:00
|
|
|
# increase timeout for ARM up to 3 times the normal value
|
|
|
|
|
timeout_scale=1
|
|
|
|
|
[ "$GOARCH" == "arm" ] && timeout_scale=3
|
|
|
|
|
|
2012-02-04 00:54:08 -05:00
|
|
|
echo '# Testing packages.'
|
2013-03-24 16:31:28 +08:00
|
|
|
time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
|
2012-01-30 23:43:46 -05:00
|
|
|
echo
|
2012-02-04 00:54:08 -05:00
|
|
|
|
2012-03-05 16:40:27 -05:00
|
|
|
echo '# GOMAXPROCS=2 runtime -cpu=1,2,4'
|
2013-03-24 16:31:28 +08:00
|
|
|
GOMAXPROCS=2 go test runtime -short -timeout=$(expr 240 \* $timeout_scale)s -cpu=1,2,4
|
2012-01-30 23:43:46 -05:00
|
|
|
echo
|
2012-02-04 00:54:08 -05:00
|
|
|
|
2012-01-30 23:43:46 -05:00
|
|
|
echo '# sync -cpu=10'
|
2013-03-24 16:31:28 +08:00
|
|
|
go test sync -short -timeout=$(expr 120 \* $timeout_scale)s -cpu=10
|
2008-12-04 12:51:36 -08:00
|
|
|
|
2013-02-15 13:37:43 -08:00
|
|
|
# Race detector only supported on Linux and OS X,
|
|
|
|
|
# and only on amd64, and only when cgo is enabled.
|
2013-02-23 20:24:38 +08:00
|
|
|
case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
|
|
|
|
|
linux-linux-amd64-1 | darwin-darwin-amd64-1)
|
2012-11-01 22:02:52 +04:00
|
|
|
echo
|
|
|
|
|
echo '# Testing race detector.'
|
|
|
|
|
go test -race -i flag
|
|
|
|
|
go test -race -short flag
|
|
|
|
|
esac
|
|
|
|
|
|
2012-02-04 00:54:08 -05:00
|
|
|
xcd() {
|
|
|
|
|
echo
|
2012-03-06 23:27:30 -05:00
|
|
|
echo '#' $1
|
2013-07-11 23:24:57 -04:00
|
|
|
builtin cd "$GOROOT"/src/$1 || exit 1
|
2012-02-04 00:54:08 -05:00
|
|
|
}
|
2012-01-30 23:43:46 -05:00
|
|
|
|
2013-07-11 23:24:57 -04: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.
|
|
|
|
|
|
2011-08-10 21:36:48 -04:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
2011-02-09 12:37:08 +11:00
|
|
|
[ "$GOHOSTOS" == windows ] ||
|
2009-10-03 11:33:51 -07:00
|
|
|
(xcd ../misc/cgo/stdio
|
2013-07-11 23:24:57 -04:00
|
|
|
go run $GOROOT/test/run.go - . || exit 1
|
2009-10-03 11:33:51 -07:00
|
|
|
) || exit $?
|
|
|
|
|
|
2011-08-10 21:36:48 -04:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
2010-12-17 09:51:55 -08:00
|
|
|
(xcd ../misc/cgo/life
|
2013-07-11 23:24:57 -04:00
|
|
|
go run $GOROOT/test/run.go - . || exit 1
|
2010-12-17 09:51:55 -08:00
|
|
|
) || exit $?
|
|
|
|
|
|
2011-08-10 21:36:48 -04:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
2011-03-11 15:09:32 -05:00
|
|
|
(xcd ../misc/cgo/test
|
2013-07-11 23:24:57 -04:00
|
|
|
go test -ldflags '-linkmode=auto' || exit 1
|
|
|
|
|
go test -ldflags '-linkmode=internal' || exit 1
|
2013-03-11 00:51:42 -04:00
|
|
|
case "$GOHOSTOS-$GOARCH" in
|
2013-03-29 16:33:35 -07:00
|
|
|
openbsd-386 | openbsd-amd64)
|
2013-03-27 13:27:35 -07:00
|
|
|
# test linkmode=external, but __thread not supported, so skip testtls.
|
2013-07-11 23:24:57 -04:00
|
|
|
go test -ldflags '-linkmode=external' || exit 1
|
2013-03-27 13:27:35 -07:00
|
|
|
;;
|
2013-03-29 16:33:35 -07: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.*) ;;
|
2013-07-11 23:24:57 -04:00
|
|
|
*) go test -ldflags '-linkmode=external' || exit 1;;
|
2013-03-29 16:33:35 -07:00
|
|
|
esac
|
|
|
|
|
;;
|
2013-03-27 13:27:35 -07:00
|
|
|
freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | netbsd-386 | netbsd-amd64)
|
2013-07-11 23:24:57 -04:00
|
|
|
go test -ldflags '-linkmode=external' || exit 1
|
|
|
|
|
go test -ldflags '-linkmode=auto' ../testtls || exit 1
|
|
|
|
|
go test -ldflags '-linkmode=external' ../testtls || exit 1
|
2013-03-11 00:51:42 -04:00
|
|
|
esac
|
2011-03-11 15:09:32 -05:00
|
|
|
) || exit $?
|
|
|
|
|
|
2011-11-22 17:57:49 +03:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
|
|
|
|
[ "$GOHOSTOS" == windows ] ||
|
|
|
|
|
(xcd ../misc/cgo/testso
|
2013-07-11 23:24:57 -04:00
|
|
|
./test.bash || exit 1
|
2011-11-22 17:57:49 +03:00
|
|
|
) || exit $?
|
|
|
|
|
|
2013-06-12 18:47:16 +04:00
|
|
|
[ "$CGO_ENABLED" != 1 ] ||
|
|
|
|
|
[ "$GOHOSTOS-$GOARCH" != linux-amd64 ] ||
|
|
|
|
|
(xcd ../misc/cgo/testasan
|
2013-07-11 23:24:57 -04:00
|
|
|
go run main.go || exit 1
|
2013-06-12 18:47:16 +04:00
|
|
|
) || exit $?
|
|
|
|
|
|
2009-01-06 15:49:27 -08:00
|
|
|
(xcd ../doc/progs
|
2013-07-11 23:24:57 -04:00
|
|
|
time ./run || exit 1
|
2009-01-06 15:49:27 -08:00
|
|
|
) || exit $?
|
|
|
|
|
|
2011-03-27 23:39:42 -04:00
|
|
|
[ "$GOARCH" == arm ] || # uses network, fails under QEMU
|
2012-03-08 06:23:56 +08:00
|
|
|
(xcd ../doc/articles/wiki
|
2013-07-11 23:24:57 -04:00
|
|
|
make clean || exit 1
|
|
|
|
|
./test.bash || exit 1
|
2011-01-31 15:58:44 +11:00
|
|
|
) || exit $?
|
2011-01-26 14:56:52 +10:00
|
|
|
|
2012-03-26 16:08:21 +11:00
|
|
|
(xcd ../doc/codewalk
|
|
|
|
|
# TODO: test these too.
|
2013-07-11 23:24:57 -04:00
|
|
|
go build pig.go || exit 1
|
|
|
|
|
go build urlpoll.go || exit 1
|
2012-03-26 16:08:21 +11:00
|
|
|
rm -f pig urlpoll
|
|
|
|
|
) || exit $?
|
|
|
|
|
|
2012-03-08 06:23:56 +08:00
|
|
|
echo
|
|
|
|
|
echo '#' ../misc/dashboard/builder ../misc/goplay
|
2012-03-17 11:20:46 -07:00
|
|
|
go build ../misc/dashboard/builder ../misc/goplay
|
2010-10-21 10:46:10 +11:00
|
|
|
|
2010-09-22 15:30:42 +10:00
|
|
|
[ "$GOARCH" == arm ] ||
|
2011-12-13 17:46:54 -05:00
|
|
|
(xcd ../test/bench/shootout
|
2013-07-11 23:24:57 -04:00
|
|
|
./timing.sh -test || exit 1
|
2009-08-09 14:31:05 -07:00
|
|
|
) || exit $?
|
|
|
|
|
|
2013-03-15 12:39:14 -04:00
|
|
|
[ "$GOOS" == openbsd ] || # golang.org/issue/5057
|
|
|
|
|
(
|
2012-03-08 06:23:56 +08:00
|
|
|
echo
|
|
|
|
|
echo '#' ../test/bench/go1
|
2013-07-11 23:24:57 -04:00
|
|
|
go test ../test/bench/go1 || exit 1
|
2013-03-15 12:39:14 -04:00
|
|
|
) || exit $?
|
2011-12-15 12:32:59 -05:00
|
|
|
|
2008-10-08 09:46:54 -07:00
|
|
|
(xcd ../test
|
2012-11-15 13:59:46 +11:00
|
|
|
unset GOMAXPROCS
|
2013-07-11 23:24:57 -04:00
|
|
|
time go run run.go || exit 1
|
2008-10-29 15:23:29 -07:00
|
|
|
) || exit $?
|
2008-10-08 09:46:54 -07:00
|
|
|
|
2012-03-17 11:20:46 -07:00
|
|
|
echo
|
|
|
|
|
echo '# Checking API compatibility.'
|
2013-05-06 17:25:09 -07:00
|
|
|
go tool api -c $GOROOT/api/go1.txt,$GOROOT/api/go1.1.txt -next $GOROOT/api/next.txt -except $GOROOT/api/except.txt
|
2012-03-17 11:20:46 -07:00
|
|
|
|
2011-02-14 09:27:02 -05:00
|
|
|
echo
|
|
|
|
|
echo ALL TESTS PASSED
|