]> Cypherpunks.ru repositories - gostls13.git/commit
misc/android: improve exit code workaround
authorAustin Clements <austin@google.com>
Tue, 25 Apr 2023 23:36:16 +0000 (19:36 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 3 May 2023 14:54:58 +0000 (14:54 +0000)
commit27aa60f54018150d607287f1ad25a73079656d72
tree882171bd336868478cb289871b4b5fc26231ab2b
parent968ebb205e02ff4a1d63575a2af54e885b0ab4fc
misc/android: improve exit code workaround

go_android_exec gets the exit status of the process run inside the
Android emulator by sending a small shell script that runs the desired
command and then prints "exitcode=" followed by the exit code. This is
necessary because adb does not reliably pass through the exit status
of the subprocess.

An old bug about this
(https://code.google.com/p/android/issues/detail?id=3254) was closed
in 2016 as fixed in Android N (7.0), but it seems that the adb on the
Android builder at least still sometimes fails to pass through the
exit code.

Unfortunately, this workaround has the effect of injecting
"exitcode=N" into the output of the subprocess it runs, which messes
up tests that are looking for golden output from a subprocess.

Fix this by inserting a filter Writer that looks for the final
"exitcode=N" and strips it from the exec wrapper's own stdout.

For #15919.

This will help us in cleaning up "host tests" for #37486.

Change-Id: I9859f5b215e0ec4a7e33ada04a1857f3cfaf55ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/488975
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
misc/go_android_exec/exitcode_test.go [new file with mode: 0644]
misc/go_android_exec/main.go