Index: net/test/test_server.cc |
diff --git a/net/test/test_server.cc b/net/test/test_server.cc |
index f38abfaccd421ad07d0a6cc738ccf8684961a182..324099d047a841df7a125f7f029313a3079da34e 100644 |
--- a/net/test/test_server.cc |
+++ b/net/test/test_server.cc |
@@ -98,23 +98,32 @@ TestServer::~TestServer() { |
Stop(); |
} |
+FilePath TestServer::GetTestServerDirectory() { |
+ // Get path to python server script. |
+ FilePath testserver_dir; |
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_dir)) { |
+ LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; |
+ return FilePath(); |
+ } |
+ |
+ testserver_dir = testserver_dir |
+ .Append(FILE_PATH_LITERAL("net")) |
+ .Append(FILE_PATH_LITERAL("tools")) |
+ .Append(FILE_PATH_LITERAL("testserver")); |
+ return testserver_dir; |
+} |
+ |
bool TestServer::Start() { |
if (type_ == TYPE_HTTPS) { |
if (!LoadTestRootCert()) |
return false; |
} |
- // Get path to python server script |
- FilePath testserver_path; |
- if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) { |
- LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; |
+ FilePath testserver_path(GetTestServerDirectory()); |
+ if (testserver_path.empty()) |
return false; |
- } |
- testserver_path = testserver_path |
- .Append(FILE_PATH_LITERAL("net")) |
- .Append(FILE_PATH_LITERAL("tools")) |
- .Append(FILE_PATH_LITERAL("testserver")) |
- .Append(FILE_PATH_LITERAL("testserver.py")); |
+ testserver_path = |
+ testserver_path.Append(FILE_PATH_LITERAL("testserver.py")); |
if (!SetPythonPath()) |
return false; |
@@ -283,6 +292,30 @@ void TestServer::Init(const std::string& host, const FilePath& document_root) { |
log_to_console_ = true; |
} |
+// static |
+bool TestServer::RunSyncTest() { |
+ if (!SetPythonPath()) { |
+ LOG(ERROR) << "Error trying to set python path. Exiting."; |
+ return false; |
+ } |
+ |
+ FilePath sync_test_path(GetTestServerDirectory()); |
+ if (sync_test_path.empty()) { |
+ LOG(ERROR) << "Error trying to get python test server path."; |
+ return false; |
+ } |
+ |
+ sync_test_path = |
+ sync_test_path.Append(FILE_PATH_LITERAL("chromiumsync_test.py")); |
+ CommandLine python_command(GetAbsolutePythonCommandPath()); |
+ python_command.AppendArgPath(sync_test_path); |
+ if (!base::LaunchProcess(python_command, base::LaunchOptions(), NULL)) { |
akalin
2012/03/03 01:18:32
can you add a VLOG of the final command line somew
|
+ LOG(ERROR) << "Failed to launch test script."; |
+ return false; |
+ } |
+ return true; |
+} |
+ |
bool TestServer::SetPythonPath() { |
FilePath third_party_dir; |
if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { |