diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 23:54:36 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 23:54:36 +0000 |
commit | f9ff629f7e67baf59700abceacbdfb0c6014211a (patch) | |
tree | 84e9ec6a9986f4a33b0cbc19a91188cadf3fb4b4 /net | |
parent | 3b3dff737b90daa8c30b5584d204399bf6317515 (diff) | |
download | chromium_src-f9ff629f7e67baf59700abceacbdfb0c6014211a.zip chromium_src-f9ff629f7e67baf59700abceacbdfb0c6014211a.tar.gz chromium_src-f9ff629f7e67baf59700abceacbdfb0c6014211a.tar.bz2 |
Restore run_testserver, it's needed for PPAPI and possibly others.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3310013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/net.gyp | 14 | ||||
-rw-r--r-- | net/tools/testserver/run_testserver.cc | 57 |
2 files changed, 71 insertions, 0 deletions
diff --git a/net/net.gyp b/net/net.gyp index c00ca47..1814d59 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -951,6 +951,20 @@ ], }, { + 'target_name': 'run_testserver', + 'type': 'executable', + 'dependencies': [ + 'net', + 'net_test_support', + '../base/base.gyp:base', + '../testing/gtest.gyp:gtest', + ], + 'msvs_guid': '506F2468-6B1D-48E2-A67C-9D9C6BAC0EC5', + 'sources': [ + 'tools/testserver/run_testserver.cc', + ], + }, + { 'target_name': 'net_test_support', 'type': '<(library)', 'dependencies': [ diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc new file mode 100644 index 0000000..157ce3e --- /dev/null +++ b/net/tools/testserver/run_testserver.cc @@ -0,0 +1,57 @@ +// 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/logging.h" +#include "base/message_loop.h" +#include "net/test/test_server.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; + } + + FilePath doc_root = command_line->GetSwitchValuePath("doc-root"); + if (doc_root.empty()) { + printf("Error: --doc-root must be specified\n"); + PrintUsage(); + return -1; + } + + net::TestServer::Type server_type(net::TestServer::TYPE_HTTP); + if (command_line->HasSwitch("https")) { + server_type = net::TestServer::TYPE_HTTPS; + } else if (command_line->HasSwitch("ftp")) { + server_type = net::TestServer::TYPE_FTP; + } + + net::TestServer test_server(server_type, doc_root); + if (!test_server.Start()) { + printf("Error: failed to start test server. Exiting.\n"); + return -1; + } + + printf("testserver running at %s (type ctrl+c to exit)\n", + test_server.host_port_pair().ToString().c_str()); + + message_loop.Run(); + return 0; +} |