]> git.lizzy.rs Git - rust.git/commit
compiletest: Fix flaky Android gdb test runs
authorAlex Crichton <alex@alexcrichton.com>
Fri, 6 Jan 2017 18:26:40 +0000 (10:26 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 6 Jan 2017 18:26:40 +0000 (10:26 -0800)
commit9ced90164ced03af42d6813710b38f1e0c0f2ecc
tree325ae77d144070c3868bee7237a87170289ed4bb
parent8f62c2920077eb5cb81323142fc5dbe6ae8813c0
compiletest: Fix flaky Android gdb test runs

Local testing showed that I was able to reproduce an error where debuginfo tests
on Android would fail with "connection reset by peer". Further investigation
turned out that the gdb tests are android with bit of process management:

* First an `adb forward` command is run to ensure that the host's port 5039 is
  the same as the emulator's.
* Next an `adb shell` command is run to execute the `gdbserver` executable
  inside the emulator. This gdb server will attach to port 5039 and listen for
  remote gdb debugging sessions.
* Finally, we run `gdb` on the host (not in the emulator) and then connect to
  this gdb server to send it commands.

The problem was happening when the host's gdb was failing to connect to the
remote gdbserver running inside the emulator. The previous test for this was
that after `adb shell` executed we'd sleep for a second and then attempt to make
a TCP connection to port 5039. If successful we'd run gdb and on failure we'd
sleep again.

It turns out, however, that as soon as we've executed `adb forward` all TCP
connections to 5039 will succeed. This means that we would only ever sleep for
at most one second, and if this wasn't enough time we'd just fail later because
we would assume that gdbserver had started but it may not have done so yet.

This commit fixes these issues by removing the TCP connection to test if
gdbserver is ready to go. Instead we read the stdout of the process and wait for
it to print that it's listening at which point we start running gdb. I've found
that locally at least I was unable to reproduce the failure after these changes.

Closes #38710
src/tools/compiletest/src/procsrv.rs
src/tools/compiletest/src/runtest.rs