From dd95244d4b9be2dda0e899535fa6f7c637937617 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Mon, 30 Mar 2015 08:47:07 -0400 Subject: [PATCH] iostest.bash: build script for iOS In the spirit of nacltest.bash and androidtest.bash. Sets up the exec script and reboots the device. The reboot helps make sure previous runs do not interfere with the current run. It is reasonably easy for a bad program, e.g. one with a corrupt stack, to get the device stuck. Change-Id: I61317527741c45a70c390fe21adc4895510fc79f Reviewed-on: https://go-review.googlesource.com/8242 Reviewed-by: Hyang-Ah Hana Kim --- src/iostest.bash | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 src/iostest.bash diff --git a/src/iostest.bash b/src/iostest.bash new file mode 100755 index 0000000000..13f5e0cd94 --- /dev/null +++ b/src/iostest.bash @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# 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. + +# For testing darwin/arm{,64} on iOS. + +set -e +ulimit -c 0 # no core files + +if [ ! -f make.bash ]; then + echo 'iostest.bash must be run from $GOROOT/src' 1>&2 + exit 1 +fi + +if [ -z $GOOS ]; then + export GOOS=darwin +fi +if [ "$GOOS" != "darwin" ]; then + echo "iostest.bash requires GOOS=darwin, got GOOS=$GOOS" 1>&2 + exit 1 +fi +if [ "$GOARCH" == "arm" ]; then + export GOARM=7 +fi + +# Reboot to make sure previous runs do not interfere with the current run. +# It is reasonably easy for a bad program leave an iOS device in an +# almost unusable state. +idevicediagnostics restart +# Initial sleep to make sure we are restarting before we start polling. +sleep 30 +# Poll until the device has restarted. +until idevicediagnostics diagnostics; do + # TODO(crawshaw): replace with a test app using go_darwin_arm_exec. + echo "waiting for idevice to come online" + sleep 10 +done +# Diagnostics are reported during boot before the device can start an +# app. Wait a little longer before trying to use the device. +sleep 30 + +unset GOBIN +export GOROOT=$(dirname $(pwd)) +export PATH=$GOROOT/bin:$PATH +export CGO_ENABLED=1 +export CC_FOR_TARGET=$GOROOT/misc/ios/clangwrap.sh + +# Run the build for the host bootstrap, so we can build go_darwin_arm_exec. +# Also lets us fail early before the (slow) adb push if the build is broken. +./make.bash + +GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \ + -o ../bin/go_darwin_${GOARCH}_exec \ + ../misc/ios/go_darwin_arm_exec.go + +# Run standard build and tests. +./all.bash --no-clean -- 2.48.1