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

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 nits 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..d6ef6e7ea1a09a8062f68981fe21f98695ca8d11 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"
Paweł Hajdan Jr. 2012/05/23 06:53:02 nit: Sort.
Raghu Simha 2012/05/23 19:54:28 Done.
#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"
Paweł Hajdan Jr. 2012/05/23 06:53:02 nit: Sort.
Raghu Simha 2012/05/23 19:54:28 Done.
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");
Paweł Hajdan Jr. 2012/05/23 06:53:02 Please add code to error out when those switches a
Raghu Simha 2012/05/23 19:54:28 Done.
}
// Launches the chromiumsync_test script, testing the --sync functionality.
@@ -51,6 +55,20 @@ static bool RunSyncTest() {
return true;
}
+// Gets a port value from the switch with name |switch_name|.
+static uint16 GetPortFromSwitch(const std::string& switch_name) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ int port_int = 0;
+ if (command_line->HasSwitch(switch_name)) {
+ std::string port_str = command_line->GetSwitchValueASCII(switch_name);
+ if (!base::StringToInt(port_str, &port_int)) {
+ LOG(WARNING) << "Could not extract port from switch " << switch_name;
Paweł Hajdan Jr. 2012/05/23 06:53:02 How about making the function return bool success,
Raghu Simha 2012/05/23 19:54:28 Done.
+ return 0;
+ }
+ }
+ return static_cast<uint16>(port_int);
+}
+
int main(int argc, const char* argv[]) {
base::AtExitManager at_exit_manager;
MessageLoopForIO message_loop;
@@ -114,12 +132,23 @@ 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: {
akalin 2012/05/23 06:16:49 usual style is to leave the braces out unless nece
Paweł Hajdan Jr. 2012/05/23 06:53:02 +1, please do
Raghu Simha 2012/05/23 19:54:28 Moot.
Raghu Simha 2012/05/23 19:54:28 Moot.
+ test_server.reset(new net::TestServer(https_options, doc_root));
+ break;
+ }
+ case net::TestServer::TYPE_SYNC: {
+ test_server.reset(new net::LocalSyncTestServer(
+ GetPortFromSwitch("port"), GetPortFromSwitch("xmpp-port")));
+ 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