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>
diff --git a/test_http_server.cc b/test_http_server.cc
index 08cf8e5..514f786 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -248,6 +248,7 @@
// 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 @@
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 @@
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,