aboutsummaryrefslogtreecommitdiff
path: root/misc/android
diff options
context:
space:
mode:
authorElias Naur <mail@eliasnaur.com>2019-03-02 13:07:54 +0100
committerElias Naur <mail@eliasnaur.com>2019-03-02 22:21:49 +0000
commit3de2fb21b7b4d472637f83031ec48e9bf539a4ee (patch)
treebfcdef13b85ad0f1c1b32cb1e16d4ac9358d7563 /misc/android
parente0ff4e6dc013ac18728743a43b6faa812737bdb2 (diff)
downloadgo-3de2fb21b7b4d472637f83031ec48e9bf539a4ee.tar.gz
go-3de2fb21b7b4d472637f83031ec48e9bf539a4ee.zip
misc/android: use adb exec-out instead of adb shell to avoid buffering
According to https://stackoverflow.com/questions/46233200/stop-buffering-of-adb-shell-output the adb exec-out commands avoids the buffering inherent to adb shell. Let's see if using exec-out will fix the android builder flakyness where exitcodes or output were sometimes missing. Updates #30512 (perhaps fixes it). Change-Id: Ib953ef0262b20730e0d4c332058d29c5066bfeb2 Reviewed-on: https://go-review.googlesource.com/c/164661 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'misc/android')
-rw-r--r--misc/android/go_android_exec.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/misc/android/go_android_exec.go b/misc/android/go_android_exec.go
index ffdacb3db8..166ced8d0f 100644
--- a/misc/android/go_android_exec.go
+++ b/misc/android/go_android_exec.go
@@ -75,12 +75,12 @@ func main() {
// In case we're booting a device or emulator alongside all.bash, wait for
// it to be ready. adb wait-for-device is not enough, we have to
// wait for sys.boot_completed.
- run("wait-for-device", "shell", "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;")
+ run("wait-for-device", "exec-out", "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;")
// Prepare a temporary directory that will be cleaned up at the end.
deviceGotmp := fmt.Sprintf("/data/local/tmp/%s-%d",
filepath.Base(os.Args[1]), os.Getpid())
- run("shell", "mkdir", "-p", deviceGotmp)
+ run("exec-out", "mkdir", "-p", deviceGotmp)
// Determine the package by examining the current working
// directory, which will look something like
@@ -94,7 +94,7 @@ func main() {
} else {
adbSyncGoroot()
}
- run("shell", "mkdir", "-p", deviceCwd)
+ run("exec-out", "mkdir", "-p", deviceCwd)
// Binary names can conflict.
// E.g. template.test from the {html,text}/template packages.
@@ -114,16 +114,13 @@ func main() {
for range quit {
// We don't have the PID of the running process; use the
// binary name instead.
- run("shell", "killall -QUIT "+binName)
+ run("exec-out", "killall -QUIT "+binName)
}
}()
- // The adb shell command will return an exit code of 0 regardless
- // of the command run. E.g.
- // $ adb shell false
- // $ echo $?
- // 0
+ // In light of
// https://code.google.com/p/android/issues/detail?id=3254
- // So we append the exitcode to the output and parse it from there.
+ // dont trust the exitcode of adb. Instead, append the exitcode to
+ // the output and parse it from there.
const exitstr = "exitcode="
cmd := `export TMPDIR="` + deviceGotmp + `"` +
`; export GOROOT="` + deviceGoroot + `"` +
@@ -131,11 +128,11 @@ func main() {
`; cd "` + deviceCwd + `"` +
"; '" + deviceBin + "' " + strings.Join(os.Args[2:], " ") +
"; echo -n " + exitstr + "$?"
- output := run("shell", cmd)
+ output := run("exec-out", cmd)
signal.Reset(syscall.SIGQUIT)
close(quit)
- run("shell", "rm", "-rf", deviceGotmp) // Clean up.
+ run("exec-out", "rm", "-rf", deviceGotmp) // Clean up.
exitIdx := strings.LastIndex(output, exitstr)
if exitIdx == -1 {
@@ -211,8 +208,8 @@ func adbSyncGoroot() {
return
}
devRoot := "/data/local/tmp/goroot"
- run("shell", "rm", "-rf", devRoot)
- run("shell", "mkdir", "-p", devRoot+"/pkg")
+ run("exec-out", "rm", "-rf", devRoot)
+ run("exec-out", "mkdir", "-p", devRoot+"/pkg")
goroot := runtime.GOROOT()
goCmd := filepath.Join(goroot, "bin", "go")
runtimea, err := exec.Command(goCmd, "list", "-f", "{{.Target}}", "runtime").Output()