OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 # FIXME: Seems this could just be inlined into callers. | 217 # FIXME: Seems this could just be inlined into callers. |
218 @classmethod | 218 @classmethod |
219 def _command_wrapper(cls, wrapper_option): | 219 def _command_wrapper(cls, wrapper_option): |
220 # Hook for injecting valgrind or other runtime instrumentation, | 220 # Hook for injecting valgrind or other runtime instrumentation, |
221 # used by e.g. tools/valgrind/valgrind_tests.py. | 221 # used by e.g. tools/valgrind/valgrind_tests.py. |
222 return shlex.split(wrapper_option) if wrapper_option else [] | 222 return shlex.split(wrapper_option) if wrapper_option else [] |
223 | 223 |
224 HTTP_DIR = "http/tests/" | 224 HTTP_DIR = "http/tests/" |
225 HTTP_LOCAL_DIR = "http/tests/local/" | 225 HTTP_LOCAL_DIR = "http/tests/local/" |
| 226 WPT_DIR = "imported/web-platform-tests/" |
226 | 227 |
227 def is_http_test(self, test_name): | 228 def is_http_test(self, test_name): |
228 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith(
self.HTTP_LOCAL_DIR) | 229 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith(
self.HTTP_LOCAL_DIR) |
229 | 230 |
| 231 def _should_treat_as_wpt_test(self, test_name): |
| 232 return self._port.is_wpt_enabled() and self._port.is_wpt_test(test_name) |
| 233 |
| 234 def _get_http_host_and_ports_for_test(self, test_name): |
| 235 if self._should_treat_as_wpt_test(test_name): |
| 236 # TODO(burnik): Read from config or args. |
| 237 return ("web-platform.test", 8001, 8444) |
| 238 else: |
| 239 return ("127.0.0.1", 8000, 8443) |
| 240 |
230 def test_to_uri(self, test_name): | 241 def test_to_uri(self, test_name): |
231 """Convert a test name to a URI. | 242 """Convert a test name to a URI. |
232 | 243 |
233 Tests which have an 'https' directory in their paths (e.g. | 244 Tests which have an 'https' directory in their paths (e.g. |
234 '/http/tests/security/mixedContent/https/test1.html') or '.https.' in | 245 '/http/tests/security/mixedContent/https/test1.html') or '.https.' in |
235 their name (e.g. 'http/tests/security/mixedContent/test1.https.html') wi
ll | 246 their name (e.g. 'http/tests/security/mixedContent/test1.https.html') wi
ll |
236 be loaded over HTTPS; all other tests over HTTP. | 247 be loaded over HTTPS; all other tests over HTTP. |
237 """ | 248 """ |
238 if not self.is_http_test(test_name): | 249 is_wpt_test = self._should_treat_as_wpt_test(test_name) |
| 250 |
| 251 if not self.is_http_test(test_name) and not is_wpt_test: |
239 return path.abspath_to_uri(self._port.host.platform, self._port.absp
ath_for_test(test_name)) | 252 return path.abspath_to_uri(self._port.host.platform, self._port.absp
ath_for_test(test_name)) |
240 | 253 |
241 relative_path = test_name[len(self.HTTP_DIR):] | 254 if is_wpt_test: |
| 255 test_dir_prefix = self.WPT_DIR |
| 256 else: |
| 257 test_dir_prefix = self.HTTP_DIR |
| 258 |
| 259 relative_path = test_name[len(test_dir_prefix):] |
| 260 hostname, insecure_port, secure_port = self._get_http_host_and_ports_for
_test(test_name) |
242 | 261 |
243 if "/https/" in test_name or ".https." in test_name: | 262 if "/https/" in test_name or ".https." in test_name: |
244 return "https://127.0.0.1:8443/" + relative_path | 263 return "https://%s:%d/%s" % (hostname, secure_port, relative_path) |
245 return "http://127.0.0.1:8000/" + relative_path | 264 return "http://%s:%d/%s" % (hostname, insecure_port, relative_path) |
246 | 265 |
247 def uri_to_test(self, uri): | 266 def uri_to_test(self, uri): |
248 """Return the base layout test name for a given URI. | 267 """Return the base layout test name for a given URI. |
249 | 268 |
250 This returns the test name for a given URI, e.g., if you passed in | 269 This returns the test name for a given URI, e.g., if you passed in |
251 "file:///src/LayoutTests/fast/html/keygen.html" it would return | 270 "file:///src/LayoutTests/fast/html/keygen.html" it would return |
252 "fast/html/keygen.html". | 271 "fast/html/keygen.html". |
253 | 272 |
254 """ | 273 """ |
| 274 |
| 275 # This looks like a bit of a hack, since the uri is used instead of test
name. |
| 276 hostname, insecure_port, secure_port = self._get_http_host_and_ports_for
_test(uri) |
| 277 |
255 if uri.startswith("file:///"): | 278 if uri.startswith("file:///"): |
256 prefix = path.abspath_to_uri(self._port.host.platform, self._port.la
yout_tests_dir()) | 279 prefix = path.abspath_to_uri(self._port.host.platform, self._port.la
yout_tests_dir()) |
257 if not prefix.endswith('/'): | 280 if not prefix.endswith('/'): |
258 prefix += '/' | 281 prefix += '/' |
259 return uri[len(prefix):] | 282 return uri[len(prefix):] |
260 if uri.startswith("http://"): | 283 if uri.startswith("http://"): |
261 return uri.replace('http://127.0.0.1:8000/', self.HTTP_DIR) | 284 return uri.replace('http://%s:%d/' % (hostname, insecure_port), self
.HTTP_DIR) |
262 if uri.startswith("https://"): | 285 if uri.startswith("https://"): |
263 return uri.replace('https://127.0.0.1:8443/', self.HTTP_DIR) | 286 return uri.replace('https://%s:%d/' % (hostname, secure_port), self.
HTTP_DIR) |
264 raise NotImplementedError('unknown url type: %s' % uri) | 287 raise NotImplementedError('unknown url type: %s' % uri) |
265 | 288 |
266 def has_crashed(self): | 289 def has_crashed(self): |
267 if self._server_process is None: | 290 if self._server_process is None: |
268 return False | 291 return False |
269 if self._crashed_process_name: | 292 if self._crashed_process_name: |
270 return True | 293 return True |
271 if self._server_process.has_crashed(): | 294 if self._server_process.has_crashed(): |
272 self._crashed_process_name = self._server_process.name() | 295 self._crashed_process_name = self._server_process.name() |
273 self._crashed_pid = self._server_process.pid() | 296 self._crashed_pid = self._server_process.pid() |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if error_line.startswith("#LEAK - "): | 404 if error_line.startswith("#LEAK - "): |
382 self._leaked = True | 405 self._leaked = True |
383 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) | 406 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) |
384 self._leak_log = match.group(3) | 407 self._leak_log = match.group(3) |
385 return self._leaked | 408 return self._leaked |
386 | 409 |
387 def _command_from_driver_input(self, driver_input): | 410 def _command_from_driver_input(self, driver_input): |
388 # FIXME: performance tests pass in full URLs instead of test names. | 411 # FIXME: performance tests pass in full URLs instead of test names. |
389 if driver_input.test_name.startswith('http://') or driver_input.test_nam
e.startswith('https://') or driver_input.test_name == ('about:blank'): | 412 if driver_input.test_name.startswith('http://') or driver_input.test_nam
e.startswith('https://') or driver_input.test_name == ('about:blank'): |
390 command = driver_input.test_name | 413 command = driver_input.test_name |
391 elif self.is_http_test(driver_input.test_name): | 414 elif self.is_http_test(driver_input.test_name) or self._should_treat_as_
wpt_test(driver_input.test_name): |
392 command = self.test_to_uri(driver_input.test_name) | 415 command = self.test_to_uri(driver_input.test_name) |
393 else: | 416 else: |
394 command = self._port.abspath_for_test(driver_input.test_name) | 417 command = self._port.abspath_for_test(driver_input.test_name) |
395 if sys.platform == 'cygwin': | 418 if sys.platform == 'cygwin': |
396 command = path.cygpath(command) | 419 command = path.cygpath(command) |
397 | 420 |
398 assert not driver_input.image_hash or driver_input.should_run_pixel_test | 421 assert not driver_input.image_hash or driver_input.should_run_pixel_test |
399 | 422 |
400 # ' is the separator between arguments. | 423 # ' is the separator between arguments. |
401 if self._port.supports_per_test_timeout(): | 424 if self._port.supports_per_test_timeout(): |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 self.decoded_content = None | 540 self.decoded_content = None |
518 self.malloc = None | 541 self.malloc = None |
519 self.js_heap = None | 542 self.js_heap = None |
520 self.stdin_path = None | 543 self.stdin_path = None |
521 | 544 |
522 def decode_content(self): | 545 def decode_content(self): |
523 if self.encoding == 'base64' and self.content is not None: | 546 if self.encoding == 'base64' and self.content is not None: |
524 self.decoded_content = base64.b64decode(self.content) | 547 self.decoded_content = base64.b64decode(self.content) |
525 else: | 548 else: |
526 self.decoded_content = self.content | 549 self.decoded_content = self.content |
OLD | NEW |