diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 06:46:59 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 06:46:59 +0000 |
commit | 5f38d719c386c354b118224999c710a6fe22f92e (patch) | |
tree | e4e41fa80a92b0fafdaa8f51412ff3eefa005675 /net/test | |
parent | a4dd2973445111a54aebba41a3774761d8d16b67 (diff) | |
download | chromium_src-5f38d719c386c354b118224999c710a6fe22f92e.zip chromium_src-5f38d719c386c354b118224999c710a6fe22f92e.tar.gz chromium_src-5f38d719c386c354b118224999c710a6fe22f92e.tar.bz2 |
GTTF: Implement a timeout for TestServer on POSIX.
This will prevent tests from hanging when the test server fails to start.
BUG=60082
TEST=none
Review URL: http://codereview.chromium.org/4075003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/test_server_posix.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc index 6e65bcf..1456ac8 100644 --- a/net/test/test_server_posix.cc +++ b/net/test/test_server_posix.cc @@ -4,6 +4,8 @@ #include "net/test/test_server.h" +#include <poll.h> + #include <vector> #include "base/file_util.h" @@ -11,6 +13,7 @@ #include "base/process_util.h" #include "base/string_number_conversions.h" #include "base/string_util.h" +#include "base/test/test_timeouts.h" namespace { @@ -107,6 +110,19 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) { } bool TestServer::WaitToStart() { + struct pollfd poll_fds[1]; + + poll_fds[0].fd = child_fd_; + poll_fds[0].events = POLLIN | POLLPRI; + poll_fds[0].revents = 0; + + int rv = HANDLE_EINTR(poll(poll_fds, 1, + TestTimeouts::action_max_timeout_ms())); + if (rv != 1) { + LOG(ERROR) << "Failed to poll for the child file descriptor."; + return false; + } + char buf[8]; ssize_t n = HANDLE_EINTR(read(child_fd_, buf, sizeof(buf))); // We don't need the FD anymore. |