aboutsummaryrefslogtreecommitdiff
path: root/misc/arm
diff options
context:
space:
mode:
authorKai Backman <kaib@golang.org>2010-04-16 13:06:45 +0300
committerKai Backman <kaib@golang.org>2010-04-16 13:06:45 +0300
commit0b2e0265ae58a4764c318fb2404f3f3dd44aa797 (patch)
treee011a4ead7cb38ba2a0c5f4a8359826615009b71 /misc/arm
parenta8c18e14ef62ce2bf043fd088f023a6d7be34bad (diff)
downloadgo-0b2e0265ae58a4764c318fb2404f3f3dd44aa797.tar.gz
go-0b2e0265ae58a4764c318fb2404f3f3dd44aa797.zip
the android runner script
this is a version synthesized from rsc's, dean's and my versions. changes and updates: - embeds the retval script and pushes a new version to the device if needed - passes arguments correctly to the program on the device - export GOARCH, GOTRACEBACK and GOGC from the local environment to the device. - added times.out support to run-arm enabled a few tests that are now passing and moved the GOGC=off workaround to run-arm. R=dpx CC=golang-dev, rsc https://golang.org/cl/880046
Diffstat (limited to 'misc/arm')
-rwxr-xr-xmisc/arm/a49
1 files changed, 49 insertions, 0 deletions
diff --git a/misc/arm/a b/misc/arm/a
new file mode 100755
index 0000000000..140b47e296
--- /dev/null
+++ b/misc/arm/a
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+
+# Copyright 2010 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.
+
+# This is a small script for executing go binaries on the android platform.
+#
+# example:
+# ./a 5.out foo bar baz
+#
+# The script exports the local values of GOARCH, GOTRACEBACK and GOGC
+# to the android environment.
+#
+# Known issues:
+# The script fails unless the last character output by the program is "\n"
+#
+# TODO(kaib): add gdb bridge support
+
+exp ()
+{
+ if [ ${!1} ]; then
+ echo "export $1=\"${!1}\"; "
+ fi
+}
+
+# adb does not correctly return the exit value of the executed program. use this
+# wrapper to manually extract the exit value
+rloc=/data/local/tmp/retval
+rsize=$(adb shell "ls -l $rloc"|tr -s ' '|cut -d' ' -f4)
+rcheck=38
+if [ $rsize != $rcheck ] ; then
+# echo "debug: retval size incorrect want $rcheck, got $rsize. uploading"
+ echo >/tmp/adb.retval '#!/system/bin/sh
+"$@"
+echo RETVAL: $?'
+ adb push /tmp/adb.retval $rloc >/dev/null 2>&1
+ adb shell chmod 755 $rloc
+fi
+
+# run the main binary
+if [ "$*" != "$1" ]; then
+ args=$(echo $*| cut -d' ' -f2-)
+fi
+adb push $1 /data/local/tmp/$1 >/dev/null 2>&1
+adb shell "$(exp GOARCH) $(exp GOTRACEBACK) $(exp GOGC) \
+ /data/local/tmp/retval /data/local/tmp/$1 $args" \
+ 2>&1|tr -d '\r' |tee /tmp/adb.out|grep -v RETVAL
+exit $(grep RETVAL /tmp/adb.out|tr -d '\n\r'| cut -d' ' -f2)