diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 22:37:35 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 22:37:35 +0000 |
commit | b89290213d94169f8293f9bd7668550975281d45 (patch) | |
tree | 951d1218d6c660cd3cf94c9c67b8c9f193a536a8 /net/socket | |
parent | 0c6da50c299be943b4c04a3953e0931734af7eaf (diff) | |
download | chromium_src-b89290213d94169f8293f9bd7668550975281d45.zip chromium_src-b89290213d94169f8293f9bd7668550975281d45.tar.gz chromium_src-b89290213d94169f8293f9bd7668550975281d45.tar.bz2 |
Speed up net_unittests a bit by re-using launched test server.
On POSIX it makes the server fork a separate process for each request for better
test isolation.
Starting with just few tests to limit impact of an eventual breakage. The results are promising.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/164522
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r-- | net/socket/ssl_test_util.cc | 6 | ||||
-rw-r--r-- | net/socket/ssl_test_util.h | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/net/socket/ssl_test_util.cc b/net/socket/ssl_test_util.cc index f6dc15e..a2874f5 100644 --- a/net/socket/ssl_test_util.cc +++ b/net/socket/ssl_test_util.cc @@ -95,6 +95,7 @@ const int TestServerLauncher::kBadHTTPSPort = 9666; const wchar_t TestServerLauncher::kCertIssuerName[] = L"Test CA"; TestServerLauncher::TestServerLauncher() : process_handle_(NULL), + forking_(false), connection_attempts_(10), connection_timeout_(1000) #if defined(OS_LINUX) @@ -107,6 +108,7 @@ TestServerLauncher::TestServerLauncher() : process_handle_(NULL), TestServerLauncher::TestServerLauncher(int connection_attempts, int connection_timeout) : process_handle_(NULL), + forking_(false), connection_attempts_(connection_attempts), connection_timeout_(connection_timeout) #if defined(OS_LINUX) @@ -222,6 +224,8 @@ bool TestServerLauncher::Start(Protocol protocol, command_line.append(file_root_url); command_line.append(L"\""); } + // Deliberately do not pass the --forking flag. It breaks the tests + // on Windows. if (!base::LaunchApp(command_line, false, true, &process_handle_)) { LOG(ERROR) << "Failed to launch " << command_line; @@ -238,6 +242,8 @@ bool TestServerLauncher::Start(Protocol protocol, command_line.push_back("-f"); if (!cert_path.value().empty()) command_line.push_back("--https=" + WideToUTF8(cert_path.ToWStringHack())); + if (forking_) + command_line.push_back("--forking"); base::file_handle_mapping_vector no_mappings; LOG(INFO) << "Trying to launch " << command_line[0] << " ..."; diff --git a/net/socket/ssl_test_util.h b/net/socket/ssl_test_util.h index ad9bbab..fb060da 100644 --- a/net/socket/ssl_test_util.h +++ b/net/socket/ssl_test_util.h @@ -37,6 +37,10 @@ class TestServerLauncher { // Load the test root cert, if it hasn't been loaded yet. bool LoadTestRootCert(); + // Tells the server to enable/disable servicing each request + // in a separate process. Takes effect only if called before Start. + void set_forking(bool forking) { forking_ = forking; } + // Start src/net/tools/testserver/testserver.py and // ask it to serve the given protocol. // If protocol is HTTP, and cert_path is not empty, serves HTTPS. @@ -106,6 +110,9 @@ class TestServerLauncher { base::ProcessHandle process_handle_; + // True if the server should handle each request in a separate process. + bool forking_; + // Number of tries and timeout for each try used for WaitToStart. int connection_attempts_; int connection_timeout_; |