From aa094a63e9c32261902648b380e52e8436227cea Mon Sep 17 00:00:00 2001 From: "mattm@chromium.org" Date: Wed, 7 Nov 2012 23:00:07 +0000 Subject: Try #2.1: Run safebrowsing_service_test through the net testserver code. Allows us to use ephemeral ports. (Relanding the change but with the test still disabled.) 1st review: https://chromiumcodereview.appspot.com/10073033 2nd review: https://chromiumcodereview.appspot.com/10918251 BUG=96459,119403 TBR=rsleevi@chromium.org Review URL: https://chromiumcodereview.appspot.com/11382002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166540 0039d316-1c4b-4281-b951-d872f2087c98 --- net/test/base_test_server.cc | 6 ++++++ net/test/base_test_server.h | 8 +++++++- net/test/local_sync_test_server.cc | 3 ++- net/test/local_test_server.cc | 18 ++++++++++++++---- net/test/local_test_server.h | 15 +++++++++++++-- 5 files changed, 42 insertions(+), 8 deletions(-) (limited to 'net/test') diff --git a/net/test/base_test_server.cc b/net/test/base_test_server.cc index d13d57c..9307acf 100644 --- a/net/test/base_test_server.cc +++ b/net/test/base_test_server.cc @@ -390,6 +390,12 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { base::Value::CreateIntegerValue(ssl_options_.tls_intolerant)); } } + + return GenerateAdditionalArguments(arguments); +} + +bool BaseTestServer::GenerateAdditionalArguments( + base::DictionaryValue* arguments) const { return true; } diff --git a/net/test/base_test_server.h b/net/test/base_test_server.h index 9f1290e..d343f18 100644 --- a/net/test/base_test_server.h +++ b/net/test/base_test_server.h @@ -214,7 +214,13 @@ class BaseTestServer { // Generates a DictionaryValue with the arguments for launching the external // Python test server. - bool GenerateArguments(base::DictionaryValue* arguments) const; + bool GenerateArguments(base::DictionaryValue* arguments) const + WARN_UNUSED_RESULT; + + // Subclasses can override this to add arguments that are specific to their + // own test servers. + virtual bool GenerateAdditionalArguments( + base::DictionaryValue* arguments) const WARN_UNUSED_RESULT; private: void Init(const std::string& host); diff --git a/net/test/local_sync_test_server.cc b/net/test/local_sync_test_server.cc index 8d757f8..432fde1 100644 --- a/net/test/local_sync_test_server.cc +++ b/net/test/local_sync_test_server.cc @@ -29,7 +29,8 @@ LocalSyncTestServer::~LocalSyncTestServer() {} bool LocalSyncTestServer::AddCommandLineArguments( CommandLine* command_line) const { - LocalTestServer::AddCommandLineArguments(command_line); + if (!LocalTestServer::AddCommandLineArguments(command_line)) + return false; if (xmpp_port_ != 0) { std::string xmpp_port_str = base::IntToString(xmpp_port_); command_line->AppendArg("--xmpp-port=" + xmpp_port_str); diff --git a/net/test/local_test_server.cc b/net/test/local_test_server.cc index 17137a69..53879df 100644 --- a/net/test/local_test_server.cc +++ b/net/test/local_test_server.cc @@ -94,13 +94,19 @@ bool LocalTestServer::GetTestServerDirectory(FilePath* directory) { return true; } +bool LocalTestServer::GetTestServerPath(FilePath* testserver_path) const { + if (!GetTestServerDirectory(testserver_path)) + return false; + *testserver_path = testserver_path->Append(FILE_PATH_LITERAL( + "testserver.py")); + return true; +} + bool LocalTestServer::Start() { // Get path to Python server script. FilePath testserver_path; - if (!GetTestServerDirectory(&testserver_path)) + if (!GetTestServerPath(&testserver_path)) return false; - testserver_path = - testserver_path.Append(FILE_PATH_LITERAL("testserver.py")); if (!SetPythonPath()) return false; @@ -159,8 +165,12 @@ bool LocalTestServer::Init(const FilePath& document_root) { return true; } +bool LocalTestServer::SetPythonPath() const { + return SetPythonPathStatic(); +} + // static -bool LocalTestServer::SetPythonPath() { +bool LocalTestServer::SetPythonPathStatic() { FilePath third_party_dir; if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; diff --git a/net/test/local_test_server.h b/net/test/local_test_server.h index d8d070e..3c6bdde 100644 --- a/net/test/local_test_server.h +++ b/net/test/local_test_server.h @@ -43,15 +43,26 @@ class LocalTestServer : public BaseTestServer { bool Stop(); // Modify PYTHONPATH to contain libraries we need. - static bool SetPythonPath() WARN_UNUSED_RESULT; + virtual bool SetPythonPath() const WARN_UNUSED_RESULT; + + // This is a static version so that RunSyncTest in run_testserver.cc can use + // it. + // TODO(mattm): We should refactor so this isn't necessary (crbug.com/159731). + static bool SetPythonPathStatic() WARN_UNUSED_RESULT; // Returns true if successfully stored the FilePath for the directory of the // testserver python script in |*directory|. static bool GetTestServerDirectory(FilePath* directory) WARN_UNUSED_RESULT; + // Returns true if successfully stored the FilePath for the testserver python + // script in |*testserver_path|. + virtual bool GetTestServerPath(FilePath* testserver_path) const + WARN_UNUSED_RESULT; + // Adds the command line arguments for the Python test server to // |command_line|. Returns true on success. - virtual bool AddCommandLineArguments(CommandLine* command_line) const; + virtual bool AddCommandLineArguments(CommandLine* command_line) const + WARN_UNUSED_RESULT; // Returns the actual path of document root for test cases. This function // should be called by test cases to retrieve the actual document root path. -- cgit v1.1