blob: a2abc6797b698a917230ffe6c2852619049d7c3d [file] [log] [blame]
Devon H. O'Dell553be842009-11-14 15:29:09 -08001#!/usr/bin/env bash
Russ Coxbbb00c62008-10-08 09:46:54 -07002# 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
6set -e
7
Shenghou Ma6d4da062012-03-10 03:42:23 +08008eval $(go env)
Russ Cox82905362012-02-04 00:54:08 -05009
Russ Cox69fd2a42010-03-31 19:48:33 -070010unset CDPATH # in case user has it set
Shenghou Ma23322ab2012-03-21 00:47:27 +080011unset GOPATH # we disallow local import for non-local packages, if $GOROOT happens
12 # to be under $GOPATH, then some tests below will fail
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080013
Russ Coxda776792009-11-09 23:11:36 -080014# no core files, please
15ulimit -c 0
16
Shenghou Ma329b27a2012-09-17 01:11:28 +080017# 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)
Shenghou Maa1a414e2012-09-17 01:26:57 +080021[ "$(ulimit -H -d)" == "unlimited" ] || ulimit -S -d $(ulimit -H -d)
Shenghou Ma329b27a2012-09-17 01:11:28 +080022
Russ Cox82905362012-02-04 00:54:08 -050023# allow all.bash to avoid double-build of everything
Russ Cox69fd2a42010-03-31 19:48:33 -070024rebuild=true
25if [ "$1" = "--no-rebuild" ]; then
Russ Cox69fd2a42010-03-31 19:48:33 -070026 shift
Russ Cox82905362012-02-04 00:54:08 -050027else
28 echo '# Building packages and commands.'
29 time go install -a -v std
30 echo
Russ Cox69fd2a42010-03-31 19:48:33 -070031fi
Russ Cox82905362012-02-04 00:54:08 -050032
Shenghou Ma34ace102012-04-04 23:14:54 +080033# we must unset GOROOT_FINAL before tests, because runtime/debug requires
34# correct access to source code, so if we have GOROOT_FINAL in effect,
35# at least runtime/debug test will fail.
36unset GOROOT_FINAL
37
Russ Cox82905362012-02-04 00:54:08 -050038echo '# Testing packages.'
39time go test std -short -timeout=120s
40echo
41
Rémy Oudomphengaa1aaee2012-03-05 16:40:27 -050042echo '# GOMAXPROCS=2 runtime -cpu=1,2,4'
Shenghou Ma2ceb6532012-03-21 16:19:37 +080043GOMAXPROCS=2 go test runtime -short -timeout=240s -cpu=1,2,4
Russ Cox82905362012-02-04 00:54:08 -050044echo
45
46echo '# sync -cpu=10'
47go test sync -short -timeout=120s -cpu=10
48
Russ Cox6d888f12013-02-15 13:37:43 -080049# Race detector only supported on Linux and OS X,
50# and only on amd64, and only when cgo is enabled.
Shenghou Maeec96142013-02-23 20:24:38 +080051case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
52linux-linux-amd64-1 | darwin-darwin-amd64-1)
Dmitriy Vyukov95329d42012-11-01 22:02:52 +040053 echo
54 echo '# Testing race detector.'
55 go test -race -i flag
56 go test -race -short flag
57esac
58
Russ Coxbbb00c62008-10-08 09:46:54 -070059xcd() {
Ken Thompsonb379d542008-10-24 20:14:28 -070060 echo
Russ Coxc3f43192012-03-06 23:27:30 -050061 echo '#' $1
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080062 builtin cd "$GOROOT"/src/$1
Russ Coxbbb00c62008-10-08 09:46:54 -070063}
64
Russ Coxc0242392011-08-10 21:36:48 -040065[ "$CGO_ENABLED" != 1 ] ||
Alex Brainman642c7742011-02-09 12:37:08 +110066[ "$GOHOSTOS" == windows ] ||
Russ Cox2d72b392009-10-03 11:33:51 -070067(xcd ../misc/cgo/stdio
Shenghou Ma1e954292012-08-07 09:38:35 +080068go run $GOROOT/test/run.go - .
Russ Cox2d72b392009-10-03 11:33:51 -070069) || exit $?
70
Russ Coxc0242392011-08-10 21:36:48 -040071[ "$CGO_ENABLED" != 1 ] ||
Russ Cox0cd34752010-12-17 09:51:55 -080072(xcd ../misc/cgo/life
Shenghou Ma1e954292012-08-07 09:38:35 +080073go run $GOROOT/test/run.go - .
Russ Cox0cd34752010-12-17 09:51:55 -080074) || exit $?
75
Russ Coxc0242392011-08-10 21:36:48 -040076[ "$CGO_ENABLED" != 1 ] ||
Russ Coxec713d62011-03-11 15:09:32 -050077(xcd ../misc/cgo/test
Russ Coxc3f43192012-03-06 23:27:30 -050078go test
Russ Coxec713d62011-03-11 15:09:32 -050079) || exit $?
80
Dmitriy Vyukov11e73b82011-11-22 17:57:49 +030081[ "$CGO_ENABLED" != 1 ] ||
82[ "$GOHOSTOS" == windows ] ||
Russ Coxafb1b0e2012-03-07 10:15:20 -050083[ "$GOHOSTOS" == darwin ] ||
Dmitriy Vyukov11e73b82011-11-22 17:57:49 +030084(xcd ../misc/cgo/testso
Russ Coxafb1b0e2012-03-07 10:15:20 -050085./test.bash
Dmitriy Vyukov11e73b82011-11-22 17:57:49 +030086) || exit $?
87
Rob Pike8d210042009-01-06 15:49:27 -080088(xcd ../doc/progs
Alex Brainman642c7742011-02-09 12:37:08 +110089time ./run
Rob Pike8d210042009-01-06 15:49:27 -080090) || exit $?
91
Russ Cox6b335712011-03-27 23:39:42 -040092[ "$GOARCH" == arm ] || # uses network, fails under QEMU
Shenghou Ma90010f82012-03-08 06:23:56 +080093(xcd ../doc/articles/wiki
94make clean
Shenghou Mad56e0e72012-03-08 12:04:49 +090095./test.bash
Alex Brainman3bfd35b2011-01-31 15:58:44 +110096) || exit $?
Andrew Gerrandadd4e162011-01-26 14:56:52 +100097
Rob Pike6492cac2012-03-26 16:08:21 +110098(xcd ../doc/codewalk
99# TODO: test these too.
Rob Pike072646c2012-03-26 17:03:04 +1100100set -e
Rob Pike6492cac2012-03-26 16:08:21 +1100101go build pig.go
102go build urlpoll.go
103rm -f pig urlpoll
104) || exit $?
105
Shenghou Ma90010f82012-03-08 06:23:56 +0800106echo
107echo '#' ../misc/dashboard/builder ../misc/goplay
Brad Fitzpatrickf69132d2012-03-17 11:20:46 -0700108go build ../misc/dashboard/builder ../misc/goplay
Andrew Gerrand06492d42010-10-21 10:46:10 +1100109
Russ Coxb7cb8442010-09-22 15:30:42 +1000110[ "$GOARCH" == arm ] ||
Russ Coxbcbb2f92011-12-13 17:46:54 -0500111(xcd ../test/bench/shootout
Alex Brainman642c7742011-02-09 12:37:08 +1100112./timing.sh -test
Rob Pike266a2c42009-08-09 14:31:05 -0700113) || exit $?
114
Shenghou Ma90010f82012-03-08 06:23:56 +0800115echo
116echo '#' ../test/bench/go1
Brad Fitzpatrickf69132d2012-03-17 11:20:46 -0700117go test ../test/bench/go1
Russ Cox6e887552011-12-15 12:32:59 -0500118
Russ Coxbbb00c62008-10-08 09:46:54 -0700119(xcd ../test
Dave Cheneyfa21df32012-11-15 13:59:46 +1100120unset GOMAXPROCS
121time go run run.go
Russ Cox527669e2008-10-29 15:23:29 -0700122) || exit $?
Russ Coxbbb00c62008-10-08 09:46:54 -0700123
Russ Coxb9f94762011-02-14 09:27:02 -0500124echo
Brad Fitzpatrickf69132d2012-03-17 11:20:46 -0700125echo '# Checking API compatibility.'
Rob Piked87d4882012-10-04 11:35:17 +1000126go tool api -c $GOROOT/api/go1.txt -next $GOROOT/api/next.txt -except $GOROOT/api/except.txt
Brad Fitzpatrickf69132d2012-03-17 11:20:46 -0700127
128echo
Russ Coxb9f94762011-02-14 09:27:02 -0500129echo ALL TESTS PASSED