File: iostest.bash

package info (click to toggle)
golang-1.11 1.11.12-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, experimental, sid
  • size: 107,360 kB
  • sloc: asm: 88,993; ansic: 8,174; perl: 2,007; sh: 1,804; xml: 623; python: 346; makefile: 123; cpp: 22; f90: 8; awk: 7
file content (73 lines) | stat: -rwxr-xr-x 2,116 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/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" ] && [ "$GOARCH" != "arm64" ]; then
	echo "iostest.bash requires GOARCH=arm or GOARCH=arm64, got GOARCH=$GOARCH" 1>&2
	exit 1
fi
if [ "$GOARCH" = "arm" ]; then
	export GOARM=7
fi

if [ "$1" = "-restart" ]; then
	# 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.
	IDEVARGS=
	if [ -n "$GOIOS_DEVICE_ID" ]; then
		IDEVARGS="-u $GOIOS_DEVICE_ID"
	fi
	idevicediagnostics $IDEVARGS restart
	# Initial sleep to make sure we are restarting before we start polling.
	sleep 30
	# Poll until the device has restarted.
	until idevicediagnostics $IDEVARGS 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
fi

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) ios-deploy 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

if [ "$GOIOS_DEV_ID" = "" ]; then
	echo "detecting iOS development identity"
	eval $(GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go run ../misc/ios/detect.go)
fi

# Run standard tests.
bash run.bash --no-rebuild