summaryrefslogtreecommitdiffstats
path: root/net/test/test_server.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/test/test_server.cc')
-rw-r--r--net/test/test_server.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/net/test/test_server.cc b/net/test/test_server.cc
index 4456993..36227cf 100644
--- a/net/test/test_server.cc
+++ b/net/test/test_server.cc
@@ -14,6 +14,7 @@
#include "net/base/x509_certificate.h"
#endif
+#include "base/command_line.h"
#include "base/file_util.h"
#include "base/leak_annotations.h"
#include "base/logging.h"
@@ -37,10 +38,12 @@ const int kServerConnectionAttempts = 10;
// Connection timeout in milliseconds for tests.
const int kServerConnectionTimeoutMs = 1000;
-int GetPort(net::TestServer::Type type) {
+const char kTestServerShardFlag[] = "test-server-shard";
+
+int GetPortBase(net::TestServer::Type type) {
switch (type) {
case net::TestServer::TYPE_FTP:
- return 1338;
+ return 3117;
case net::TestServer::TYPE_HTTP:
return 1337;
case net::TestServer::TYPE_HTTPS:
@@ -55,6 +58,22 @@ int GetPort(net::TestServer::Type type) {
return -1;
}
+int GetPort(net::TestServer::Type type) {
+ int port = GetPortBase(type);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(kTestServerShardFlag)) {
+ std::string shard_str(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ kTestServerShardFlag));
+ int shard = -1;
+ if (base::StringToInt(shard_str, &shard)) {
+ port += shard;
+ } else {
+ LOG(FATAL) << "Got invalid " << kTestServerShardFlag << " flag value. "
+ << "An integer is expected.";
+ }
+ }
+ return port;
+}
+
std::string GetHostname(net::TestServer::Type type) {
if (type == net::TestServer::TYPE_HTTPS_MISMATCHED_HOSTNAME) {
// Return a different hostname string that resolves to the same hostname.