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

Side by Side Diff: net/test/test_server.cc

Issue 9545019: Add "run_testserver --sync-test" for easy chromiumsync_test.py launching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/test/test_server.h ('k') | net/test/test_server_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/test/test_server.h" 5 #include "net/test/test_server.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 Init(host, document_root); 92 Init(host, document_root);
93 } 93 }
94 94
95 TestServer::~TestServer() { 95 TestServer::~TestServer() {
96 TestRootCerts* root_certs = TestRootCerts::GetInstance(); 96 TestRootCerts* root_certs = TestRootCerts::GetInstance();
97 root_certs->Clear(); 97 root_certs->Clear();
98 Stop(); 98 Stop();
99 } 99 }
100 100
101 FilePath TestServer::GetTestServerDirectory() {
102 // Get path to python server script.
103 FilePath testserver_dir;
104 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_dir)) {
105 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
106 return FilePath();
107 }
108
109 testserver_dir = testserver_dir
110 .Append(FILE_PATH_LITERAL("net"))
111 .Append(FILE_PATH_LITERAL("tools"))
112 .Append(FILE_PATH_LITERAL("testserver"));
113 return testserver_dir;
114 }
115
101 bool TestServer::Start() { 116 bool TestServer::Start() {
102 if (type_ == TYPE_HTTPS) { 117 if (type_ == TYPE_HTTPS) {
103 if (!LoadTestRootCert()) 118 if (!LoadTestRootCert())
104 return false; 119 return false;
105 } 120 }
106 121
107 // Get path to python server script 122 FilePath testserver_path(GetTestServerDirectory());
108 FilePath testserver_path; 123 if (testserver_path.empty())
109 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) {
110 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
111 return false; 124 return false;
112 } 125 testserver_path =
113 testserver_path = testserver_path 126 testserver_path.Append(FILE_PATH_LITERAL("testserver.py"));
114 .Append(FILE_PATH_LITERAL("net"))
115 .Append(FILE_PATH_LITERAL("tools"))
116 .Append(FILE_PATH_LITERAL("testserver"))
117 .Append(FILE_PATH_LITERAL("testserver.py"));
118 127
119 if (!SetPythonPath()) 128 if (!SetPythonPath())
120 return false; 129 return false;
121 130
122 if (!LaunchPython(testserver_path)) 131 if (!LaunchPython(testserver_path))
123 return false; 132 return false;
124 133
125 if (!WaitToStart()) { 134 if (!WaitToStart()) {
126 Stop(); 135 Stop();
127 return false; 136 return false;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 certificates_dir_ = src_dir.Append(FILE_PATH_LITERAL("net")) 285 certificates_dir_ = src_dir.Append(FILE_PATH_LITERAL("net"))
277 .Append(FILE_PATH_LITERAL("data")) 286 .Append(FILE_PATH_LITERAL("data"))
278 .Append(FILE_PATH_LITERAL("ssl")) 287 .Append(FILE_PATH_LITERAL("ssl"))
279 .Append(FILE_PATH_LITERAL("certificates")); 288 .Append(FILE_PATH_LITERAL("certificates"));
280 289
281 // TODO(battre) Remove this after figuring out why the TestServer is flaky. 290 // TODO(battre) Remove this after figuring out why the TestServer is flaky.
282 // http://crbug.com/96594 291 // http://crbug.com/96594
283 log_to_console_ = true; 292 log_to_console_ = true;
284 } 293 }
285 294
295 // static
296 bool TestServer::RunSyncTest() {
297 if (!SetPythonPath()) {
298 LOG(ERROR) << "Error trying to set python path. Exiting.";
299 return false;
300 }
301
302 FilePath sync_test_path(GetTestServerDirectory());
303 if (sync_test_path.empty()) {
304 LOG(ERROR) << "Error trying to get python test server path.";
305 return false;
306 }
307
308 sync_test_path =
309 sync_test_path.Append(FILE_PATH_LITERAL("chromiumsync_test.py"));
310 CommandLine python_command(GetAbsolutePythonCommandPath());
311 python_command.AppendArgPath(sync_test_path);
312 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
313 LOG(ERROR) << "Failed to launch test script.";
314 return false;
315 }
316 return true;
317 }
318
286 bool TestServer::SetPythonPath() { 319 bool TestServer::SetPythonPath() {
287 FilePath third_party_dir; 320 FilePath third_party_dir;
288 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { 321 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) {
289 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; 322 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
290 return false; 323 return false;
291 } 324 }
292 third_party_dir = third_party_dir.AppendASCII("third_party"); 325 third_party_dir = third_party_dir.AppendASCII("third_party");
293 326
294 // For simplejson. (simplejson, unlike all the other python modules 327 // For simplejson. (simplejson, unlike all the other python modules
295 // we include, doesn't have an extra 'simplejson' directory, so we 328 // we include, doesn't have an extra 'simplejson' directory, so we
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 command_line->AppendArg(kBulkCipherSwitch + "=3des"); 445 command_line->AppendArg(kBulkCipherSwitch + "=3des");
413 446
414 if (https_options_.record_resume) 447 if (https_options_.record_resume)
415 command_line->AppendArg("--https-record-resume"); 448 command_line->AppendArg("--https-record-resume");
416 } 449 }
417 450
418 return true; 451 return true;
419 } 452 }
420 453
421 } // namespace net 454 } // namespace net
OLDNEW
« no previous file with comments | « net/test/test_server.h ('k') | net/test/test_server_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698