Skip to content

Commit

Permalink
misc/android: make the exec wrapper exit code parsing more robust
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
Elias Naur committed Jun 8, 2016
1 parent d1b5d08 commit 09eedc3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions misc/android/go_android_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 09eedc3

Please sign in to comment.