blob: 5e0989485200380d4a648f6934750db84485a63c [file] [log] [blame]
David Crawshawdd952442015-03-30 08:47:07 -04001#!/usr/bin/env bash
2# Copyright 2015 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# For testing darwin/arm{,64} on iOS.
7
8set -e
9ulimit -c 0 # no core files
10
11if [ ! -f make.bash ]; then
12 echo 'iostest.bash must be run from $GOROOT/src' 1>&2
13 exit 1
14fi
15
16if [ -z $GOOS ]; then
17 export GOOS=darwin
18fi
19if [ "$GOOS" != "darwin" ]; then
20 echo "iostest.bash requires GOOS=darwin, got GOOS=$GOOS" 1>&2
21 exit 1
22fi
Josh Bleecher Snyderc45f4b72015-04-03 11:02:32 -070023if [ "$GOARCH" != "arm" ] && [ "$GOARCH" != "arm64" ]; then
24 echo "iostest.bash requires GOARCH=arm or GOARCH=arm64, got GOARCH=$GOARCH" 1>&2
25 exit 1
26fi
David Crawshawdd952442015-03-30 08:47:07 -040027if [ "$GOARCH" == "arm" ]; then
28 export GOARM=7
29fi
30
Josh Bleecher Snyder4af5dcb2015-04-13 09:30:56 -070031if [ "$1" == "-restart" ]; then
32 # Reboot to make sure previous runs do not interfere with the current run.
33 # It is reasonably easy for a bad program leave an iOS device in an
34 # almost unusable state.
35 idevicediagnostics restart
36 # Initial sleep to make sure we are restarting before we start polling.
37 sleep 30
38 # Poll until the device has restarted.
39 until idevicediagnostics diagnostics; do
40 # TODO(crawshaw): replace with a test app using go_darwin_arm_exec.
41 echo "waiting for idevice to come online"
42 sleep 10
43 done
44 # Diagnostics are reported during boot before the device can start an
45 # app. Wait a little longer before trying to use the device.
46 sleep 30
47fi
David Crawshawdd952442015-03-30 08:47:07 -040048
49unset GOBIN
50export GOROOT=$(dirname $(pwd))
51export PATH=$GOROOT/bin:$PATH
52export CGO_ENABLED=1
53export CC_FOR_TARGET=$GOROOT/misc/ios/clangwrap.sh
54
55# Run the build for the host bootstrap, so we can build go_darwin_arm_exec.
Josh Bleecher Snyder4af5dcb2015-04-13 09:30:56 -070056# Also lets us fail early before the (slow) ios-deploy if the build is broken.
David Crawshawdd952442015-03-30 08:47:07 -040057./make.bash
58
59GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
60 -o ../bin/go_darwin_${GOARCH}_exec \
61 ../misc/ios/go_darwin_arm_exec.go
62
David Crawshawbfd441f2015-04-15 15:03:41 -040063if [ "$GOIOS_DEV_ID" == "" ]; then
64 echo "detecting iOS development identity"
65 eval $(GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go run ../misc/ios/detect.go)
66fi
67
David Crawshawdd952442015-03-30 08:47:07 -040068# Run standard build and tests.
69./all.bash --no-clean