Home | History | Annotate | Download | only in src
      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 export GOROOT   # the api test requires GOROOT to be set.
     10 
     11 # We disallow local import for non-local packages, if $GOROOT happens
     12 # to be under $GOPATH, then some tests below will fail.  $GOPATH needs
     13 # to be set to a non-empty string, else Go will set a default value
     14 # that may also conflict with $GOROOT.  The $GOPATH value doesn't need
     15 # to point to an actual directory, it just needs to pass the semantic
     16 # checks performed by Go.  Use $GOROOT to define $GOPATH so that we
     17 # don't blunder into a user-defined symbolic link.
     18 GOPATH=$GOROOT/nonexistentpath
     19 export GOPATH
     20 
     21 unset CDPATH	# in case user has it set
     22 unset GOBIN     # Issue 14340
     23 
     24 export GOHOSTOS
     25 export CC
     26 
     27 # no core files, please
     28 ulimit -c 0
     29 
     30 # Raise soft limits to hard limits for NetBSD/OpenBSD.
     31 # We need at least 256 files and ~300 MB of bss.
     32 # On OS X ulimit -S -n rejects 'unlimited'.
     33 #
     34 # Note that ulimit -S -n may fail if ulimit -H -n is set higher than a
     35 # non-root process is allowed to set the high limit.
     36 # This is a system misconfiguration and should be fixed on the
     37 # broken system, not "fixed" by ignoring the failure here.
     38 # See longer discussion on golang.org/issue/7381. 
     39 [ "$(ulimit -H -n)" = "unlimited" ] || ulimit -S -n $(ulimit -H -n)
     40 [ "$(ulimit -H -d)" = "unlimited" ] || ulimit -S -d $(ulimit -H -d)
     41 
     42 # Thread count limit on NetBSD 7.
     43 if ulimit -T &> /dev/null; then
     44 	[ "$(ulimit -H -T)" = "unlimited" ] || ulimit -S -T $(ulimit -H -T)
     45 fi
     46 
     47 exec go tool dist test -rebuild "$@"
     48