aboutsummaryrefslogtreecommitdiff
path: root/misc/android
diff options
context:
space:
mode:
authorElias Naur <elias.naur@gmail.com>2016-06-03 11:41:26 +0200
committerElias Naur <elias.naur@gmail.com>2016-06-08 05:24:53 +0000
commit09eedc32e13484d9171519e9f07f3210ba5a7afd (patch)
tree4476ac77b7e9aae612346e6f7d7e70aa771fd8fb /misc/android
parentd1b5d08f341cbc702e1d2a3cd86ab1ad93a90c41 (diff)
downloadgo-09eedc32e13484d9171519e9f07f3210ba5a7afd.tar.gz
go-09eedc32e13484d9171519e9f07f3210ba5a7afd.zip
misc/android: make the exec wrapper exit code parsing more robust
Before, the Android exec wrapper expected the trailing exit code output on its own line, like this: PASS exitcode=0 However, some tests can sometimes squeeze in some output after the test harness outputs "PASS" and the newline. The TestWriteHeapDumpFinalizers test is particularly prone to this, since its finalizers println to standard out. When it happens, the output looks like this: PASS finalizedexitcode=0 Two recent failures caused by this race: https://build.golang.org/log/185605e1b936142c22350eef22d20e982be53c29 https://build.golang.org/log/e61cf6a050551d10360bd90be3c5f58c3eb07605 Since the "exitcode=" string is always echoed after the test output, the fix is simple: instead of looking for the last newline in the output, look for the last exitcode string instead. Change-Id: Icd6e53855eeba60b982ad3108289d92549328b86 Reviewed-on: https://go-review.googlesource.com/23750 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'misc/android')
-rw-r--r--misc/android/go_android_exec.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/misc/android/go_android_exec.go b/misc/android/go_android_exec.go
index 6db38c2cc5..ebff845154 100644
--- a/misc/android/go_android_exec.go
+++ b/misc/android/go_android_exec.go
@@ -91,11 +91,11 @@ func main() {
run("shell", "rm", "-rf", deviceGotmp) // Clean up.
- output = output[strings.LastIndex(output, "\n")+1:]
- if !strings.HasPrefix(output, exitstr) {
+ exitIdx := strings.LastIndex(output, exitstr)
+ if exitIdx == -1 {
log.Fatalf("no exit code: %q", output)
}
- code, err := strconv.Atoi(output[len(exitstr):])
+ code, err := strconv.Atoi(output[exitIdx+len(exitstr):])
if err != nil {
log.Fatalf("bad exit code: %v", err)
}