Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Unified Diff: net/tools/testserver/run_testserver.cc

Issue 10388206: [sync] Add --port and --xmpp-port parameters to run_testserver.cc (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile with OVERRIDE Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/testserver/run_testserver.cc
diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc
index f00f9f2d2b5730d59886b047c36f49a983ce55d5..74cc727bf7047497a1b89f164fe65862f5759364 100644
--- a/net/tools/testserver/run_testserver.cc
+++ b/net/tools/testserver/run_testserver.cc
@@ -11,14 +11,18 @@
#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/test/test_timeouts.h"
+#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "net/test/python_utils.h"
#include "net/test/test_server.h"
+#include "net/test/local_sync_test_server.h"
static void PrintUsage() {
printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"
- " [--https-cert=ok|mismatched-name|expired]\n");
- printf("(NOTE: relpath should be relative to the 'src' directory)\n");
+ " [--https-cert=ok|mismatched-name|expired]\n"
+ " [--port=<port>] [--xmpp-port=<xmpp_port>]\n");
+ printf("(NOTE: relpath should be relative to the 'src' directory.\n");
+ printf(" --port and --xmpp-port only work with the --sync flag.)\n");
}
// Launches the chromiumsync_test script, testing the --sync functionality.
@@ -87,6 +91,20 @@ int main(int argc, const char* argv[]) {
return RunSyncTest() ? 0 : -1;
}
+ std::string port_str = "0";
akalin 2012/05/23 05:29:21 move port_str inside the if statement and don't in
Raghu Simha 2012/05/23 06:02:59 Done.
+ int port_int = 0;
+ if (command_line->HasSwitch("port")) {
+ port_str = command_line->GetSwitchValueASCII("port");
+ base::StringToInt(port_str, &port_int);
+ }
+
+ std::string xmpp_port_str = "0";
+ int xmpp_port_int = 0;
+ if (command_line->HasSwitch("xmpp-port")) {
+ xmpp_port_str = command_line->GetSwitchValueASCII("xmpp-port");
+ base::StringToInt(xmpp_port_str, &xmpp_port_int);
+ }
+
net::TestServer::HTTPSOptions https_options;
if (command_line->HasSwitch("https-cert")) {
server_type = net::TestServer::TYPE_HTTPS;
@@ -114,12 +132,20 @@ int main(int argc, const char* argv[]) {
}
scoped_ptr<net::TestServer> test_server;
- if (server_type == net::TestServer::TYPE_HTTPS)
- test_server.reset(new net::TestServer(https_options, doc_root));
- else
- test_server.reset(new net::TestServer(server_type,
- net::TestServer::kLocalhost,
- doc_root));
+ switch (server_type) {
+ case net::TestServer::TYPE_HTTPS:
+ test_server.reset(new net::TestServer(https_options, doc_root));
+ break;
+ case net::TestServer::TYPE_SYNC:
+ test_server.reset(new net::LocalSyncTestServer((uint16) port_int,
akalin 2012/05/23 05:29:21 prefer static_cast<uint16>()
akalin 2012/05/23 05:29:21 in fact, you can probably stick the int parsing co
Raghu Simha 2012/05/23 06:02:59 Done.
Raghu Simha 2012/05/23 06:02:59 Done. Moved to a separate function. Added braces i
+ (uint16) xmpp_port_int));
+ break;
+ default:
+ test_server.reset(new net::TestServer(server_type,
+ net::TestServer::kLocalhost,
+ doc_root));
+ break;
+ }
if (!test_server->Start()) {
printf("Error: failed to start test server. Exiting.\n");

Powered by Google App Engine
This is Rietveld 408576698