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

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

Issue 2901006: Add a run_testserver executable to make it easy to run the testserver... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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
« net/net.gyp ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/run_testserver.cc
===================================================================
--- net/tools/testserver/run_testserver.cc (revision 0)
+++ net/tools/testserver/run_testserver.cc (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdio.h>
+
+#include "base/at_exit.h"
+#include "base/command_line.h"
+#include "base/message_loop.h"
+#include "net/url_request/url_request_unittest.h"
+
+static void PrintUsage() {
+ printf("run_testserver --doc-root=relpath [--http|--https|--ftp]\n");
+ printf("(NOTE: relpath should be relative to the 'src' directory)\n");
+}
+
+int main(int argc, const char* argv[]) {
+ base::AtExitManager at_exit_manager;
+ MessageLoopForIO message_loop;
+
+ // Process command line
+ CommandLine::Init(argc, argv);
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+
+ if (command_line->GetSwitchCount() == 0 ||
+ command_line->HasSwitch("help")) {
+ PrintUsage();
+ return -1;
+ }
+
+ std::string protocol;
+ int port;
+ if (command_line->HasSwitch("https")) {
+ protocol = "https";
+ port = net::TestServerLauncher::kOKHTTPSPort;
+ } else if (command_line->HasSwitch("ftp")) {
+ protocol = "ftp";
+ port = kFTPDefaultPort;
+ } else {
+ protocol = "http";
+ port = kHTTPDefaultPort;
+ }
+ std::wstring doc_root = command_line->GetSwitchValue("doc-root");
+ if (doc_root.empty()) {
+ printf("Error: --doc-root must be specified");
eroman 2010/07/09 18:36:14 typo: "Error".
+ PrintUsage();
+ return -1;
+ }
+
+ // Launch testserver
+ scoped_refptr<BaseTestServer> test_server;
+ if (protocol == "https") {
+ test_server = HTTPSTestServer::CreateGoodServer(doc_root);
+ } else if (protocol == "ftp") {
+ test_server = FTPTestServer::CreateServer(doc_root);
+ } else if (protocol == "http") {
+ test_server = HTTPTestServer::CreateServer(doc_root, NULL);
+ }
eroman 2010/07/09 18:36:14 nit: Can you add an else that is NOTREACHED() ?
+
+ printf("testserver running at %s://%s:%d (type ctrl+c to exit)\n",
+ protocol.c_str(),
eroman 2010/07/09 18:36:14 nit: Can you line this up with the open parenthesi
+ net::TestServerLauncher::kHostName,
+ port);
+
+ message_loop.Run();
+ return 0;
+}
Property changes on: net\tools\testserver\run_testserver.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« net/net.gyp ('K') | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698