aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahul Chaudhry <rahulchaudhry@chromium.org>2018-07-03 15:23:29 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-07-03 22:31:07 -0700
commita631811129ca12826e137f744f12d08a46f857a6 (patch)
tree385dc6720f82cd8f64f4263c202fd31373e1b2ea
parentfceaba3af1a2dbb9e965320be39432b1b412e284 (diff)
downloadtoolchain-utils-a631811129ca12826e137f744f12d08a46f857a6.tar.gz
toolchain-utils: update scripts for building and testing the Go toolchain.
BUG=None TEST=None Change-Id: If19fcb65915334c40970cbf456128dbc6ac7bcec Reviewed-on: https://chromium-review.googlesource.com/1125344 Commit-Ready: Rahul Chaudhry <rahulchaudhry@chromium.org> Tested-by: Rahul Chaudhry <rahulchaudhry@chromium.org> Reviewed-by: Ting-Yuan Huang <laszio@chromium.org>
-rwxr-xr-xgo/android/adb_marlin (renamed from go/android/adb_shamu)2
l---------go/android/adb_marlin321
-rwxr-xr-xgo/android/adb_volantis8
-rwxr-xr-xgo/android/build_go8
-rwxr-xr-xgo/android/go_marlin (renamed from go/android/go_volantis)6
-rwxr-xr-xgo/android/go_marlin32 (renamed from go/android/go_shamu)6
-rwxr-xr-xgo/android/go_marlin32_exec8
-rwxr-xr-xgo/android/go_marlin_exec8
-rwxr-xr-xgo/android/go_shamu_exec8
-rwxr-xr-xgo/android/go_volantis_exec8
-rwxr-xr-xgo/android/target_cp4
-rwxr-xr-xgo/chromeos/build_go38
-rwxr-xr-xgo/chromeos/go_chell (renamed from go/chromeos/go_panther)6
-rwxr-xr-xgo/chromeos/go_chell_exec (renamed from go/chromeos/go_panther_exec)6
-rwxr-xr-xgo/chromeos/go_elm11
-rwxr-xr-xgo/chromeos/go_elm32 (renamed from go/chromeos/go_daisy)6
-rwxr-xr-xgo/chromeos/go_elm32_exec (renamed from go/chromeos/go_x86-zgb_exec)6
-rwxr-xr-xgo/chromeos/go_elm_exec (renamed from go/chromeos/go_daisy_exec)6
-rwxr-xr-xgo/chromeos/go_x86-zgb11
-rwxr-xr-xgo/chromeos/push_glibc56
-rwxr-xr-xgo/chromeos/target_cp2
-rwxr-xr-xgo/go_local4
-rwxr-xr-xgo/go_target32
-rwxr-xr-xgo/go_target_exec6
-rw-r--r--go/patch/go0.patch40
-rw-r--r--go/patch/go1.patch49
-rw-r--r--go/patch/go2.patch256
-rw-r--r--go/patch/go3.patch381
-rw-r--r--go/patch/go4.patch158
-rw-r--r--go/patch/go5.patch346
-rw-r--r--go/patch/go6.patch261
-rw-r--r--go/patch/go7.patch139
-rwxr-xr-xgo/push_goroot17
-rwxr-xr-xgo/test_go9
34 files changed, 1255 insertions, 658 deletions
diff --git a/go/android/adb_shamu b/go/android/adb_marlin
index 1c53ecc1..476e6603 100755
--- a/go/android/adb_shamu
+++ b/go/android/adb_marlin
@@ -1,6 +1,6 @@
#!/bin/bash
-# This wrapper runs adb with the serial number of the shamu device.
+# This wrapper runs adb with the serial number of the marlin device.
# Replace XXXXXXXX with the actual serial number of the device.
# This is just an example. Create one such wrapper for each Android
# device used for running Go tests.
diff --git a/go/android/adb_marlin32 b/go/android/adb_marlin32
new file mode 120000
index 00000000..9cdd321b
--- /dev/null
+++ b/go/android/adb_marlin32
@@ -0,0 +1 @@
+adb_marlin \ No newline at end of file
diff --git a/go/android/adb_volantis b/go/android/adb_volantis
deleted file mode 100755
index 4712eec2..00000000
--- a/go/android/adb_volantis
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# This wrapper runs adb with the serial number of the volantis device.
-# Replace YYYYYYYY with the actual serial number of the device.
-# This is just an example. Create one such wrapper for each Android
-# device used for running Go tests.
-
-exec adb -s YYYYYYYY "$@"
diff --git a/go/android/build_go b/go/android/build_go
index 65b7ec2b..ecb3bee0 100755
--- a/go/android/build_go
+++ b/go/android/build_go
@@ -15,12 +15,12 @@ fi
# Build the Go toolchain for arm devices.
GOOS="android" GOARCH="arm" CGO_ENABLED="1" \
- CC_FOR_TARGET="arm-linux-androideabi-gcc" \
- CXX_FOR_TARGET="arm-linux-androideabi-g++" \
+ CC_FOR_TARGET="arm-linux-androideabi-clang" \
+ CXX_FOR_TARGET="arm-linux-androideabi-clang++" \
./make.bash --no-clean
# Build the Go toolchain for arm64 devices.
GOOS="android" GOARCH="arm64" CGO_ENABLED="1" \
- CC_FOR_TARGET="aarch64-linux-android-gcc" \
- CXX_FOR_TARGET="aarch64-linux-android-g++" \
+ CC_FOR_TARGET="aarch64-linux-android-clang" \
+ CXX_FOR_TARGET="aarch64-linux-android-clang++" \
./make.bash --no-clean
diff --git a/go/android/go_volantis b/go/android/go_marlin
index bfeab196..bfb564f9 100755
--- a/go/android/go_volantis
+++ b/go/android/go_marlin
@@ -1,11 +1,11 @@
#!/bin/bash
-# Invoke the Go cross compiler for volantis.
+# Invoke the Go cross compiler for marlin.
# Uses ../go_target to add PIE flags.
#
# This is just an example for an arm64 device.
GOOS="android" GOARCH="arm64" CGO_ENABLED="1" \
- CC="aarch64-linux-android-gcc" \
- CXX="aarch64-linux-android-g++" \
+ CC="aarch64-linux-android-clang" \
+ CXX="aarch64-linux-android-clang++" \
exec go_target "$@"
diff --git a/go/android/go_shamu b/go/android/go_marlin32
index 7e1ffbea..d02dadc9 100755
--- a/go/android/go_shamu
+++ b/go/android/go_marlin32
@@ -1,11 +1,11 @@
#!/bin/bash
-# Invoke the Go cross compiler for shamu.
+# Invoke the Go cross compiler for marlin32.
# Uses ../go_target to add PIE flags.
#
# This is just an example for an arm device.
GOOS="android" GOARCH="arm" CGO_ENABLED="1" \
- CC="arm-linux-androideabi-gcc" \
- CXX="arm-linux-androideabi-g++" \
+ CC="arm-linux-androideabi-clang" \
+ CXX="arm-linux-androideabi-clang++" \
exec go_target "$@"
diff --git a/go/android/go_marlin32_exec b/go/android/go_marlin32_exec
new file mode 100755
index 00000000..ed3fdf42
--- /dev/null
+++ b/go/android/go_marlin32_exec
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Copy and remotely execute a binary on the marlin32 device.
+#
+# For this to work, the corresponding adb_marlin32 wrapper
+# must exist to tell adb the serial number of the device.
+
+GOOS="android" GOARCH="arm" exec go_target_exec marlin32 "$@"
diff --git a/go/android/go_marlin_exec b/go/android/go_marlin_exec
new file mode 100755
index 00000000..9f4c06d4
--- /dev/null
+++ b/go/android/go_marlin_exec
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Copy and remotely execute a binary on the marlin device.
+#
+# For this to work, the corresponding adb_marlin wrapper
+# must exist to tell adb the serial number of the device.
+
+GOOS="android" GOARCH="arm64" exec go_target_exec marlin "$@"
diff --git a/go/android/go_shamu_exec b/go/android/go_shamu_exec
deleted file mode 100755
index 2c169026..00000000
--- a/go/android/go_shamu_exec
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# Copy and remotely execute a binary on the shamu device.
-#
-# For this to work, the corresponding adb_shamu wrapper
-# must exist to tell adb the serial number of the device.
-
-GOOS="android" GOARCH="arm" exec go_target_exec shamu "$@"
diff --git a/go/android/go_volantis_exec b/go/android/go_volantis_exec
deleted file mode 100755
index 86cb2cfb..00000000
--- a/go/android/go_volantis_exec
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# Copy and remotely execute a binary on the volantis device.
-#
-# For this to work, the corresponding adb_volantis wrapper
-# must exist to tell adb the serial number of the device.
-
-GOOS="android" GOARCH="arm64" exec go_target_exec volantis "$@"
diff --git a/go/android/target_cp b/go/android/target_cp
index 8a311534..f6cd5cbe 100755
--- a/go/android/target_cp
+++ b/go/android/target_cp
@@ -22,7 +22,7 @@ fi
if [[ -d ${src} ]]
then
- adb_${target} push ${src} ${dest}/${src##*/} 2>/dev/null
+ adb_${target} push ${src} ${dest}/${src##*/} >/dev/null
else
- adb_${target} push ${src} ${dest} 2>/dev/null
+ adb_${target} push ${src} ${dest} >/dev/null
fi
diff --git a/go/chromeos/build_go b/go/chromeos/build_go
index cb882eaf..164ea3f7 100755
--- a/go/chromeos/build_go
+++ b/go/chromeos/build_go
@@ -6,8 +6,8 @@ set -e -o pipefail
# Usage: build_go
#
# It assumes that the "x86_64-cros-linux-gnu" toolchain is already installed.
-# It assumes that the "i686-pc-linux-gnu" toolchain is already installed.
# It assumes that the "armv7a-cros-linux-gnueabi" toolchain is already installed.
+# It assumes that the "aarch64-cros-linux-gnu" toolchain is already installed.
if [[ ! -e "make.bash" && -e "src/make.bash" ]]
then
@@ -16,30 +16,30 @@ fi
# Build the Go toolchain for amd64 targets.
GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" \
- CC_FOR_TARGET="x86_64-cros-linux-gnu-gcc" \
- CXX_FOR_TARGET="x86_64-cros-linux-gnu-g++" \
+ CC_FOR_TARGET="x86_64-cros-linux-gnu-clang" \
+ CXX_FOR_TARGET="x86_64-cros-linux-gnu-clang++" \
./make.bash --no-clean
GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" \
- CC="x86_64-cros-linux-gnu-gcc" \
- CXX="x86_64-cros-linux-gnu-g++" \
- ../bin/go install -v -buildmode=pie std
-
-# Build the Go toolchain for 386 targets.
-GOOS="linux" GOARCH="386" CGO_ENABLED="1" \
- CC_FOR_TARGET="i686-pc-linux-gnu-gcc" \
- CXX_FOR_TARGET="i686-pc-linux-gnu-g++" \
- ./make.bash --no-clean
-GOOS="linux" GOARCH="386" CGO_ENABLED="1" \
- CC="i686-pc-linux-gnu-gcc" \
- CXX="i686-pc-linux-gnu-g++" \
+ CC="x86_64-cros-linux-gnu-clang" \
+ CXX="x86_64-cros-linux-gnu-clang++" \
../bin/go install -v -buildmode=pie std
# Build the Go toolchain for arm targets.
GOOS="linux" GOARCH="arm" CGO_ENABLED="1" \
- CC_FOR_TARGET="armv7a-cros-linux-gnueabi-gcc" \
- CXX_FOR_TARGET="armv7a-cros-linux-gnueabi-g++" \
+ CC_FOR_TARGET="armv7a-cros-linux-gnueabi-clang" \
+ CXX_FOR_TARGET="armv7a-cros-linux-gnueabi-clang++" \
./make.bash --no-clean
GOOS="linux" GOARCH="arm" CGO_ENABLED="1" \
- CC="armv7a-cros-linux-gnueabi-gcc" \
- CXX="armv7a-cros-linux-gnueabi-g++" \
+ CC="armv7a-cros-linux-gnueabi-clang" \
+ CXX="armv7a-cros-linux-gnueabi-clang++" \
+ ../bin/go install -v -buildmode=pie std
+
+# Build the Go toolchain for arm64 targets.
+GOOS="linux" GOARCH="arm64" CGO_ENABLED="1" \
+ CC_FOR_TARGET="aarch64-cros-linux-gnu-clang" \
+ CXX_FOR_TARGET="aarch64-cros-linux-gnu-clang++" \
+ ./make.bash --no-clean
+GOOS="linux" GOARCH="arm64" CGO_ENABLED="1" \
+ CC="aarch64-cros-linux-gnu-clang" \
+ CXX="aarch64-cros-linux-gnu-clang++" \
../bin/go install -v -buildmode=pie std
diff --git a/go/chromeos/go_panther b/go/chromeos/go_chell
index 5c06f432..ca6a7dba 100755
--- a/go/chromeos/go_panther
+++ b/go/chromeos/go_chell
@@ -1,11 +1,11 @@
#!/bin/bash
-# Invoke the Go cross compiler for panther.
+# Invoke the Go cross compiler for chell.
# Uses ../go_target to add PIE flags.
#
# This is just an example for an amd64 board.
GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" \
- CC="x86_64-cros-linux-gnu-gcc" \
- CXX="x86_64-cros-linux-gnu-g++" \
+ CC="x86_64-cros-linux-gnu-clang" \
+ CXX="x86_64-cros-linux-gnu-clang++" \
exec go_target "$@"
diff --git a/go/chromeos/go_panther_exec b/go/chromeos/go_chell_exec
index 64f77b1f..8fac94bd 100755
--- a/go/chromeos/go_panther_exec
+++ b/go/chromeos/go_chell_exec
@@ -1,10 +1,12 @@
#!/bin/bash
-# Copy and remotely execute a binary on the panther device.
+# Copy and remotely execute a binary on the chell device.
#
# For this to work, the corresponding entry must exist in
# ~/.ssh/config and the device must already be setup for
# password-less authentication. See setup instructions at
# http://go/chromeos-toolchain-team/go-toolchain
-GOOS="linux" GOARCH="amd64" exec go_target_exec panther "$@"
+GOOS="linux" GOARCH="amd64" \
+ GOLOADER="/tmp/glibc/ld.so" \
+ exec go_target_exec chell "$@"
diff --git a/go/chromeos/go_elm b/go/chromeos/go_elm
new file mode 100755
index 00000000..a92d9c64
--- /dev/null
+++ b/go/chromeos/go_elm
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Invoke the Go cross compiler for elm.
+# Uses ../go_target to add PIE flags.
+#
+# This is just an example for an arm64 board.
+
+GOOS="linux" GOARCH="arm64" CGO_ENABLED="1" \
+ CC="aarch64-cros-linux-gnu-clang" \
+ CXX="aarch64-cros-linux-gnu-clang++" \
+ exec go_target "$@"
diff --git a/go/chromeos/go_daisy b/go/chromeos/go_elm32
index db4a95ac..2bcb3f3b 100755
--- a/go/chromeos/go_daisy
+++ b/go/chromeos/go_elm32
@@ -1,11 +1,11 @@
#!/bin/bash
-# Invoke the Go cross compiler for daisy.
+# Invoke the Go cross compiler for elm32.
# Uses ../go_target to add PIE flags.
#
# This is just an example for an arm board.
GOOS="linux" GOARCH="arm" CGO_ENABLED="1" \
- CC="armv7a-cros-linux-gnueabi-gcc" \
- CXX="armv7a-cros-linux-gnueabi-g++" \
+ CC="armv7a-cros-linux-gnueabi-clang" \
+ CXX="armv7a-cros-linux-gnueabi-clang++" \
exec go_target "$@"
diff --git a/go/chromeos/go_x86-zgb_exec b/go/chromeos/go_elm32_exec
index b0341f21..3e115a9a 100755
--- a/go/chromeos/go_x86-zgb_exec
+++ b/go/chromeos/go_elm32_exec
@@ -1,10 +1,12 @@
#!/bin/bash
-# Copy and remotely execute a binary on the x86-zgb device.
+# Copy and remotely execute a binary on the elm32 device.
#
# For this to work, the corresponding entry must exist in
# ~/.ssh/config and the device must already be setup for
# password-less authentication. See setup instructions at
# http://go/chromeos-toolchain-team/go-toolchain
-GOOS="linux" GOARCH="386" exec go_target_exec x86-zgb "$@"
+GOOS="linux" GOARCH="arm" \
+ GOLOADER="/tmp/glibc32/ld.so" \
+ exec go_target_exec elm32 "$@"
diff --git a/go/chromeos/go_daisy_exec b/go/chromeos/go_elm_exec
index 3b9a63dd..da244c2e 100755
--- a/go/chromeos/go_daisy_exec
+++ b/go/chromeos/go_elm_exec
@@ -1,10 +1,12 @@
#!/bin/bash
-# Copy and remotely execute a binary on the daisy device.
+# Copy and remotely execute a binary on the elm device.
#
# For this to work, the corresponding entry must exist in
# ~/.ssh/config and the device must already be setup for
# password-less authentication. See setup instructions at
# http://go/chromeos-toolchain-team/go-toolchain
-GOOS="linux" GOARCH="arm" exec go_target_exec daisy "$@"
+GOOS="linux" GOARCH="arm64" \
+ GOLOADER="/tmp/glibc/ld.so" \
+ exec go_target_exec elm "$@"
diff --git a/go/chromeos/go_x86-zgb b/go/chromeos/go_x86-zgb
deleted file mode 100755
index 272efb58..00000000
--- a/go/chromeos/go_x86-zgb
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-
-# Invoke the Go cross compiler for x86-zgb.
-# Uses ../go_target to add PIE flags.
-#
-# This is just an example for an 386 board.
-
-GOOS="linux" GOARCH="386" CGO_ENABLED="1" \
- CC="i686-pc-linux-gnu-gcc" \
- CXX="i686-pc-linux-gnu-g++" \
- exec go_target "$@"
diff --git a/go/chromeos/push_glibc b/go/chromeos/push_glibc
new file mode 100755
index 00000000..7528284c
--- /dev/null
+++ b/go/chromeos/push_glibc
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -e -o pipefail
+
+# This script copies a locally built GLIBC to a remote device.
+#
+# Usage: push_glibc <target>...
+#
+# This script works with 64-bit (amd64 or arm64) ChromeOS targets.
+# It copies both 32-bit and 64-bit glibc loaders onto the device.
+# This allows loading and running both 32-bit and 64-bit binaries
+# on the same device.
+
+for target in "$@"
+do
+ echo -n "pushing glibc to ${target} ... "
+ case "$(ssh ${target} uname -m)" in
+ x86_64)
+ glibc="/usr/x86_64-cros-linux-gnu/lib64"
+ loader="ld-linux-x86-64.so.2"
+ glibc32="/usr/i686-pc-linux-gnu/lib"
+ loader32="ld-linux.so.2"
+ ;;
+ aarch64)
+ glibc="/usr/aarch64-cros-linux-gnu/lib64"
+ loader="ld-linux-aarch64.so.1"
+ glibc32="/usr/armv7a-cros-linux-gnueabi/lib"
+ loader32="ld-linux-armhf.so.3"
+ ;;
+ *)
+ echo "unknown arch"
+ continue
+ ;;
+ esac
+
+ target_sh ${target} "rm -rf /tmp/glibc"
+ target_sh ${target} "mkdir -p /tmp/glibc"
+ target_cp "${glibc}" ${target}:/tmp/glibc
+
+ target_sh ${target} "rm -rf /tmp/glibc32"
+ target_sh ${target} "mkdir -p /tmp/glibc32"
+ target_cp "${glibc32}" ${target}:/tmp/glibc32
+
+ echo "#!/bin/bash" > /tmp/ld.so
+ echo "LD_LIBRARY_PATH=/tmp/glibc/${glibc##*/} exec /tmp/glibc/${glibc##*/}/${loader} \"\$@\"" >> /tmp/ld.so
+ chmod +x /tmp/ld.so
+ target_cp /tmp/ld.so ${target}:/tmp/glibc
+ rm /tmp/ld.so
+
+ echo "#!/bin/bash" > /tmp/ld.so
+ echo "LD_LIBRARY_PATH=/tmp/glibc32/${glibc32##*/} exec /tmp/glibc32/${glibc32##*/}/${loader32} \"\$@\"" >> /tmp/ld.so
+ chmod +x /tmp/ld.so
+ target_cp /tmp/ld.so ${target}:/tmp/glibc32
+ rm /tmp/ld.so
+
+ echo "done"
+done
diff --git a/go/chromeos/target_cp b/go/chromeos/target_cp
index 6df476e6..8e0c4055 100755
--- a/go/chromeos/target_cp
+++ b/go/chromeos/target_cp
@@ -22,7 +22,7 @@ fi
if [[ -d ${src} ]]
then
- scp -rq ${src} ${target}:${dest}
+ tar -C $(dirname ${src}) -zcf - $(basename ${src}) | ssh ${target} "tar -C ${dest} -zxf -"
else
scp -q ${src} ${target}:${dest}
fi
diff --git a/go/go_local b/go/go_local
index 92954ef8..cb2a4dc1 100755
--- a/go/go_local
+++ b/go/go_local
@@ -3,6 +3,6 @@
# Invoke the Go compiler for localhost.
GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" \
- CC="gcc" \
- CXX="g++" \
+ CC="clang" \
+ CXX="clang++" \
exec go "$@"
diff --git a/go/go_target b/go/go_target
index 05786377..8943d813 100755
--- a/go/go_target
+++ b/go/go_target
@@ -4,7 +4,7 @@ set -e -o pipefail
# This script wraps the go cross compilers.
#
# It ensures that Go binaries are linked with an external linker
-# by default (cross gcc). Appropriate flags are added to build a
+# by default (cross clang). Appropriate flags are added to build a
# position independent executable (PIE) for ASLR.
# "export GOPIE=0" to temporarily disable this behavior.
@@ -36,44 +36,28 @@ then
case "$1" in
build | install | run | test)
# Add "-buildmode=pie" to "go build|install|run|test" commands.
- pie_flags=(
- "$1"
- "-buildmode=pie"
- )
+ pie_flags=( "$1" )
shift
+ [[ "${GOOS}" == "android" ]] || pie_flags+=( "-buildmode=pie" )
;;
tool)
case "$2" in
asm)
# Handle direct assembler invocations ("go tool asm <args>").
- pie_flags=(
- "$1"
- "$2"
- "-shared"
- )
+ pie_flags=( "$1" "$2" "-shared" )
shift 2
;;
compile)
# Handle direct compiler invocations ("go tool compile <args>").
- pie_flags=(
- "$1"
- "$2"
- "-shared"
- "-installsuffix=shared"
- )
+ pie_flags=( "$1" "$2" "-shared" )
shift 2
+ [[ "${GOOS}" == "android" ]] || pie_flags+=( "-installsuffix=shared" )
;;
link)
# Handle direct linker invocations ("go tool link <args>").
- pie_flags=(
- "$1"
- "$2"
- "-installsuffix=shared"
- "-buildmode=pie"
- "-extld"
- "${CC}"
- )
+ pie_flags=( "$1" "$2" "-extld" "${CC}" "-buildmode=pie" )
shift 2
+ [[ "${GOOS}" == "android" ]] || pie_flags+=( "-installsuffix=shared" )
;;
esac
;;
diff --git a/go/go_target_exec b/go/go_target_exec
index 34d9e799..0a44b4cf 100755
--- a/go/go_target_exec
+++ b/go/go_target_exec
@@ -27,15 +27,15 @@ targetdir="${tmpdir}"
goroot="$(go_${target} env GOROOT)"
if [[ "${PWD}" == ${goroot}/src/* ]]
then
- targetdir="${tmpdir}/go/src/${PWD#${goroot}/src/}"
+ targetdir="${tmpdir}/goroot/src/${PWD#${goroot}/src/}"
fi
# Set GOROOT, and forward some environment variables to the remote shell.
-vars="GOROOT=${tmpdir}/go"
+vars="GOROOT=${tmpdir}/goroot"
vars+="${GOOS:+ GOOS=${GOOS}}"
vars+="${GOARCH:+ GOARCH=${GOARCH}}"
vars+="${GOMAXPROCS:+ GOMAXPROCS=${GOMAXPROCS}}"
vars+="${GOTRACEBACK:+ GOTRACEBACK=${GOTRACEBACK}}"
# Remotely execute the binary using ssh (for ChromeOS) or adb (for Android).
-target_sh ${target} "cd ${targetdir} && ${vars} ${tmpdir}/a.out $*"
+target_sh ${target} "cd ${targetdir} && ${vars} ${GOLOADER} ${tmpdir}/a.out $*"
diff --git a/go/patch/go0.patch b/go/patch/go0.patch
index 27e1451e..c539865e 100644
--- a/go/patch/go0.patch
+++ b/go/patch/go0.patch
@@ -2,26 +2,33 @@ testenv: look for "go" executable in path.
--- src/go/build/deps_test.go
+++ src/go/build/deps_test.go
-@@ -168,7 +168,7 @@ var pkgDeps = map[string][]string{
- "testing": {"L2", "flag", "fmt", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"},
+@@ -182,17 +182,17 @@ var pkgDeps = map[string][]string{
+ "runtime/debug": {"L2", "fmt", "io/ioutil", "os", "time"},
+ "runtime/pprof": {"L2", "compress/gzip", "context", "encoding/binary", "fmt", "io/ioutil", "os", "text/tabwriter", "time"},
+ "runtime/trace": {"L0"},
+ "text/tabwriter": {"L2"},
+
+ "testing": {"L2", "flag", "fmt", "internal/race", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"},
"testing/iotest": {"L2", "log"},
- "testing/quick": {"L2", "flag", "fmt", "reflect"},
-- "internal/testenv": {"L2", "os", "testing"},
-+ "internal/testenv": {"L2", "os", "os/exec", "testing"},
+ "testing/quick": {"L2", "flag", "fmt", "reflect", "time"},
+- "internal/testenv": {"L2", "OS", "flag", "testing", "syscall"},
++ "internal/testenv": {"L2", "OS", "os/exec", "flag", "testing", "syscall"},
// L4 is defined as L3+fmt+log+time, because in general once
// you're using L3 packages, use of fmt, log, or time is not a big deal.
+ "L4": {
+ "L3",
+ "fmt",
+ "log",
+ "time",
--- src/internal/testenv/testenv.go
+++ src/internal/testenv/testenv.go
-@@ -12,6 +12,7 @@ package testenv
-
- import (
- "os"
-+ "os/exec"
- "runtime"
- "strings"
- "testing"
-@@ -36,6 +37,9 @@ func HasGoBuild() bool {
+@@ -43,16 +43,19 @@ func HasGoBuild() bool {
+ switch runtime.GOOS {
+ case "android", "nacl":
+ return false
+ case "darwin":
+ if strings.HasPrefix(runtime.GOARCH, "arm") {
return false
}
}
@@ -31,3 +38,8 @@ testenv: look for "go" executable in path.
return true
}
+ // MustHaveGoBuild checks that the current system can build programs with ``go build''
+ // and then run them with os.StartProcess or exec.Command.
+ // If not, MustHaveGoBuild calls t.Skip with an explanation.
+ func MustHaveGoBuild(t testing.TB) {
+ if os.Getenv("GO_GCFLAGS") != "" {
diff --git a/go/patch/go1.patch b/go/patch/go1.patch
index 49d229ec..e32268ac 100644
--- a/go/patch/go1.patch
+++ b/go/patch/go1.patch
@@ -2,49 +2,66 @@ test: enable some tests on android/arm64.
--- test/chanlinear.go
+++ test/chanlinear.go
-@@ -1,4 +1,4 @@
+@@ -1,9 +1,9 @@
-// +build darwin linux
+// +build darwin linux android
// run
// Copyright 2014 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.
+
+ // Test that dequeueing from a pending channel doesn't
+ // take linear time.
--- test/fixedbugs/bug385_64.go
+++ test/fixedbugs/bug385_64.go
-@@ -1,4 +1,4 @@
+@@ -1,9 +1,9 @@
-// +build amd64
+// +build amd64 arm64
// errorcheck
- // Copyright 2011 The Go Authors. All rights reserved.
+ // Copyright 2011 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.
+
+ // Issue 2444
+ // Issue 4666: issue with arrays of exactly 4GB.
--- test/fixedbugs/issue10607.go
+++ test/fixedbugs/issue10607.go
-@@ -1,4 +1,4 @@
--// +build linux,!ppc64,!ppc64le,!mips64,!mips64le
-+// +build linux,!ppc64,!ppc64le,!mips64,!mips64le android
+@@ -1,9 +1,9 @@
+-// +build linux,!ppc64
++// +build linux,!ppc64 android
// run
// Copyright 2015 The Go Authors. All rights reserved.
---- test/fixedbugs/issue6036.go
-+++ test/fixedbugs/issue6036.go
-@@ -1,4 +1,4 @@
--// +build amd64
-+// +build amd64 arm64
- // compile
+ // Use of this source code is governed by a BSD-style
+ // license that can be found in the LICENSE file.
- // Copyright 2013 The Go Authors. All rights reserved.
+ // Test that a -B option is passed through when using both internal
+ // and external linking mode.
--- test/maplinear.go
+++ test/maplinear.go
-@@ -1,4 +1,4 @@
+@@ -1,9 +1,9 @@
-// +build darwin linux
+// +build darwin linux android
// run
// Copyright 2013 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.
+
+ // Test that maps don't go quadratic for NaNs and other values.
+
--- test/recover4.go
+++ test/recover4.go
-@@ -1,4 +1,4 @@
+@@ -1,9 +1,9 @@
-// +build linux darwin
+// +build linux android darwin
// run
- // Copyright 2015 The Go Authors. All rights reserved.
+ // Copyright 2015 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.
+
+ // Test that if a slice access causes a fault, a deferred func
+ // sees the most recent value of the variables it accesses.
diff --git a/go/patch/go2.patch b/go/patch/go2.patch
index dfc236a4..20f04791 100644
--- a/go/patch/go2.patch
+++ b/go/patch/go2.patch
@@ -2,10 +2,15 @@ test: add -target flag.
--- test/run.go
+++ test/run.go
-@@ -37,9 +37,9 @@ var (
+@@ -34,19 +34,19 @@ import (
+
+ var (
+ verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.")
+ keep = flag.Bool("k", false, "keep. keep temporary directory.")
numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run")
summary = flag.Bool("summary", false, "show summary of results")
showSkips = flag.Bool("show_skips", false, "show skipped tests")
+ runSkips = flag.Bool("run_skips", false, "run skipped tests (ignore skip and build tags)")
- linkshared = flag.Bool("linkshared", false, "")
updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output")
runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run")
@@ -13,29 +18,42 @@ test: add -target flag.
shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.")
shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.")
-@@ -192,19 +192,11 @@ func goFiles(dir string) []string {
+ )
+
+ var (
+ goos, goarch string
+
+@@ -189,48 +189,49 @@ func goFiles(dir string) []string {
+ }
+ sort.Strings(names)
+ return names
+ }
+
type runCmd func(...string) ([]byte, error)
- func compileFile(runcmd runCmd, longname string) (out []byte, err error) {
+ func compileFile(runcmd runCmd, longname string, flags []string) (out []byte, err error) {
- cmd := []string{"go", "tool", "compile", "-e"}
++ cmd := []string{findGoCmd(), "tool", "compile", "-e"}
+ cmd = append(cmd, flags...)
- if *linkshared {
- cmd = append(cmd, "-dynlink", "-installsuffix=dynlink")
- }
-- cmd = append(cmd, longname)
-- return runcmd(cmd...)
-+ return runcmd(findGoCmd(), "tool", "compile", "-e", longname)
+ cmd = append(cmd, longname)
+ return runcmd(cmd...)
}
- func compileInDir(runcmd runCmd, dir string, names ...string) (out []byte, err error) {
+ func compileInDir(runcmd runCmd, dir string, flags []string, names ...string) (out []byte, err error) {
- cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", "."}
++ cmd := []string{findGoCmd(), "tool", "compile", "-e", "-D", ".", "-I", "."}
+ cmd = append(cmd, flags...)
- if *linkshared {
- cmd = append(cmd, "-dynlink", "-installsuffix=dynlink")
- }
-+ cmd := []string{findGoCmd(), "tool", "compile", "-e", "-D", ".", "-I", "."}
for _, name := range names {
cmd = append(cmd, filepath.Join(dir, name))
}
-@@ -213,15 +205,21 @@ func compileInDir(runcmd runCmd, dir string, names ...string) (out []byte, err e
+ return runcmd(cmd...)
+ }
func linkFile(runcmd runCmd, goname string) (err error) {
pfile := strings.Replace(goname, ".go", ".o", -1)
@@ -49,12 +67,13 @@ test: add -target flag.
return
}
-+func goRun(runcmd runCmd, goname string, args ...string) (out []byte, err error) {
-+ cmd := []string{findGoCmd(), "run"}
++func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out []byte, err error) {
++ cmd := []string{findGoCmd(), "run", goGcflags()}
+ if len(findExecCmd()) > 0 {
+ cmd = append(cmd, "-exec")
+ cmd = append(cmd, findExecCmd()...)
+ }
++ cmd = append(cmd, flags...)
+ cmd = append(cmd, goname)
+ cmd = append(cmd, args...)
+ return runcmd(cmd...)
@@ -63,81 +82,230 @@ test: add -target flag.
// skipError describes why a test was skipped.
type skipError string
-@@ -530,8 +528,7 @@ func (t *test) run() {
+ func (s skipError) Error() string { return string(s) }
+
+ func check(err error) {
+ if err != nil {
+ log.Fatal(err)
+@@ -590,18 +591,17 @@ func (t *test) run() {
+
+ long := filepath.Join(cwd, t.goFileName())
+ switch action {
+ default:
t.err = fmt.Errorf("unimplemented action %q", action)
case "errorcheck":
-- cmdline := []string{"go", "tool", "compile", "-e", "-o", "a.o"}
+ // TODO(gri) remove need for -C (disable printing of columns in error messages)
+- cmdline := []string{"go", "tool", "compile", "-C", "-e", "-o", "a.o"}
- // No need to add -dynlink even if linkshared if we're just checking for errors...
-+ cmdline := []string{findGoCmd(), "tool", "compile", "-e", "-o", "a.o"}
++ cmdline := []string{findGoCmd(), "tool", "compile", "-C", "-e", "-o", "a.o"}
cmdline = append(cmdline, flags...)
cmdline = append(cmdline, long)
out, err := runcmd(cmdline...)
-@@ -640,19 +637,14 @@ func (t *test) run() {
+ if wantError {
+ if err == nil {
+ t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out)
+ return
+ }
+@@ -704,17 +704,17 @@ func (t *test) run() {
+ }
+ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
+ t.err = fmt.Errorf("incorrect output\n%s", out)
+ }
+ }
}
case "build":
-- _, err := runcmd("go", "build", "-o", "a.exe", long)
-+ _, err := runcmd(findGoCmd(), "build", "-o", "a.exe", long)
+- _, err := runcmd("go", "build", goGcflags(), "-o", "a.exe", long)
++ _, err := runcmd(findGoCmd(), "build", goGcflags(), "-o", "a.exe", long)
if err != nil {
t.err = err
}
- case "run":
- useTmp = false
-- cmd := []string{"go", "run"}
+ case "builddir":
+ // Build an executable from all the .go and .s files in a subdirectory.
+ useTmp = true
+ longdir := filepath.Join(cwd, t.goDirName())
+@@ -730,177 +730,132 @@ func (t *test) run() {
+ case ".go":
+ gos = append(gos, file)
+ case ".s":
+ asms = append(asms, file)
+ }
+
+ }
+ var objs []string
+- cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"}
++ cmd := []string{findGoCmd(), "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"}
+ if len(asms) > 0 {
+ cmd = append(cmd, "-asmhdr", "go_asm.h")
+ }
+ for _, file := range gos {
+ cmd = append(cmd, filepath.Join(longdir, file.Name()))
+ }
+ _, err := runcmd(cmd...)
+ if err != nil {
+ t.err = err
+ break
+ }
+ objs = append(objs, "go.o")
+ if len(asms) > 0 {
+- cmd = []string{"go", "tool", "asm", "-e", "-I", ".", "-o", "asm.o"}
++ cmd = []string{findGoCmd(), "tool", "asm", "-e", "-I", ".", "-o", "asm.o"}
+ for _, file := range asms {
+ cmd = append(cmd, filepath.Join(longdir, file.Name()))
+ }
+ _, err = runcmd(cmd...)
+ if err != nil {
+ t.err = err
+ break
+ }
+ objs = append(objs, "asm.o")
+ }
+- cmd = []string{"go", "tool", "pack", "c", "all.a"}
++ cmd = []string{findGoCmd(), "tool", "pack", "c", "all.a"}
+ cmd = append(cmd, objs...)
+ _, err = runcmd(cmd...)
+ if err != nil {
+ t.err = err
+ break
+ }
+- cmd = []string{"go", "tool", "link", "all.a"}
++ cmd = []string{findGoCmd(), "tool", "link", "all.a"}
+ _, err = runcmd(cmd...)
+ if err != nil {
+ t.err = err
+ break
+ }
+
+ case "buildrun": // build binary, then run binary, instead of go run. Useful for timeout tests where failure mode is infinite loop.
+ // TODO: not supported on NaCl
+ useTmp = true
+- cmd := []string{"go", "build", goGcflags(), "-o", "a.exe"}
- if *linkshared {
- cmd = append(cmd, "-linkshared")
- }
-- cmd = append(cmd, t.goFileName())
-- out, err := runcmd(append(cmd, args...)...)
-+ out, err := goRun(runcmd, t.goFileName(), args...)
++ cmd := []string{findGoCmd(), "build", goGcflags(), "-o", "a.exe"}
+ longdirgofile := filepath.Join(filepath.Join(cwd, t.dir), t.gofile)
+ cmd = append(cmd, flags...)
+ cmd = append(cmd, longdirgofile)
+ out, err := runcmd(cmd...)
+ if err != nil {
+ t.err = err
+ return
+ }
+- cmd = []string{"./a.exe"}
++ cmd = []string{}
++ if len(findExecCmd()) > 0 {
++ cmd = append(cmd, findExecCmd()...)
++ }
++ cmd = append(cmd, "./a.exe")
+ out, err = runcmd(append(cmd, args...)...)
if err != nil {
t.err = err
return
-@@ -667,12 +659,7 @@ func (t *test) run() {
+ }
+
+ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
+ t.err = fmt.Errorf("incorrect output\n%s", out)
+ }
+
+ case "run":
+ useTmp = false
+- var out []byte
+- var err error
+- if len(flags)+len(args) == 0 && goGcflags() == "" && !*linkshared {
+- // If we're not using special go command flags,
+- // skip all the go command machinery.
+- // This avoids any time the go command would
+- // spend checking whether, for example, the installed
+- // package runtime is up to date.
+- // Because we run lots of trivial test programs,
+- // the time adds up.
+- pkg := filepath.Join(t.tempDir, "pkg.a")
+- if _, err := runcmd("go", "tool", "compile", "-o", pkg, t.goFileName()); err != nil {
+- t.err = err
+- return
+- }
+- exe := filepath.Join(t.tempDir, "test.exe")
+- cmd := []string{"go", "tool", "link", "-s", "-w"}
+- cmd = append(cmd, "-o", exe, pkg)
+- if _, err := runcmd(cmd...); err != nil {
+- t.err = err
+- return
+- }
+- out, err = runcmd(append([]string{exe}, args...)...)
+- } else {
+- cmd := []string{"go", "run", goGcflags()}
+- if *linkshared {
+- cmd = append(cmd, "-linkshared")
+- }
+- cmd = append(cmd, flags...)
+- cmd = append(cmd, t.goFileName())
+- out, err = runcmd(append(cmd, args...)...)
+- }
++ out, err := goRun(runcmd, flags, t.goFileName(), args...)
+ if err != nil {
+ t.err = err
+ return
+ }
+ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
+ t.err = fmt.Errorf("incorrect output\n%s", out)
+ }
+
+ case "runoutput":
+ rungatec <- true
+ defer func() {
<-rungatec
}()
useTmp = false
-- cmd := []string{"go", "run"}
+- cmd := []string{"go", "run", goGcflags()}
- if *linkshared {
- cmd = append(cmd, "-linkshared")
- }
- cmd = append(cmd, t.goFileName())
- out, err := runcmd(append(cmd, args...)...)
-+ out, err := goRun(runcmd, t.goFileName(), args...)
++ out, err := goRun(runcmd, nil, t.goFileName(), args...)
if err != nil {
t.err = err
return
-@@ -682,12 +669,7 @@ func (t *test) run() {
+ }
+ tfile := filepath.Join(t.tempDir, "tmp__.go")
+ if err := ioutil.WriteFile(tfile, out, 0666); err != nil {
t.err = fmt.Errorf("write tempfile:%s", err)
return
}
-- cmd = []string{"go", "run"}
+- cmd = []string{"go", "run", goGcflags()}
- if *linkshared {
- cmd = append(cmd, "-linkshared")
- }
- cmd = append(cmd, tfile)
- out, err = runcmd(cmd...)
-+ out, err = goRun(runcmd, tfile)
++ out, err = goRun(runcmd, nil, tfile)
if err != nil {
t.err = err
return
-@@ -698,12 +680,7 @@ func (t *test) run() {
+ }
+ if string(out) != t.expectedOutput() {
+ t.err = fmt.Errorf("incorrect output\n%s", out)
+ }
case "errorcheckoutput":
useTmp = false
-- cmd := []string{"go", "run"}
+- cmd := []string{"go", "run", goGcflags()}
- if *linkshared {
- cmd = append(cmd, "-linkshared")
- }
- cmd = append(cmd, t.goFileName())
- out, err := runcmd(append(cmd, args...)...)
-+ out, err := goRun(runcmd, t.goFileName(), args...)
++ out, err := goRun(runcmd, nil, t.goFileName(), args...)
if err != nil {
t.err = err
return
-@@ -714,7 +691,7 @@ func (t *test) run() {
+ }
+ tfile := filepath.Join(t.tempDir, "tmp__.go")
+ err = ioutil.WriteFile(tfile, out, 0666)
+ if err != nil {
t.err = fmt.Errorf("write tempfile:%s", err)
return
}
@@ -146,7 +314,17 @@ test: add -target flag.
cmdline = append(cmdline, flags...)
cmdline = append(cmdline, tfile)
out, err = runcmd(cmdline...)
-@@ -741,6 +718,10 @@ func findExecCmd() []string {
+ if wantError {
+ if err == nil {
+ t.err = fmt.Errorf("compilation succeeded unexpectedly\n%s", out)
+ return
+ }
+@@ -917,26 +872,37 @@ func (t *test) run() {
+
+ var execCmd []string
+
+ func findExecCmd() []string {
+ if execCmd != nil {
return execCmd
}
execCmd = []string{} // avoid work the second time
@@ -157,7 +335,10 @@ test: add -target flag.
if goos == runtime.GOOS && goarch == runtime.GOARCH {
return execCmd
}
-@@ -751,6 +732,13 @@ func findExecCmd() []string {
+ path, err := exec.LookPath(fmt.Sprintf("go_%s_%s_exec", goos, goarch))
+ if err == nil {
+ execCmd = []string{path}
+ }
return execCmd
}
@@ -171,3 +352,8 @@ test: add -target flag.
func (t *test) String() string {
return filepath.Join(t.dir, t.gofile)
}
+
+ func (t *test) makeTempDir() {
+ var err error
+ t.tempDir, err = ioutil.TempDir("", "")
+ check(err)
diff --git a/go/patch/go3.patch b/go/patch/go3.patch
index 37bd562f..62247a03 100644
--- a/go/patch/go3.patch
+++ b/go/patch/go3.patch
@@ -2,14 +2,15 @@ test: add runtarget action.
--- test/fixedbugs/bug248.go
+++ test/fixedbugs/bug248.go
-@@ -1,5 +1,5 @@
+@@ -1,38 +1,57 @@
// +build !nacl,!plan9,!windows
-// run
+// runtarget
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -8,13 +8,32 @@
+ // license that can be found in the LICENSE file.
+
package main
import (
@@ -42,7 +43,7 @@ test: add runtarget action.
// TODO: If we get rid of errchk, re-enable this test on Windows.
errchk, err := filepath.Abs("errchk")
check(err)
-@@ -22,12 +41,12 @@ func main() {
+
err = os.Chdir(filepath.Join("fixedbugs", "bug248.dir"))
check(err)
@@ -61,16 +62,22 @@ test: add runtarget action.
os.Remove("bug0.o")
os.Remove("bug1.o")
+ os.Remove("bug2.o")
+ os.Remove("a.out")
+ }
+
+ func run(name string, args ...string) {
--- test/fixedbugs/bug302.go
+++ test/fixedbugs/bug302.go
-@@ -1,5 +1,5 @@
+@@ -1,28 +1,39 @@
// +build !nacl
-// run
+// runtarget
- // Copyright 2010 The Go Authors. All rights reserved.
+ // Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -8,16 +8,27 @@
+ // license that can be found in the LICENSE file.
+
package main
import (
@@ -101,16 +108,22 @@ test: add runtarget action.
os.Remove("p.o")
os.Remove("pp.a")
os.Remove("main.o")
+ }
+
+ func run(cmd string, args ...string) {
+ out, err := exec.Command(cmd, args...).CombinedOutput()
+ if err != nil {
--- test/fixedbugs/bug345.go
+++ test/fixedbugs/bug345.go
-@@ -1,5 +1,5 @@
+@@ -1,34 +1,45 @@
// +build !nacl,!plan9,!windows
-// run
+// runtarget
- // Copyright 2011 The Go Authors. All rights reserved.
+ // Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -8,13 +8,24 @@
+ // license that can be found in the LICENSE file.
+
package main
import (
@@ -135,7 +148,7 @@ test: add runtarget action.
// TODO: If we get rid of errchk, re-enable this test on Plan 9 and Windows.
errchk, err := filepath.Abs("errchk")
check(err)
-@@ -22,8 +33,8 @@ func main() {
+
err = os.Chdir(filepath.Join(".", "fixedbugs", "bug345.dir"))
check(err)
@@ -146,16 +159,24 @@ test: add runtarget action.
os.Remove("io.o")
}
+ func run(name string, args ...string) {
+ cmd := exec.Command(name, args...)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ fmt.Println(string(out))
--- test/fixedbugs/bug369.go
+++ test/fixedbugs/bug369.go
-@@ -1,5 +1,5 @@
+@@ -1,35 +1,54 @@
// +build !nacl,!windows
-// run
+// runtarget
- // Copyright 2011 The Go Authors. All rights reserved.
+ // Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -10,21 +10,40 @@
+ // license that can be found in the LICENSE file.
+
+ // Test that compiling with optimization turned on produces faster code.
+
package main
import (
@@ -201,16 +222,24 @@ test: add runtarget action.
os.Remove("slow.o")
os.Remove("fast.o")
+ os.Remove("main.o")
+ os.Remove("a.exe")
+ }
+
+ func run(name string, args ...string) {
--- test/fixedbugs/bug429_run.go
+++ test/fixedbugs/bug429_run.go
-@@ -1,5 +1,5 @@
+@@ -1,29 +1,49 @@
// +build !nacl
-// run
+// runtarget
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -10,6 +10,7 @@
+ // license that can be found in the LICENSE file.
+
+ // Run the bug429.go test.
+
package main
import (
@@ -218,7 +247,7 @@ test: add runtarget action.
"fmt"
"os"
"os/exec"
-@@ -17,8 +18,27 @@ import (
+ "path/filepath"
"strings"
)
@@ -247,16 +276,25 @@ test: add runtarget action.
out, err := cmd.CombinedOutput()
if err == nil {
fmt.Println("expected deadlock")
+ os.Exit(1)
+ }
+
+ want := "fatal error: all goroutines are asleep - deadlock!"
+ got := string(out)
--- test/fixedbugs/issue10607.go
+++ test/fixedbugs/issue10607.go
-@@ -1,5 +1,5 @@
- // +build linux,!ppc64,!ppc64le,!mips64,!mips64le android
+@@ -1,31 +1,51 @@
+ // +build linux,!ppc64 android
-// run
+// runtarget
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -11,19 +11,39 @@
+ // license that can be found in the LICENSE file.
+
+ // Test that a -B option is passed through when using both internal
+ // and external linking mode.
+
package main
import (
@@ -286,8 +324,9 @@ test: add runtarget action.
+}
+
func main() {
+- test("internal")
+ flag.Parse()
- test("internal")
++ // test("internal")
test("external")
}
@@ -297,16 +336,22 @@ test: add runtarget action.
if err != nil {
fmt.Printf("BUG: linkmode=%s %v\n%s\n", linkmode, err, out)
os.Exit(1)
+ }
+ }
--- test/fixedbugs/issue11771.go
+++ test/fixedbugs/issue11771.go
-@@ -1,5 +1,5 @@
+@@ -1,31 +1,42 @@
// +build !nacl
-// run
+// runtarget
- // Copyright 2015 The Go Authors. All rights reserved.
+ // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -11,6 +11,7 @@ package main
+ // license that can be found in the LICENSE file.
+
+ // Issue 11771: Magic comments should ignore carriage returns.
+
+ package main
import (
"bytes"
@@ -314,7 +359,9 @@ test: add runtarget action.
"fmt"
"io/ioutil"
"log"
-@@ -20,7 +21,17 @@ import (
+ "os"
+ "os/exec"
+ "path/filepath"
"runtime"
)
@@ -332,7 +379,17 @@ test: add runtarget action.
if runtime.Compiler != "gc" {
return
}
-@@ -52,7 +63,7 @@ func x() {
+
+ dir, err := ioutil.TempDir("", "go-issue11771")
+ if err != nil {
+ log.Fatalf("creating temp dir: %v\n", err)
+ }
+@@ -47,17 +58,17 @@ func main() {
+ func x() {
+ }
+ `)
+
+ if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil {
log.Fatal(err)
}
@@ -341,15 +398,21 @@ test: add runtarget action.
cmd.Dir = dir
output, err := cmd.CombinedOutput()
if err == nil {
+ log.Fatal("compile succeeded unexpectedly")
+ }
+ if !bytes.Contains(output, []byte("only allowed in runtime")) {
+ log.Fatalf("wrong error message from compiler; got:\n%s\n", output)
+ }
--- test/fixedbugs/issue9355.go
+++ test/fixedbugs/issue9355.go
-@@ -1,4 +1,4 @@
+@@ -1,34 +1,45 @@
-// run
+// runtarget
- // Copyright 2014 The Go Authors. All rights reserved.
+ // Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -7,6 +7,7 @@
+ // license that can be found in the LICENSE file.
+
package main
import (
@@ -357,7 +420,8 @@ test: add runtarget action.
"fmt"
"os"
"os/exec"
-@@ -15,7 +16,17 @@ import (
+ "path/filepath"
+ "regexp"
"runtime"
)
@@ -375,7 +439,7 @@ test: add runtarget action.
if runtime.Compiler != "gc" || runtime.GOOS == "nacl" {
return
}
-@@ -23,7 +34,7 @@ func main() {
+
err := os.Chdir(filepath.Join("fixedbugs", "issue9355.dir"))
check(err)
@@ -384,16 +448,24 @@ test: add runtarget action.
os.Remove("a.o")
// 6g/8g print the offset as dec, but 5g/9g print the offset as hex.
+ patterns := []string{
+ `rel 0\+\d t=1 \"\"\.x\+8\r?\n`, // y = &x.b
+ `rel 0\+\d t=1 \"\"\.x\+(28|1c)\r?\n`, // z = &x.d.q
+ `rel 0\+\d t=1 \"\"\.b\+5\r?\n`, // c = &b[5]
+ `rel 0\+\d t=1 \"\"\.x\+(88|58)\r?\n`, // w = &x.f[3].r
--- test/fixedbugs/issue9862_run.go
+++ test/fixedbugs/issue9862_run.go
-@@ -1,5 +1,5 @@
+@@ -1,26 +1,46 @@
// +build !nacl
-// run
+// runtarget
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -10,12 +10,32 @@
+ // license that can be found in the LICENSE file.
+
+ // Check for compile or link error.
+
package main
import (
@@ -427,16 +499,24 @@ test: add runtarget action.
outstr := string(out)
if err == nil {
println("go run issue9862.go succeeded, should have failed\n", outstr)
+ return
+ }
+ if !strings.Contains(outstr, "symbol too large") {
+ println("go run issue9862.go gave unexpected error; want symbol too large:\n", outstr)
+ }
--- test/linkmain_run.go
+++ test/linkmain_run.go
-@@ -1,5 +1,5 @@
+@@ -1,26 +1,36 @@
// +build !nacl
-// run
+// runtarget
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -10,12 +10,22 @@
+ // license that can be found in the LICENSE file.
+
+ // Run the sinit test.
+
package main
import (
@@ -459,7 +539,17 @@ test: add runtarget action.
func cleanup() {
os.Remove("linkmain.o")
os.Remove("linkmain.a")
-@@ -51,16 +61,18 @@ func runFail(cmdline string) {
+ os.Remove("linkmain1.o")
+ os.Remove("linkmain1.a")
+ os.Remove("linkmain.exe")
+ }
+
+@@ -46,21 +56,23 @@ func runFail(cmdline string) {
+ fmt.Println(string(out))
+ fmt.Println("SHOULD HAVE FAILED!")
+ cleanup()
+ os.Exit(1)
+ }
}
func main() {
@@ -486,16 +576,114 @@ test: add runtarget action.
+ runFail(goCmd() + " tool link -o linkmain.exe linkmain1.a")
cleanup()
}
+--- test/linkobj.go
++++ test/linkobj.go
+@@ -1,31 +1,50 @@
+ // +build !nacl
+-// run
++// runtarget
+
+ // Copyright 2016 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.
+
+ // Test the compiler -linkobj flag.
+
+ package main
+
+ import (
++ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "strings"
+ )
+
++var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries")
++
++func goCmd() string {
++ if *target != "" {
++ return "go_" + *target
++ }
++ return "go"
++}
++
++func goRun(cmd ...string) string {
++ if *target == "" {
++ return run(cmd...)
++ } else {
++ return run(append([]string{"go_"+*target+"_exec"}, cmd...)...)
++ }
++}
++
+ var pwd, tmpdir string
+
+ func main() {
++ flag.Parse()
+ dir, err := ioutil.TempDir("", "go-test-linkobj-")
+ if err != nil {
+ log.Fatal(err)
+ }
+ pwd, err = os.Getwd()
+ if err != nil {
+ log.Fatal(err)
+ }
+@@ -71,33 +90,33 @@ func main() {
+
+ // The compiler expects the files being read to have the right suffix.
+ o := "o"
+ if round == 1 {
+ o = "a"
+ }
+
+ // inlining is disabled to make sure that the link objects contain needed code.
+- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go")
+- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go")
+- run("go", "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go")
++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go")
++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go")
++ run(goCmd(), "tool", "compile", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go")
+
+ cp("p1."+o, "p1.oo")
+ cp("p2."+o, "p2.oo")
+ cp("p3."+o, "p3.oo")
+ cp("p1.lo", "p1."+o)
+ cp("p2.lo", "p2."+o)
+ cp("p3.lo", "p3."+o)
+- out := runFail("go", "tool", "link", "p2."+o)
++ out := runFail(goCmd(), "tool", "link", "p2."+o)
+ if !strings.Contains(out, "not package main") {
+ fatalf("link p2.o failed but not for package main:\n%s", out)
+ }
+
+- run("go", "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o)
+- out = run("./a.out.exe")
++ run(goCmd(), "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o)
++ out = goRun("./a.out.exe")
+ if !strings.Contains(out, "hello from p1\nhello from p2\nhello from main\n") {
+ fatalf("running main, incorrect output:\n%s", out)
+ }
+
+ // ensure that mistaken future round can't use these
+ os.Remove("p1.o")
+ os.Remove("a.out.exe")
+ }
--- test/linkx_run.go
+++ test/linkx_run.go
-@@ -1,5 +1,5 @@
+@@ -1,35 +1,55 @@
// +build !nacl
-// run
+// runtarget
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -11,20 +11,40 @@ package main
+ // license that can be found in the LICENSE file.
+
+ // Run the linkx test.
+
+ package main
import (
"bytes"
@@ -526,7 +714,7 @@ test: add runtarget action.
+
func main() {
+ flag.Parse()
- test(" ") // old deprecated syntax
+ // test(" ") // old deprecated & removed syntax
test("=") // new syntax
}
@@ -537,7 +725,17 @@ test: add runtarget action.
var out, errbuf bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &errbuf
-@@ -44,7 +64,7 @@ func test(sep string) {
+ err := cmd.Run()
+ if err != nil {
+ fmt.Println(errbuf.String())
+ fmt.Println(out.String())
+ fmt.Println(err)
+@@ -39,25 +59,25 @@ func test(sep string) {
+ want := "hello\ntrumped\n"
+ got := out.String()
+ if got != want {
+ fmt.Printf("got %q want %q\n", got, want)
+ os.Exit(1)
}
// Issue 8810
@@ -546,7 +744,7 @@ test: add runtarget action.
_, err = cmd.CombinedOutput()
if err == nil {
fmt.Println("-X linker flag should not accept keys without values")
-@@ -52,7 +72,7 @@ func test(sep string) {
+ os.Exit(1)
}
// Issue 9621
@@ -555,16 +753,23 @@ test: add runtarget action.
outx, err := cmd.CombinedOutput()
if err == nil {
fmt.Println("-X linker flag should not overwrite non-strings")
+ os.Exit(1)
+ }
+ outstr := string(outx)
+ if !strings.Contains(outstr, "main.b") {
+ fmt.Printf("-X linker flag did not diagnose overwrite of main.b:\n%s\n", outstr)
--- test/nosplit.go
+++ test/nosplit.go
-@@ -1,5 +1,5 @@
+@@ -1,31 +1,49 @@
// +build !nacl
-// run
+// runtarget
- // Copyright 2014 The Go Authors. All rights reserved.
+ // Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -9,6 +9,7 @@ package main
+ // license that can be found in the LICENSE file.
+
+ package main
import (
"bytes"
@@ -572,7 +777,7 @@ test: add runtarget action.
"fmt"
"io/ioutil"
"log"
-@@ -16,11 +17,28 @@ import (
+ "os"
"os/exec"
"path/filepath"
"regexp"
@@ -602,7 +807,17 @@ test: add runtarget action.
var tests = `
# These are test cases for the linker analysis that detects chains of
# nosplit functions that would cause a stack overflow.
-@@ -193,12 +211,13 @@ var (
+ #
+ # Lines beginning with # are comments.
+ #
+ # Each test case describes a sequence of functions, one per line.
+ # Each function definition is the function name, then the frame size,
+@@ -189,22 +207,23 @@ var (
+ commentRE = regexp.MustCompile(`(?m)^#.*`)
+ rejectRE = regexp.MustCompile(`(?s)\A(.+?)((\n|; *)REJECT(.*))?\z`)
+ lineRE = regexp.MustCompile(`(\w+) (\d+)( nosplit)?(.*)`)
+ callRE = regexp.MustCompile(`\bcall (\w+)\b`)
+ callindRE = regexp.MustCompile(`\bcallind\b`)
)
func main() {
@@ -619,7 +834,17 @@ test: add runtarget action.
if err != nil {
bug()
fmt.Printf("running go tool compile -V: %v\n", err)
-@@ -338,7 +357,7 @@ TestCases:
+ return
+ }
+ if s := string(version); goarch == "amd64" && strings.Contains(s, "X:") && !strings.Contains(s, "framepointer") {
+ // Skip this test if framepointer is NOT enabled on AMD64
+ return
+@@ -340,17 +359,17 @@ TestCases:
+
+ if err := ioutil.WriteFile(filepath.Join(dir, "asm.s"), buf.Bytes(), 0666); err != nil {
+ log.Fatal(err)
+ }
+ if err := ioutil.WriteFile(filepath.Join(dir, "main.go"), gobuf.Bytes(), 0666); err != nil {
log.Fatal(err)
}
@@ -628,9 +853,19 @@ test: add runtarget action.
cmd.Dir = dir
output, err := cmd.CombinedOutput()
if err == nil {
+ nok++
+ if reject {
+ bug()
+ fmt.Printf("accepted incorrectly:\n\t%s\n", indent(strings.TrimSpace(stanza)))
+ }
--- test/run.go
+++ test/run.go
-@@ -220,6 +220,16 @@ func goRun(runcmd runCmd, goname string, args ...string) (out []byte, err error)
+@@ -222,16 +222,26 @@ func goRun(runcmd runCmd, flags []string, goname string, args ...string) (out []
+ cmd = append(cmd, findExecCmd()...)
+ }
+ cmd = append(cmd, flags...)
+ cmd = append(cmd, goname)
+ cmd = append(cmd, args...)
return runcmd(cmd...)
}
@@ -647,16 +882,36 @@ test: add runtarget action.
// skipError describes why a test was skipped.
type skipError string
-@@ -469,7 +479,7 @@ func (t *test) run() {
+ func (s skipError) Error() string { return string(s) }
+
+ func check(err error) {
+ if err != nil {
+ log.Fatal(err)
+@@ -484,17 +494,17 @@ func (t *test) run() {
+ }
+
+ // TODO: Clean up/simplify this switch statement.
+ switch action {
+ case "rundircmpout":
+ action = "rundir"
case "cmpout":
action = "run" // the run case already looks for <dir>/<test>.out files
- fallthrough
-- case "compile", "compiledir", "build", "run", "runoutput", "rundir":
-+ case "compile", "compiledir", "build", "run", "runtarget", "runoutput", "rundir":
- t.action = action
+- case "compile", "compiledir", "build", "builddir", "run", "buildrun", "runoutput", "rundir":
++ case "compile", "compiledir", "build", "builddir", "run", "runtarget", "buildrun", "runoutput", "rundir":
+ // nothing to do
+ case "errorcheckandrundir":
+ wantError = false // should be no error if also will run
+ case "errorcheckwithauto":
+ action = "errorcheck"
+ wantAuto = true
+ wantError = true
case "errorcheck", "errorcheckdir", "errorcheckoutput":
- t.action = action
-@@ -653,6 +663,17 @@ func (t *test) run() {
+@@ -807,16 +817,27 @@ func (t *test) run() {
+ if err != nil {
+ t.err = err
+ return
+ }
+ if strings.Replace(string(out), "\r\n", "\n", -1) != t.expectedOutput() {
t.err = fmt.Errorf("incorrect output\n%s", out)
}
@@ -674,16 +929,25 @@ test: add runtarget action.
case "runoutput":
rungatec <- true
defer func() {
+ <-rungatec
+ }()
+ useTmp = false
+ out, err := goRun(runcmd, nil, t.goFileName(), args...)
+ if err != nil {
--- test/sinit_run.go
+++ test/sinit_run.go
-@@ -1,5 +1,5 @@
+@@ -1,28 +1,39 @@
// +build !nacl
-// run
+// runtarget
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
-@@ -11,13 +11,24 @@ package main
+ // license that can be found in the LICENSE file.
+
+ // Run the sinit test.
+
+ package main
import (
"bytes"
@@ -709,3 +973,8 @@ test: add runtarget action.
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(string(out))
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ os.Remove("sinit.o")
+
diff --git a/go/patch/go4.patch b/go/patch/go4.patch
index 1c96c093..290de390 100644
--- a/go/patch/go4.patch
+++ b/go/patch/go4.patch
@@ -2,15 +2,26 @@ runtime, crypto/x509: add -target flag.
--- src/crypto/x509/x509_test.go
+++ src/crypto/x509/x509_test.go
-@@ -19,6 +19,7 @@ import (
+@@ -13,29 +13,32 @@ import (
+ "crypto/rsa"
+ _ "crypto/sha256"
+ _ "crypto/sha512"
+ "crypto/x509/pkix"
+ "encoding/asn1"
+ "encoding/base64"
"encoding/hex"
"encoding/pem"
- "fmt"
+ "flag"
+ "fmt"
"internal/testenv"
"math/big"
"net"
-@@ -28,6 +29,8 @@ import (
+ "net/url"
+ "os/exec"
+ "reflect"
+ "runtime"
+ "strings"
+ "testing"
"time"
)
@@ -19,14 +30,24 @@ runtime, crypto/x509: add -target flag.
func TestParsePKCS1PrivateKey(t *testing.T) {
block, _ := pem.Decode([]byte(pemPrivateKey))
priv, err := ParsePKCS1PrivateKey(block.Bytes)
-@@ -862,7 +865,13 @@ func TestParsePEMCRL(t *testing.T) {
+ if err != nil {
+ t.Errorf("Failed to parse private key: %s", err)
+ return
+ }
+ if priv.PublicKey.N.Cmp(rsaPrivateKey.PublicKey.N) != 0 ||
+@@ -1089,17 +1092,23 @@ func TestParsePEMCRL(t *testing.T) {
+ }
+
+ // Can't check the signature here without a package cycle.
+ }
+
func TestImports(t *testing.T) {
testenv.MustHaveGoRun(t)
-- if err := exec.Command("go", "run", "x509_test_import.go").Run(); err != nil {
+- if err := exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go").Run(); err != nil {
+ var cmd *exec.Cmd
+ if *target == "" {
-+ cmd = exec.Command("go", "run", "x509_test_import.go")
++ cmd = exec.Command(testenv.GoToolPath(t), "run", "x509_test_import.go")
+ } else {
+ cmd = exec.Command("go_"+*target, "run", "-exec", "go_"+*target+"_exec", "x509_test_import.go")
+ }
@@ -34,27 +55,50 @@ runtime, crypto/x509: add -target flag.
t.Errorf("failed to run x509_test_import.go: %s", err)
}
}
+
+ const derCRLBase64 = "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"
+
+ const pemCRLBase64 = "LS0tLS1CRUdJTiBYNTA5IENSTC0tLS0tDQpNSUlCOWpDQ0FWOENBUUV3RFFZSktvWklodmNOQVFFRkJRQXdiREVhTUJnR0ExVUVDaE1SVWxOQklGTmxZM1Z5DQphWFI1SUVsdVl5NHhIakFjQmdOVkJBTVRGVkpUUVNCUWRXSnNhV01nVW05dmRDQkRRU0IyTVRFdU1Dd0dDU3FHDQpTSWIzRFFFSkFSWWZjbk5oYTJWdmJuSnZiM1J6YVdkdVFISnpZWE5sWTNWeWFYUjVMbU52YlJjTk1URXdNakl6DQpNVGt5T0RNd1doY05NVEV3T0RJeU1Ua3lPRE13V2pDQmpEQktBaEVBckRxb2g5RkhKSFhUN09QZ3V1bjQrQmNODQpNRGt4TVRBeU1UUXlOekE1V2pBbU1Bb0dBMVVkRlFRRENnRUpNQmdHQTFVZEdBUVJHQTh5TURBNU1URXdNakUwDQpNalExTlZvd1BnSVJBTEd6blowOTVQQjVhQU9MUGc1N2ZNTVhEVEF5TVRBeU16RTBOVEF4TkZvd0dqQVlCZ05WDQpIUmdFRVJnUE1qQXdNakV3TWpNeE5EVXdNVFJhb0RBd0xqQWZCZ05WSFNNRUdEQVdnQlQxVERGNlVRTS9MTmVMDQpsNWx2cUhHUXEzZzltekFMQmdOVkhSUUVCQUlDQUlRd0RRWUpLb1pJaHZjTkFRRUZCUUFEZ1lFQUZVNUFzNk16DQpxNVBSc2lmYW9iUVBHaDFhSkx5QytNczVBZ2MwYld5QTNHQWR4dXI1U3BQWmVSV0NCamlQL01FSEJXSkNsQkhQDQpHUmNxNXlJZDNFakRrYUV5eFJhK2k2N0x6dmhJNmMyOUVlNks5cFNZd2ppLzdSVWhtbW5Qclh0VHhsTDBsckxyDQptUVFKNnhoRFJhNUczUUE0Q21VZHNITnZicnpnbUNZcHZWRT0NCi0tLS0tRU5EIFg1MDkgQ1JMLS0tLS0NCg0K"
+
+--- src/runtime/crash_cgo_test.go
++++ src/runtime/crash_cgo_test.go
+@@ -279,17 +279,17 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) {
+ }
+ testenv.MustHaveGoRun(t)
+
+ exe, err := buildTestProg(t, "testprogcgo", buildArg)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+- got, err := testenv.CleanCmdEnv(exec.Command(exe, runArg)).CombinedOutput()
++ got, err := testenv.CleanCmdEnv(goExecCmd(exe, runArg)).CombinedOutput()
+ if err != nil {
+ if testenv.Builder() == "linux-amd64-alpine" {
+ // See Issue 18243 and Issue 19938.
+ t.Skipf("Skipping failing test on Alpine (golang.org/issue/18243). Ignoring error: %v", err)
+ }
+ t.Fatal(err)
+ }
+ fn := strings.TrimSpace(string(got))
--- src/runtime/crash_test.go
+++ src/runtime/crash_test.go
-@@ -5,6 +5,7 @@
- package runtime_test
-
- import (
-+ "flag"
- "fmt"
- "internal/testenv"
- "io/ioutil"
-@@ -18,6 +19,25 @@ import (
+@@ -17,16 +17,35 @@ import (
+ "runtime"
+ "strconv"
+ "strings"
+ "sync"
"testing"
+ "time"
)
+var target = flag.String("target", "", "if non empty, use 'go_target' to compile test files and 'go_target_exec' to run the binaries")
+
-+func goCmd() string {
++func goCmd(t *testing.T) string {
+ if *target != "" {
+ return "go_" + *target
+ }
-+ return "go"
++ return testenv.GoToolPath(t)
+}
+
+func goExecCmd(name string, arg ...string) *exec.Cmd {
@@ -70,32 +114,86 @@ runtime, crypto/x509: add -target flag.
var toRemove []string
func TestMain(m *testing.M) {
-@@ -65,7 +85,7 @@ func runTestProg(t *testing.T, binary, name string) string {
+ status := m.Run()
+ for _, file := range toRemove {
+ os.RemoveAll(file)
+ }
+ os.Exit(status)
+@@ -50,17 +69,17 @@ func runTestProg(t *testing.T, binary, name string, env ...string) string {
+
+ testenv.MustHaveGoBuild(t)
+
+ exe, err := buildTestProg(t, binary)
if err != nil {
t.Fatal(err)
}
-- got, _ := testEnv(exec.Command(exe, name)).CombinedOutput()
-+ got, _ := testEnv(goExecCmd(exe, name)).CombinedOutput()
- return string(got)
- }
-@@ -92,7 +112,7 @@ func buildTestProg(t *testing.T, binary string) (string, error) {
+- cmd := testenv.CleanCmdEnv(exec.Command(exe, name))
++ cmd := testenv.CleanCmdEnv(goExecCmd(exe, name))
+ cmd.Env = append(cmd.Env, env...)
+ if testing.Short() {
+ cmd.Env = append(cmd.Env, "RUNTIME_TEST_SHORT=1")
+ }
+ var b bytes.Buffer
+ cmd.Stdout = &b
+ cmd.Stderr = &b
+ if err := cmd.Start(); err != nil {
+@@ -125,17 +144,17 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error)
+ name += "_" + strings.Join(flags, "_")
+ }
+ target, ok := testprog.target[name]
+ if ok {
+ return target.exe, target.err
}
- exe := filepath.Join(testprog.dir, binary+".exe")
-- cmd := exec.Command("go", "build", "-o", exe)
-+ cmd := exec.Command(goCmd(), "build", "-o", exe)
+ exe := filepath.Join(testprog.dir, name+".exe")
+- cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...)
++ cmd := exec.Command(goCmd(t), append([]string{"build", "-o", exe}, flags...)...)
cmd.Dir = "testdata/" + binary
- out, err := testEnv(cmd).CombinedOutput()
+ out, err := testenv.CleanCmdEnv(cmd).CombinedOutput()
if err != nil {
+ target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out)
+ testprog.target[name] = target
+ return "", target.err
+ }
+ target.exe = exe
+@@ -456,17 +475,17 @@ func TestPanicLoop(t *testing.T) {
+ func TestMemPprof(t *testing.T) {
+ testenv.MustHaveGoRun(t)
+
+ exe, err := buildTestProg(t, "testprog")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+- got, err := testenv.CleanCmdEnv(exec.Command(exe, "MemProf")).CombinedOutput()
++ got, err := testenv.CleanCmdEnv(goExecCmd(exe, "MemProf")).CombinedOutput()
+ if err != nil {
+ t.Fatal(err)
+ }
+ fn := strings.TrimSpace(string(got))
+ defer os.Remove(fn)
+
+ for try := 0; try < 2; try++ {
+ cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-alloc_space", "-top"))
--- src/runtime/crash_unix_test.go
+++ src/runtime/crash_unix_test.go
-@@ -157,7 +157,7 @@ func TestSignalExitStatus(t *testing.T) {
+@@ -244,17 +244,17 @@ func testPanicSystemstackInternal() {
+ }
+
+ func TestSignalExitStatus(t *testing.T) {
+ testenv.MustHaveGoBuild(t)
+ exe, err := buildTestProg(t, "testprog")
if err != nil {
t.Fatal(err)
}
-- err = testEnv(exec.Command(exe, "SignalExitStatus")).Run()
-+ err = testEnv(goExecCmd(exe, "SignalExitStatus")).Run()
+- err = testenv.CleanCmdEnv(exec.Command(exe, "SignalExitStatus")).Run()
++ err = testenv.CleanCmdEnv(goExecCmd(exe, "SignalExitStatus")).Run()
if err == nil {
t.Error("test program succeeded unexpectedly")
} else if ee, ok := err.(*exec.ExitError); !ok {
+ t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
+ } else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
+ t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
+ } else if !ws.Signaled() || ws.Signal() != syscall.SIGTERM {
+ t.Errorf("got %v; expected SIGTERM", ee)
diff --git a/go/patch/go5.patch b/go/patch/go5.patch
index fa656586..7189c89e 100644
--- a/go/patch/go5.patch
+++ b/go/patch/go5.patch
@@ -1,198 +1,160 @@
-misc/cgo/testcshared: add support for -target.
+runtime: deadlock detection does not work when using external linker.
---- misc/cgo/testcshared/test.bash
-+++ misc/cgo/testcshared/test.bash
-@@ -14,9 +14,23 @@ if [ ! -f src/libgo/libgo.go ]; then
- exit 1
- fi
-
--goos=$(go env GOOS)
--goarch=$(go env GOARCH)
--goroot=$(go env GOROOT)
-+function target()
-+ {
-+ [[ -n "${target}" ]]
-+ }
-+
-+function go_target()
-+ {
-+ if target; then
-+ go_${target} "$@"
-+ else
-+ go "$@"
-+ fi
-+ }
-+
-+goos=$(go_target env GOOS)
-+goarch=$(go_target env GOARCH)
-+goroot=$(go_target env GOROOT)
- if [ ! -d "$goroot" ]; then
- echo 'misc/cgo/testcshared/test.bash cannnot find GOROOT' 1>&2
- echo '$GOROOT:' "$GOROOT" 1>&2
-@@ -31,8 +45,10 @@ if [ "${goos}" == "darwin" ]; then
- installdir=pkg/${goos}_${goarch}_testcshared
- fi
-
--# Temporary directory on the android device.
--androidpath=/data/local/tmp/testcshared-$$
-+# Temporary directory on the android/chromeos device.
-+if target; then
-+ remotepath=$(target_tmpdir)/testcshared-$$
-+fi
-
- function cleanup() {
- rm -f libgo.$libext libgo2.$libext libgo4.$libext libgo5.$libext
-@@ -40,37 +56,33 @@ function cleanup() {
- rm -f testp testp2 testp3 testp4 testp5
- rm -rf pkg "${goroot}/${installdir}"
-
-- if [ "$goos" == "android" ]; then
-- adb shell rm -rf "$androidpath"
-+ if target; then
-+ target_sh "${target}" "rm -rf $remotepath"
- fi
+--- src/runtime/crash_test.go
++++ src/runtime/crash_test.go
+@@ -214,32 +214,37 @@ func testDeadlock(t *testing.T, name string) {
+ output := runTestProg(t, "testprog", name)
+ want := "fatal error: all goroutines are asleep - deadlock!\n"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
}
- trap cleanup EXIT
-
--if [ "$goos" == "android" ]; then
-- adb shell mkdir -p "$androidpath"
-+if target; then
-+ target_sh "${target}" "mkdir -p $remotepath"
- fi
-
- function run() {
-- case "$goos" in
-- "android")
-+ if target; then
- local args=$@
-- output=$(adb shell "cd ${androidpath}; $@")
-- output=$(echo $output|tr -d '\r')
-+ output=$(target_sh "${target}" "cd ${remotepath}; $@")
- case $output in
- *PASS) echo "PASS";;
- *) echo "$output";;
- esac
-- ;;
-- *)
-+ else
- echo $(env $@)
-- ;;
-- esac
-+ fi
+
+ func TestSimpleDeadlock(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ testDeadlock(t, "SimpleDeadlock")
+ }
+
+ func TestInitDeadlock(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ testDeadlock(t, "InitDeadlock")
+ }
+
+ func TestLockedDeadlock(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ testDeadlock(t, "LockedDeadlock")
+ }
+
+ func TestLockedDeadlock2(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ testDeadlock(t, "LockedDeadlock2")
+ }
+
+ func TestGoexitDeadlock(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ output := runTestProg(t, "testprog", "GoexitDeadlock")
+ want := "no goroutines (main called runtime.Goexit) - deadlock!"
+ if !strings.Contains(output, want) {
+ t.Fatalf("output:\n%s\n\nwant output containing: %s", output, want)
+ }
+ }
+
+ func TestStackOverflow(t *testing.T) {
+@@ -266,16 +271,17 @@ panic: again
+ `
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+
}
- function binpush() {
- bin=${1}
-- if [ "$goos" == "android" ]; then
-- adb push "$bin" "${androidpath}/${bin}" 2>/dev/null
-+ if target; then
-+ target_cp "$bin" "${target}:${remotepath}/${bin}"
- fi
+ func TestGoexitCrash(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ output := runTestProg(t, "testprog", "GoexitExit")
+ want := "no goroutines (main called runtime.Goexit) - deadlock!"
+ if !strings.Contains(output, want) {
+ t.Fatalf("output:\n%s\n\nwant output containing: %s", output, want)
+ }
}
-@@ -84,9 +96,9 @@ if [ "$goos" == "darwin" ]; then
- fi
-
- # Create the header files.
--GOPATH=$(pwd) go install -buildmode=c-shared $suffix libgo
-+GOPATH=$(pwd) go_target install -buildmode=c-shared $suffix libgo
-
--GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo.$libext src/libgo/libgo.go
-+GOPATH=$(pwd) go_target build -buildmode=c-shared $suffix -o libgo.$libext src/libgo/libgo.go
- binpush libgo.$libext
-
- if [ "$goos" == "linux" ] || [ "$goos" == "android" ] ; then
-@@ -96,8 +108,8 @@ if [ "$goos" == "linux" ] || [ "$goos" == "android" ] ; then
- fi
- fi
-
--GOGCCFLAGS=$(go env GOGCCFLAGS)
--if [ "$goos" == "android" ]; then
-+GOGCCFLAGS=$(go_target env GOGCCFLAGS)
-+if target; then
- GOGCCFLAGS="${GOGCCFLAGS} -pie"
- fi
-
-@@ -105,7 +117,7 @@ status=0
-
- # test0: exported symbols in shared lib are accessible.
- # TODO(iant): using _shared here shouldn't really be necessary.
--$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
-+$(go_target env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
- binpush testp
-
- output=$(run LD_LIBRARY_PATH=. ./testp)
-@@ -115,7 +127,7 @@ if [ "$output" != "PASS" ]; then
- fi
-
- # test1: shared library can be dynamically loaded and exported symbols are accessible.
--$(go env CC) ${GOGCCFLAGS} -o testp main1.c -ldl
-+$(go_target env CC) ${GOGCCFLAGS} -o testp main1.c -ldl
- binpush testp
- output=$(run ./testp ./libgo.$libext)
- if [ "$output" != "PASS" ]; then
-@@ -124,13 +136,13 @@ if [ "$output" != "PASS" ]; then
- fi
-
- # test2: tests libgo2 which does not export any functions.
--GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo2.$libext libgo2
-+GOPATH=$(pwd) go_target build -buildmode=c-shared $suffix -o libgo2.$libext libgo2
- binpush libgo2.$libext
- linkflags="-Wl,--no-as-needed"
- if [ "$goos" == "darwin" ]; then
- linkflags=""
- fi
--$(go env CC) ${GOGCCFLAGS} -o testp2 main2.c $linkflags libgo2.$libext
-+$(go_target env CC) ${GOGCCFLAGS} -o testp2 main2.c $linkflags libgo2.$libext
- binpush testp2
- output=$(run LD_LIBRARY_PATH=. ./testp2)
- if [ "$output" != "PASS" ]; then
-@@ -138,9 +150,9 @@ if [ "$output" != "PASS" ]; then
- status=1
- fi
-
--# test3: tests main.main is exported on android.
--if [ "$goos" == "android" ]; then
-- $(go env CC) ${GOGCCFLAGS} -o testp3 main3.c -ldl
-+# test3: tests main.main is exported on android/chromeos.
-+if target; then
-+ $(go_target env CC) ${GOGCCFLAGS} -o testp3 main3.c -ldl
- binpush testp3
- output=$(run ./testp ./libgo.so)
- if [ "$output" != "PASS" ]; then
-@@ -150,14 +162,14 @@ if [ "$goos" == "android" ]; then
- fi
-
- # test4: tests signal handlers
--GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo4.$libext libgo4
-+GOPATH=$(pwd) go_target build -buildmode=c-shared $suffix -o libgo4.$libext libgo4
- binpush libgo4.$libext
--$(go env CC) ${GOGCCFLAGS} -pthread -o testp4 main4.c -ldl
-+$(go_target env CC) ${GOGCCFLAGS} -pthread -o testp4 main4.c -ldl
- binpush testp4
- output=$(run ./testp4 ./libgo4.$libext 2>&1)
- if test "$output" != "PASS"; then
- echo "FAIL test4 got ${output}"
-- if test "$goos" != "android"; then
-+ if ! target; then
- echo "re-running test4 in verbose mode"
- ./testp4 ./libgo4.$libext verbose
- fi
-@@ -165,14 +177,14 @@ if test "$output" != "PASS"; then
- fi
-
- # test5: tests signal handlers with os/signal.Notify
--GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo5.$libext libgo5
-+GOPATH=$(pwd) go_target build -buildmode=c-shared $suffix -o libgo5.$libext libgo5
- binpush libgo5.$libext
--$(go env CC) ${GOGCCFLAGS} -pthread -o testp5 main5.c -ldl
-+$(go_target env CC) ${GOGCCFLAGS} -pthread -o testp5 main5.c -ldl
- binpush testp5
- output=$(run ./testp5 ./libgo5.$libext 2>&1)
- if test "$output" != "PASS"; then
- echo "FAIL test5 got ${output}"
-- if test "$goos" != "android"; then
-+ if ! target; then
- echo "re-running test5 in verbose mode"
- ./testp5 ./libgo5.$libext verbose
- fi
+ func TestGoexitDefer(t *testing.T) {
+@@ -324,16 +330,17 @@ func TestBreakpoint(t *testing.T) {
+ // "runtime.Breakpoint(...)" instead of "runtime.Breakpoint()".
+ want := "runtime.Breakpoint("
+ if !strings.Contains(output, want) {
+ t.Fatalf("output:\n%s\n\nwant output containing: %s", output, want)
+ }
+ }
+
+ func TestGoexitInPanic(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ // see issue 8774: this code used to trigger an infinite recursion
+ output := runTestProg(t, "testprog", "GoexitInPanic")
+ want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+ }
+
+@@ -388,16 +395,17 @@ func TestPanicAfterGoexit(t *testing.T) {
+ output := runTestProg(t, "testprog", "PanicAfterGoexit")
+ want := "panic: hello"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+ }
+
+ func TestRecoveredPanicAfterGoexit(t *testing.T) {
++ t.Skip("deadlock detection fails with external linker")
+ output := runTestProg(t, "testprog", "RecoveredPanicAfterGoexit")
+ want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+ }
+
+ func TestRecoverBeforePanicAfterGoexit(t *testing.T) {
+--- src/runtime/proc_test.go
++++ src/runtime/proc_test.go
+@@ -349,19 +349,20 @@ func TestGCFairness2(t *testing.T) {
+ want := "OK\n"
+ if output != want {
+ t.Fatalf("want %s, got %s\n", want, output)
+ }
+ }
+
+ func TestNumGoroutine(t *testing.T) {
+ output := runTestProg(t, "testprog", "NumGoroutine")
+- want := "1\n"
+- if output != want {
+- t.Fatalf("want %q, got %q", want, output)
++ want1 := "1\n"
++ want2 := "2\n"
++ if output != want1 && output != want2 {
++ t.Fatalf("want %q, got %q", want1, output)
+ }
+
+ buf := make([]byte, 1<<20)
+
+ // Try up to 10 times for a match before giving up.
+ // This is a fundamentally racy check but it's important
+ // to notice if NumGoroutine and Stack are _always_ out of sync.
+ for i := 0; ; i++ {
+--- test/fixedbugs/bug429_run.go
++++ test/fixedbugs/bug429_run.go
+@@ -1,10 +1,10 @@
+ // +build !nacl
+-// runtarget
++// skip
+
+ // Copyright 2014 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.
+
+ // Run the bug429.go test.
+
+ package main
+--- test/goprint.go
++++ test/goprint.go
+@@ -3,19 +3,14 @@
+ // Copyright 2011 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.
+
+ // Test that println can be the target of a go statement.
+
+ package main
+
+-import (
+- "runtime"
+- "time"
+-)
++import "time"
+
+ func main() {
+ go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255))
+- for runtime.NumGoroutine() > 1 {
+- time.Sleep(10*time.Millisecond)
+- }
++ time.Sleep(100*time.Millisecond)
+ }
diff --git a/go/patch/go6.patch b/go/patch/go6.patch
index 7f1e4c0e..9f32ed84 100644
--- a/go/patch/go6.patch
+++ b/go/patch/go6.patch
@@ -1,65 +1,230 @@
-runtime: deadlock detection does not work when using external linker.
+all: disable some tests that have trouble running remotely.
---- src/runtime/crash_test.go
-+++ src/runtime/crash_test.go
-@@ -177,22 +177,27 @@ func testDeadlock(t *testing.T, name string) {
+--- src/encoding/gob/encoder_test.go
++++ src/encoding/gob/encoder_test.go
+@@ -1125,20 +1125,17 @@ func TestBadData(t *testing.T) {
+ if !strings.Contains(err.Error(), test.error) {
+ t.Errorf("#%d: decode: expected %q error, got %s", i, test.error, err.Error())
+ }
+ }
+ }
+
+ // TestHugeWriteFails tests that enormous messages trigger an error.
+ func TestHugeWriteFails(t *testing.T) {
+- if testing.Short() {
+- // Requires allocating a monster, so don't do this from all.bash.
+- t.Skip("skipping huge allocation in short mode")
+- }
++ t.Skip("skipping test due to huge memory requirement")
+ huge := make([]byte, tooBig)
+ huge[0] = 7 // Make sure it's not all zeros.
+ buf := new(bytes.Buffer)
+ err := NewEncoder(buf).Encode(huge)
+ if err == nil {
+ t.Fatalf("expected error for huge slice")
+ }
+ if !strings.Contains(err.Error(), "message too big") {
+--- src/runtime/crash_cgo_test.go
++++ src/runtime/crash_cgo_test.go
+@@ -246,20 +246,17 @@ func TestCgoCCodeSIGPROF(t *testing.T) {
+ got := runTestProg(t, "testprogcgo", "CgoCCodeSIGPROF")
+ want := "OK\n"
+ if got != want {
+ t.Errorf("expected %q got %v", want, got)
+ }
}
- func TestSimpleDeadlock(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- testDeadlock(t, "SimpleDeadlock")
+ func TestCgoCrashTraceback(t *testing.T) {
+- t.Parallel()
+- if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") {
+- t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
+- }
++ t.Skipf("skip running remotely")
+ got := runTestProg(t, "testprogcgo", "CrashTraceback")
+ for i := 1; i <= 3; i++ {
+ if !strings.Contains(got, fmt.Sprintf("cgo symbolizer:%d", i)) {
+ t.Errorf("missing cgo symbolizer:%d", i)
+ }
+ }
}
- func TestInitDeadlock(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- testDeadlock(t, "InitDeadlock")
+@@ -268,20 +265,17 @@ func TestCgoTracebackContext(t *testing.T) {
+ got := runTestProg(t, "testprogcgo", "TracebackContext")
+ want := "OK\n"
+ if got != want {
+ t.Errorf("expected %q got %v", want, got)
+ }
}
- func TestLockedDeadlock(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- testDeadlock(t, "LockedDeadlock")
+ func testCgoPprof(t *testing.T, buildArg, runArg string) {
+- t.Parallel()
+- if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") {
+- t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
+- }
++ t.Skipf("skip pprof test")
+ testenv.MustHaveGoRun(t)
+
+ exe, err := buildTestProg(t, "testprogcgo", buildArg)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ got, err := testenv.CleanCmdEnv(goExecCmd(exe, runArg)).CombinedOutput()
+--- src/runtime/crash_test.go
++++ src/runtime/crash_test.go
+@@ -476,16 +476,17 @@ func TestPanicDeadlockSyscall(t *testing.T) {
+ func TestPanicLoop(t *testing.T) {
+ output := runTestProg(t, "testprog", "PanicLoop")
+ if want := "panic while printing panic value"; !strings.Contains(output, want) {
+ t.Errorf("output does not contain %q:\n%s", want, output)
+ }
+ }
+
+ func TestMemPprof(t *testing.T) {
++ t.Skipf("skip pprof test")
+ testenv.MustHaveGoRun(t)
+
+ exe, err := buildTestProg(t, "testprog")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ got, err := testenv.CleanCmdEnv(goExecCmd(exe, "MemProf")).CombinedOutput()
+--- src/runtime/crash_unix_test.go
++++ src/runtime/crash_unix_test.go
+@@ -169,19 +169,17 @@ func loop(i int, c chan bool) {
+
+ func TestPanicSystemstack(t *testing.T) {
+ // Test that GOTRACEBACK=crash prints both the system and user
+ // stack of other threads.
+
+ // The GOTRACEBACK=crash handler takes 0.1 seconds even if
+ // it's not writing a core file and potentially much longer if
+ // it is. Skip in short mode.
+- if testing.Short() {
+- t.Skip("Skipping in short mode (GOTRACEBACK=crash is slow)")
+- }
++ t.Skip("Skipping (GOTRACEBACK=crash hangs on arm)")
+
+ if runtime.Sigisblocked(int(syscall.SIGQUIT)) {
+ t.Skip("skipping; SIGQUIT is blocked, see golang.org/issue/19196")
+ }
+
+ t.Parallel()
+ cmd := exec.Command(os.Args[0], "testPanicSystemstackInternal")
+ cmd = testenv.CleanCmdEnv(cmd)
+@@ -239,16 +237,17 @@ func init() {
}
- func TestLockedDeadlock2(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- testDeadlock(t, "LockedDeadlock2")
+ func testPanicSystemstackInternal() {
+ runtime.BlockOnSystemStack()
+ os.Exit(1) // Should be unreachable.
}
- func TestGoexitDeadlock(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- output := runTestProg(t, "testprog", "GoexitDeadlock")
- want := "no goroutines (main called runtime.Goexit) - deadlock!"
- if !strings.Contains(output, want) {
-@@ -229,6 +234,7 @@ panic: again
+ func TestSignalExitStatus(t *testing.T) {
++ t.Skipf("skip running remotely")
+ testenv.MustHaveGoBuild(t)
+ exe, err := buildTestProg(t, "testprog")
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = testenv.CleanCmdEnv(goExecCmd(exe, "SignalExitStatus")).Run()
+ if err == nil {
+ t.Error("test program succeeded unexpectedly")
+--- src/runtime/fastlog2_test.go
++++ src/runtime/fastlog2_test.go
+@@ -11,21 +11,17 @@ import (
+ )
+
+ func TestFastLog2(t *testing.T) {
+ // Compute the euclidean distance between math.Log2 and the FastLog2
+ // implementation over the range of interest for heap sampling.
+ const randomBitCount = 26
+ var e float64
+
+- inc := 1
+- if testing.Short() {
+- // Check 1K total values, down from 64M.
+- inc = 1 << 16
+- }
++ inc := 1 << 16
+ for i := 1; i < 1<<randomBitCount; i += inc {
+ l, fl := math.Log2(float64(i)), runtime.Fastlog2(float64(i))
+ d := l - fl
+ e += d * d
+ }
+ e = math.Sqrt(e)
+
+ if e > 1.0 {
+--- src/runtime/hash_test.go
++++ src/runtime/hash_test.go
+@@ -156,19 +156,17 @@ func TestSmhasherZeros(t *testing.T) {
+ for i := 0; i <= N; i++ {
+ h.addB(b[:i])
+ }
+ h.check(t)
}
- func TestGoexitCrash(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- output := runTestProg(t, "testprog", "GoexitExit")
- want := "no goroutines (main called runtime.Goexit) - deadlock!"
- if !strings.Contains(output, want) {
-@@ -285,6 +291,7 @@ func TestBreakpoint(t *testing.T) {
+ // Strings with up to two nonzero bytes all have distinct hashes.
+ func TestSmhasherTwoNonzero(t *testing.T) {
+- if testing.Short() {
+- t.Skip("Skipping in short mode")
+- }
++ t.Skip("skipping test due to huge memory requirement")
+ h := newHashSet()
+ for n := 2; n <= 16; n++ {
+ twoNonZero(h, n)
+ }
+ h.check(t)
+ }
+ func twoNonZero(h *HashSet, n int) {
+ b := make([]byte, n)
+@@ -259,19 +257,17 @@ func setbits(h *HashSet, b []byte, i int, k int) {
+ setbits(h, b, j+1, k-1)
+ b[j/8] &= byte(^(1 << uint(j&7)))
+ }
}
- func TestGoexitInPanic(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- // see issue 8774: this code used to trigger an infinite recursion
- output := runTestProg(t, "testprog", "GoexitInPanic")
- want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!"
-@@ -303,6 +310,7 @@ func TestPanicAfterGoexit(t *testing.T) {
+ // Test all possible combinations of n blocks from the set s.
+ // "permutation" is a bad name here, but it is what Smhasher uses.
+ func TestSmhasherPermutation(t *testing.T) {
+- if testing.Short() {
+- t.Skip("Skipping in short mode")
+- }
++ t.Skip("skipping test due to huge memory requirement")
+ permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
+ permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
+ permutation(t, []uint32{0, 1}, 20)
+ permutation(t, []uint32{0, 1 << 31}, 20)
+ permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 6)
}
+ func permutation(t *testing.T, s []uint32, n int) {
+ b := make([]byte, n*4)
+--- src/runtime/pprof/pprof_test.go
++++ src/runtime/pprof/pprof_test.go
+@@ -278,24 +278,17 @@ func profileOk(t *testing.T, need []string, prof bytes.Buffer, duration time.Dur
+ return ok
+ }
+
+ // Fork can hang if preempted with signals frequently enough (see issue 5517).
+ // Ensure that we do not do this.
+ func TestCPUProfileWithFork(t *testing.T) {
+ testenv.MustHaveExec(t)
- func TestRecoveredPanicAfterGoexit(t *testing.T) {
-+ t.Skip("deadlock detection fails with external linker")
- output := runTestProg(t, "testprog", "RecoveredPanicAfterGoexit")
- want := "fatal error: no goroutines (main called runtime.Goexit) - deadlock!"
- if !strings.HasPrefix(output, want) {
---- test/fixedbugs/bug429_run.go
-+++ test/fixedbugs/bug429_run.go
-@@ -1,5 +1,5 @@
- // +build !nacl
--// runtarget
-+// skip
-
- // Copyright 2014 The Go Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style
+- heap := 1 << 30
+- if runtime.GOOS == "android" {
+- // Use smaller size for Android to avoid crash.
+- heap = 100 << 20
+- }
+- if testing.Short() {
+- heap = 100 << 20
+- }
++ heap := 100 << 20
+ // This makes fork slower.
+ garbage := make([]byte, heap)
+ // Need to touch the slice, otherwise it won't be paged in.
+ done := make(chan bool)
+ go func() {
+ for i := range garbage {
+ garbage[i] = 42
+ }
diff --git a/go/patch/go7.patch b/go/patch/go7.patch
deleted file mode 100644
index 7b769cf4..00000000
--- a/go/patch/go7.patch
+++ /dev/null
@@ -1,139 +0,0 @@
-all: disable some tests that take a long time or allocate a lot of memory.
-
---- src/encoding/gob/encoder_test.go
-+++ src/encoding/gob/encoder_test.go
-@@ -1003,10 +1003,7 @@ func TestBadData(t *testing.T) {
-
- // TestHugeWriteFails tests that enormous messages trigger an error.
- func TestHugeWriteFails(t *testing.T) {
-- if testing.Short() {
-- // Requires allocating a monster, so don't do this from all.bash.
-- t.Skip("skipping huge allocation in short mode")
-- }
-+ t.Skip("skipping test due to huge memory requirement")
- huge := make([]byte, tooBig)
- huge[0] = 7 // Make sure it's not all zeros.
- buf := new(bytes.Buffer)
---- src/math/big/float_test.go
-+++ src/math/big/float_test.go
-@@ -1428,10 +1428,7 @@ func TestFloatQuo(t *testing.T) {
- // TestFloatQuoSmoke tests all divisions x/y for values x, y in the range [-n, +n];
- // it serves as a smoke test for basic correctness of division.
- func TestFloatQuoSmoke(t *testing.T) {
-- n := 1000
-- if testing.Short() {
-- n = 10
-- }
-+ n := 10
-
- const dprec = 3 // max. precision variation
- const prec = 10 + dprec // enough bits to hold n precisely
---- src/math/big/rat_test.go
-+++ src/math/big/rat_test.go
-@@ -430,10 +430,7 @@ func TestFloat64Distribution(t *testing.T) {
- 9,
- 11,
- }
-- var winc, einc = uint64(1), 1 // soak test (~75s on x86-64)
-- if testing.Short() {
-- winc, einc = 10, 500 // quick test (~12ms on x86-64)
-- }
-+ var winc, einc = uint64(10), 500
-
- for _, sign := range "+-" {
- for _, a := range add {
---- src/math/big/ratconv_test.go
-+++ src/math/big/ratconv_test.go
-@@ -344,9 +344,7 @@ func isFinite(f float64) bool {
- func TestFloat32SpecialCases(t *testing.T) {
- for _, input := range float64inputs {
- if strings.HasPrefix(input, "long:") {
-- if testing.Short() {
-- continue
-- }
-+ continue
- input = input[len("long:"):]
- }
-
-@@ -400,9 +398,7 @@ func TestFloat32SpecialCases(t *testing.T) {
- func TestFloat64SpecialCases(t *testing.T) {
- for _, input := range float64inputs {
- if strings.HasPrefix(input, "long:") {
-- if testing.Short() {
-- continue
-- }
-+ continue
- input = input[len("long:"):]
- }
-
---- src/net/dial_test.go
-+++ src/net/dial_test.go
-@@ -77,10 +77,7 @@ func TestSelfConnect(t *testing.T) {
- l.Close()
-
- // Try to connect to that address repeatedly.
-- n := 100000
-- if testing.Short() {
-- n = 1000
-- }
-+ n := 1000
- switch runtime.GOOS {
- case "darwin", "dragonfly", "freebsd", "netbsd", "openbsd", "plan9", "solaris", "windows":
- // Non-Linux systems take a long time to figure
---- src/runtime/fastlog2_test.go
-+++ src/runtime/fastlog2_test.go
-@@ -16,11 +16,7 @@ func TestFastLog2(t *testing.T) {
- const randomBitCount = 26
- var e float64
-
-- inc := 1
-- if testing.Short() {
-- // Check 1K total values, down from 64M.
-- inc = 1 << 16
-- }
-+ inc := 1 << 16
- for i := 1; i < 1<<randomBitCount; i += inc {
- l, fl := math.Log2(float64(i)), runtime.Fastlog2(float64(i))
- d := l - fl
---- src/runtime/hash_test.go
-+++ src/runtime/hash_test.go
-@@ -126,9 +126,7 @@ func TestSmhasherZeros(t *testing.T) {
-
- // Strings with up to two nonzero bytes all have distinct hashes.
- func TestSmhasherTwoNonzero(t *testing.T) {
-- if testing.Short() {
-- t.Skip("Skipping in short mode")
-- }
-+ t.Skip("skipping test due to huge memory requirement")
- h := newHashSet()
- for n := 2; n <= 16; n++ {
- twoNonZero(h, n)
-@@ -229,9 +227,7 @@ func setbits(h *HashSet, b []byte, i int, k int) {
- // Test all possible combinations of n blocks from the set s.
- // "permutation" is a bad name here, but it is what Smhasher uses.
- func TestSmhasherPermutation(t *testing.T) {
-- if testing.Short() {
-- t.Skip("Skipping in short mode")
-- }
-+ t.Skip("skipping test due to huge memory requirement")
- permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
- permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
- permutation(t, []uint32{0, 1}, 20)
---- src/runtime/pprof/pprof_test.go
-+++ src/runtime/pprof/pprof_test.go
-@@ -257,14 +257,7 @@ func profileOk(t *testing.T, need []string, prof bytes.Buffer, duration time.Dur
- func TestCPUProfileWithFork(t *testing.T) {
- testenv.MustHaveExec(t)
-
-- heap := 1 << 30
-- if runtime.GOOS == "android" {
-- // Use smaller size for Android to avoid crash.
-- heap = 100 << 20
-- }
-- if testing.Short() {
-- heap = 100 << 20
-- }
-+ heap := 100 << 20
- // This makes fork slower.
- garbage := make([]byte, heap)
- // Need to touch the slice, otherwise it won't be paged in.
diff --git a/go/push_goroot b/go/push_goroot
index 41612f72..0d7706e1 100755
--- a/go/push_goroot
+++ b/go/push_goroot
@@ -11,24 +11,19 @@ set -e -o pipefail
# It uses "target_sh" to remotely execute commands on the device.
# It uses "target_cp" to transfer files to the device.
-goroot="$(target_tmpdir)/go"
+goroot="$(target_tmpdir)/goroot"
for target in "$@"
do
- echo -n "pushing to ${target} ... "
+ echo -n "pushing goroot to ${target} ... "
target_sh ${target} "rm -rf ${goroot}"
target_sh ${target} "mkdir -p ${goroot}/pkg"
- pkgdir="$(go_${target} env GOOS)_$(go_${target} env GOARCH)"
- if [[ -d "pkg/${pkgdir}_shared" ]]
- then
- target_cp "pkg/${pkgdir}_shared" ${target}:${goroot}/pkg
- target_sh ${target} "ln -s ${pkgdir}_shared ${goroot}/pkg/${pkgdir}"
- else
- target_cp "pkg/${pkgdir}" ${target}:${goroot}/pkg
- fi
+ cd "$(go_${target} env GOROOT)"
+ pkgdir="pkg/$(go_${target} env GOOS)_$(go_${target} env GOARCH)"
+ target_cp "${pkgdir}" ${target}:${goroot}/pkg
target_cp "src" ${target}:${goroot}
target_cp "lib" ${target}:${goroot}
- target_cp "test" ${target}:${goroot}
+ [[ -d test ]] && target_cp "test" ${target}:${goroot}
echo "done"
done
diff --git a/go/test_go b/go/test_go
index 3740c1b7..548712f5 100755
--- a/go/test_go
+++ b/go/test_go
@@ -49,6 +49,7 @@ for target in "$@"
do
echo
echo "## ${target}"
+ push_goroot ${target}
echo
echo "# test"
@@ -77,12 +78,4 @@ do
echo
echo "# misc/cgo/{test,testtls,nocgo}"
GOTRACEBACK=2 go_test ./misc/cgo/{test,testtls,nocgo}
-
- echo
- echo "# misc/cgo/testcshared"
- (cd misc/cgo/testcshared && target="${target}" ./test.bash)
-
- echo
- echo "# misc/cgo/testsigfwd"
- (cd misc/cgo/testsigfwd && go_${target} run -exec="go_${target}_exec" main.go)
done