aboutsummaryrefslogtreecommitdiff
path: root/src/androidtest.bash
diff options
context:
space:
mode:
authorHyang-Ah (Hana) Kim <hyangah@gmail.com>2015-07-17 15:40:26 -0400
committerHyang-Ah Hana Kim <hyangah@gmail.com>2015-07-17 21:12:12 +0000
commita81c6563525521a116582b93a4a95f3e8a6ceec9 (patch)
tree1647d276f5acd89840389846cd0b9e408a261b6d /src/androidtest.bash
parentebb67836f9dfec6016a1fb7922872cb0c1c0d4bc (diff)
downloadgo-a81c6563525521a116582b93a4a95f3e8a6ceec9.tar.xz
androidtest.bash: robust cleanup in case of failure.
Change-Id: I69ed001bca4987e08b46a8288f6feae2aca6a142 Reviewed-on: https://go-review.googlesource.com/12380 Reviewed-by: David Crawshaw <crawshaw@golang.org>
Diffstat (limited to 'src/androidtest.bash')
-rwxr-xr-xsrc/androidtest.bash13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/androidtest.bash b/src/androidtest.bash
index 39e73c350b..0010738614 100755
--- a/src/androidtest.bash
+++ b/src/androidtest.bash
@@ -35,6 +35,13 @@ GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
-o ../bin/go_android_${GOARCH}_exec \
../misc/android/go_android_exec.go
+export ANDROID_TEST_DIR=/tmp/androidtest-$$
+
+function cleanup() {
+ rm -rf ${ANDROID_TEST_DIR}
+}
+trap cleanup EXIT
+
# Push GOROOT to target device.
#
# The adb sync command will sync either the /system or /data
@@ -42,7 +49,7 @@ GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
# on the host. We copy the files required for running tests under
# /data/local/tmp/goroot. The adb sync command does not follow
# symlinks so we have to copy.
-export ANDROID_PRODUCT_OUT=/tmp/androidtest-$$
+export ANDROID_PRODUCT_OUT="${ANDROID_TEST_DIR}/out"
FAKE_GOROOT=$ANDROID_PRODUCT_OUT/data/local/tmp/goroot
mkdir -p $FAKE_GOROOT
mkdir -p $FAKE_GOROOT/pkg
@@ -54,17 +61,15 @@ echo '# Syncing test files to android device'
adb shell mkdir -p /data/local/tmp/goroot
time adb sync data &> /dev/null
-export CLEANER=/tmp/androidcleaner-$$
+export CLEANER=${ANDROID_TEST_DIR}/androidcleaner-$$
cp ../misc/android/cleaner.go $CLEANER.go
echo 'var files = `' >> $CLEANER.go
(cd $ANDROID_PRODUCT_OUT/data/local/tmp/goroot; find . >> $CLEANER.go)
echo '`' >> $CLEANER.go
go build -o $CLEANER $CLEANER.go
adb push $CLEANER /data/local/tmp/cleaner
-rm $CLEANER $CLEANER.go
adb shell /data/local/tmp/cleaner
-rm -rf "$ANDROID_PRODUCT_OUT"
echo ''
# Run standard tests.