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

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

Issue 10073033: Run safebrowsing_service_test through the net testserver code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: specify absolute path to safe_browsing_test datafile Created 8 years, 4 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
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/local_test_server.h" 5 #include "net/test/local_test_server.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 testserver_dir = testserver_dir 88 testserver_dir = testserver_dir
89 .Append(FILE_PATH_LITERAL("net")) 89 .Append(FILE_PATH_LITERAL("net"))
90 .Append(FILE_PATH_LITERAL("tools")) 90 .Append(FILE_PATH_LITERAL("tools"))
91 .Append(FILE_PATH_LITERAL("testserver")); 91 .Append(FILE_PATH_LITERAL("testserver"));
92 *directory = testserver_dir; 92 *directory = testserver_dir;
93 return true; 93 return true;
94 } 94 }
95 95
96 bool LocalTestServer::GetTestServerPath(FilePath* testserver_path) const {
97 if (!GetTestServerDirectory(testserver_path))
98 return false;
99 *testserver_path = testserver_path->Append(FILE_PATH_LITERAL(
100 "testserver.py"));
101 return true;
102 }
103
96 bool LocalTestServer::Start() { 104 bool LocalTestServer::Start() {
97 // Get path to Python server script. 105 // Get path to Python server script.
98 FilePath testserver_path; 106 FilePath testserver_path;
99 if (!GetTestServerDirectory(&testserver_path)) 107 if (!GetTestServerPath(&testserver_path))
100 return false; 108 return false;
101 testserver_path =
102 testserver_path.Append(FILE_PATH_LITERAL("testserver.py"));
103 109
104 if (!SetPythonPath()) 110 if (!SetPythonPath())
105 return false; 111 return false;
106 112
107 if (!LaunchPython(testserver_path)) 113 if (!LaunchPython(testserver_path))
108 return false; 114 return false;
109 115
110 if (!WaitToStart()) { 116 if (!WaitToStart()) {
111 Stop(); 117 Stop();
112 return false; 118 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) 157 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
152 return false; 158 return false;
153 SetResourcePath(src_dir.Append(document_root), 159 SetResourcePath(src_dir.Append(document_root),
154 src_dir.AppendASCII("net") 160 src_dir.AppendASCII("net")
155 .AppendASCII("data") 161 .AppendASCII("data")
156 .AppendASCII("ssl") 162 .AppendASCII("ssl")
157 .AppendASCII("certificates")); 163 .AppendASCII("certificates"));
158 return true; 164 return true;
159 } 165 }
160 166
167 bool LocalTestServer::SetPythonPath() const {
168 return SetPythonPathStatic();
169 }
170
161 // static 171 // static
162 bool LocalTestServer::SetPythonPath() { 172 bool LocalTestServer::SetPythonPathStatic() {
163 FilePath third_party_dir; 173 FilePath third_party_dir;
164 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { 174 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) {
165 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; 175 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
166 return false; 176 return false;
167 } 177 }
168 third_party_dir = third_party_dir.AppendASCII("third_party"); 178 third_party_dir = third_party_dir.AppendASCII("third_party");
169 179
170 // For simplejson. (simplejson, unlike all the other Python modules 180 // For simplejson. (simplejson, unlike all the other Python modules
171 // we include, doesn't have an extra 'simplejson' directory, so we 181 // we include, doesn't have an extra 'simplejson' directory, so we
172 // need to include its parent directory, i.e. third_party_dir). 182 // need to include its parent directory, i.e. third_party_dir).
(...skipping 14 matching lines...) Expand all
187 AppendToPythonPath(pyproto_dir); 197 AppendToPythonPath(pyproto_dir);
188 AppendToPythonPath(pyproto_dir.AppendASCII("sync").AppendASCII("protocol")); 198 AppendToPythonPath(pyproto_dir.AppendASCII("sync").AppendASCII("protocol"));
189 AppendToPythonPath(pyproto_dir.AppendASCII("chrome") 199 AppendToPythonPath(pyproto_dir.AppendASCII("chrome")
190 .AppendASCII("browser") 200 .AppendASCII("browser")
191 .AppendASCII("policy") 201 .AppendASCII("policy")
192 .AppendASCII("proto")); 202 .AppendASCII("proto"));
193 203
194 return true; 204 return true;
195 } 205 }
196 206
207 void LocalTestServer::AddPythonArguments(const FilePath& testserver_path,
208 CommandLine* command_line) const {
209 // Make python stdout and stderr unbuffered, to prevent incomplete stderr on
210 // win bots, and also fix mixed up ordering of stdout and stderr.
211 command_line->AppendSwitch("-u");
212
213 command_line->AppendArgPath(testserver_path);
214 }
215
197 bool LocalTestServer::AddCommandLineArguments(CommandLine* command_line) const { 216 bool LocalTestServer::AddCommandLineArguments(CommandLine* command_line) const {
198 base::DictionaryValue arguments_dict; 217 base::DictionaryValue arguments_dict;
199 if (!GenerateArguments(&arguments_dict)) 218 if (!GenerateArguments(&arguments_dict))
200 return false; 219 return false;
201 220
202 // Serialize the argument dictionary into CommandLine. 221 // Serialize the argument dictionary into CommandLine.
203 for (DictionaryValue::Iterator it(arguments_dict); it.HasNext(); 222 for (DictionaryValue::Iterator it(arguments_dict); it.HasNext();
204 it.Advance()) { 223 it.Advance()) {
205 const base::Value& value = it.value(); 224 const base::Value& value = it.value();
206 const std::string& key = it.key(); 225 const std::string& key = it.key();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 break; 263 break;
245 default: 264 default:
246 NOTREACHED(); 265 NOTREACHED();
247 return false; 266 return false;
248 } 267 }
249 268
250 return true; 269 return true;
251 } 270 }
252 271
253 } // namespace net 272 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698