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)
|
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'.
|
|
|
|
[ "$(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
|
|
|
|
if [ "$1" = "--no-rebuild" ]; then
|
|
|
|
shift
|
2012-02-03 22:54:08 -07:00
|
|
|
else
|
|
|
|
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
|
|
|
|
|
2013-03-24 02:31:28 -06:00
|
|
|
# increase timeout for ARM up to 3 times the normal value
|
|
|
|
timeout_scale=1
|
|
|
|
[ "$GOARCH" == "arm" ] && timeout_scale=3
|
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
echo '# Testing packages.'
|
2013-03-24 02:31:28 -06:00
|
|
|
time go test std -short -timeout=$(expr 120 \* $timeout_scale)s
|
2012-01-30 21:43:46 -07:00
|
|
|
echo
|
2012-02-03 22:54:08 -07:00
|
|
|
|
2012-03-05 14:40:27 -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
|
|
|
|
2012-01-30 21:43:46 -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
|
|
|
|
2013-02-15 14:37:43 -07:00
|
|
|
# Race detector only supported on Linux and OS X,
|
|
|
|
# and only on amd64, and only when cgo is enabled.
|
2013-02-23 05:24:38 -07:00
|
|
|
case "$GOHOSTOS-$GOOS-$GOARCH-$CGO_ENABLED" in
|
|
|
|
linux-linux-amd64-1 | darwin-darwin-amd64-1)
|
2012-11-01 12:02:52 -06:00
|
|
|
echo
|
|
|
|
echo '# Testing race detector.'
|
2013-08-12 12:04:10 -06:00
|
|
|
go test -race -i runtime/race flag
|
|
|
|
go test -race -run=Output runtime/race
|
2012-11-01 12:02:52 -06:00
|
|
|
go test -race -short flag
|
|
|
|
esac
|
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
xcd() {
|
|
|
|
echo
|
2012-03-06 21:27:30 -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.
|
|
|
|
|
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
|
2013-07-11 21:24:57 -06:00
|
|
|
go test -ldflags '-linkmode=auto' || exit 1
|
|
|
|
go test -ldflags '-linkmode=internal' || exit 1
|
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
|
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.*) ;;
|
2013-07-11 21:24:57 -06:00
|
|
|
*) go test -ldflags '-linkmode=external' || exit 1;;
|
2013-03-29 17:33:35 -06:00
|
|
|
esac
|
|
|
|
;;
|
runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:
10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS
This CL prepares for external linking support to ARM.
The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.
The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.
10271047
This CL adds support for -linkmode external to 5l.
For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.
In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.
9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.
The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.
Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.
The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.
The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.
The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.
This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.
Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q
Fixes #5590.
R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 09:38:54 -06:00
|
|
|
freebsd-386 | freebsd-amd64 | 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
|
2013-03-10 22:51:42 -06:00
|
|
|
esac
|
2011-03-11 13:09:32 -07:00
|
|
|
) || exit $?
|
|
|
|
|
2013-08-02 12:58:27 -06:00
|
|
|
# This tests cgo -godefs. That mode is not supported,
|
|
|
|
# so it's okay if it doesn't work on some systems.
|
|
|
|
# In particular, it works badly with clang on OS X.
|
|
|
|
[ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
|
cmd/cgo: Fix issue with cgo cdefs
The problem is that the cdecl() function in cmd/cgo/godefs.go isn't
properly translating the Go array type to a C array type when an
asterisk follows the [] in the array type declaration (it is perfectly
legal to put the asterisk on either side of the [] in go syntax,
depending on how you set up your pointers).
That said, the cdefs tool is only designed to translate from Go types
generated using the cgo *godefs* tool -- where the godefs tool is
designed to translate gcc-style C types into Go types. In essence, the
cdefs tool translates from gcc-style C types to Go types (via the godefs
tool), then back to kenc-style C types. Because of this, cdefs does not
need to know how to translate arbitraty Go types into C, just the ones
produced by godefs.
The problem is that during this translation process, the logic is
slightly wrong when going from (e.g.):
char *array[10];
to:
array [10]*int8;
back to:
int8 *array[10];
In the current implementation of cdecl(), the translation from the Go
type declaration back to the kenc-style declaration looks for Go
types of the form:
name *[]type;
rather than the actual generated Go type declaration of:
name []*type;
Both are valid Go syntax, with slightly different semantics, but the
latter is the only one that can ever be generated by the godefs tools.
(The semantics of the former are not directly expressible in a
single C statement -- you would have to have to first typedef the array
type, then declare a pointer to that typedef'd type in a separate
statement).
This commit changes the logic of cdecl() to look properly for, and
translate, Go type declarations of the form:
name []*type;
Additionally, the original implementation only allowed for a single
asterisk and a single sized aray (i.e. only a single level of pointer
indirection, and only one set of []) on the type, whereas the patched
version allows for an arbitrary number of both.
Tests are included in misc/cgo/testcdefs and the all.bash script has been
updated to account for these.
R=golang-dev, bradfitz, dave, iant
CC=golang-dev
https://golang.org/cl/11377043
2013-07-24 18:27:42 -06:00
|
|
|
(xcd ../misc/cgo/testcdefs
|
|
|
|
./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 $?
|
|
|
|
|
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 $?
|
|
|
|
|
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
|
|
|
make clean || exit 1
|
|
|
|
./test.bash || exit 1
|
2011-01-30 21:58:44 -07:00
|
|
|
) || exit $?
|
2011-01-25 21:56:52 -07:00
|
|
|
|
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 $?
|
|
|
|
|
2012-03-07 15:23:56 -07:00
|
|
|
echo
|
2013-07-31 21:49:00 -06:00
|
|
|
echo '#' ../misc/goplay
|
|
|
|
go build ../misc/goplay
|
2013-08-02 20:14:13 -06:00
|
|
|
rm -f goplay
|
2010-10-20 17:46:10 -06:00
|
|
|
|
2010-09-21 23:30:42 -06:00
|
|
|
[ "$GOARCH" == arm ] ||
|
2011-12-13 15:46:54 -07:00
|
|
|
(xcd ../test/bench/shootout
|
2013-07-11 21:24:57 -06:00
|
|
|
./timing.sh -test || exit 1
|
2009-08-09 15:31:05 -06:00
|
|
|
) || exit $?
|
|
|
|
|
2013-03-15 10:39:14 -06:00
|
|
|
[ "$GOOS" == openbsd ] || # golang.org/issue/5057
|
|
|
|
(
|
2012-03-07 15:23:56 -07:00
|
|
|
echo
|
|
|
|
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
|
|
|
|
2008-10-08 10:46:54 -06:00
|
|
|
(xcd ../test
|
2012-11-14 19:59:46 -07:00
|
|
|
unset GOMAXPROCS
|
2013-07-11 21:24:57 -06:00
|
|
|
time go run run.go || exit 1
|
2008-10-29 16:23:29 -06:00
|
|
|
) || exit $?
|
2008-10-08 10:46:54 -06:00
|
|
|
|
2013-08-07 14:49:37 -06:00
|
|
|
echo
|
|
|
|
echo '# Checking API compatibility.'
|
2013-08-09 16:44:00 -06:00
|
|
|
time go run $GOROOT/src/cmd/api/run.go
|
2012-03-17 12:20:46 -06:00
|
|
|
|
2011-02-14 07:27:02 -07:00
|
|
|
echo
|
|
|
|
echo ALL TESTS PASSED
|