summaryrefslogtreecommitdiff
path: root/test_http_server.cc
diff options
context:
space:
mode:
authorJay Srinivasan <jaysri@chromium.org>2012-07-13 12:46:49 -0700
committerGerrit <chrome-bot@google.com>2012-07-13 13:38:18 -0700
commit135a58b2cc8bd94c384625d375f0bf26252d6f07 (patch)
treeb9a3b73330dcb2ef392f9bc3bcc79d43f6e5ea73 /test_http_server.cc
parent780db2144f19d696d84b1602858b25d82d70da1f (diff)
Fixed incorrect test cleanup that causes update_engine unit tests to hang
The PythonHttpServer class has to be cleaned up always. This was not happening properly in one test (ServerDiesTest). This was causing the succeeding test (which always happened to be SimpleRedirectTest) to use the wrong server sometimes or hang forever. Adding a bunch of instrumentation in unit test code helped to figure out what's going, so leaving them in. BUG=chromium-os:32096 TEST=update engine unit tests run fine. Change-Id: Ide9a31eb411c8687ca39d78d8ebff97fe6305dbe Reviewed-on: https://gerrit.chromium.org/gerrit/27325 Commit-Ready: Jay Srinivasan <jaysri@chromium.org> Reviewed-by: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org>
Diffstat (limited to 'test_http_server.cc')
-rw-r--r--test_http_server.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/test_http_server.cc b/test_http_server.cc
index 08cf8e58..514f786e 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -248,6 +248,7 @@ inline size_t WritePayload(int fd, const off_t start_offset,
// Send an empty response, then kill the server.
void HandleQuit(int fd) {
WriteHeaders(fd, 0, 0, kHttpResponseOk);
+ LOG(INFO) << "pid(" << getpid() << "): HTTP server exiting ...";
exit(0);
}
@@ -472,6 +473,7 @@ void HandleConnection(int fd) {
ParseRequest(fd, &request);
string &url = request.url;
+ LOG(INFO) << "pid(" << getpid() << "): handling url " << url;
if (url == "/quitquitquit") {
HandleQuit(fd);
} else if (StartsWithASCII(url, "/download/", true)) {
@@ -523,17 +525,18 @@ int main(int argc, char** argv) {
if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &tr,
sizeof(int)) == -1) {
perror("setsockopt");
- exit(1);
+ exit(2);
}
}
if (bind(listen_fd, reinterpret_cast<struct sockaddr *>(&server_addr),
sizeof(server_addr)) < 0) {
perror("bind");
- exit(1);
+ exit(3);
}
CHECK_EQ(listen(listen_fd,5), 0);
while (1) {
+ LOG(INFO) << "pid(" << getpid() << "): waiting to accept new connection";
clilen = sizeof(client_addr);
int client_fd = accept(listen_fd,
(struct sockaddr *) &client_addr,