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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 | 215 |
216 # FIXME: Seems this could just be inlined into callers. | 216 # FIXME: Seems this could just be inlined into callers. |
217 @classmethod | 217 @classmethod |
218 def _command_wrapper(cls, wrapper_option): | 218 def _command_wrapper(cls, wrapper_option): |
219 # Hook for injecting valgrind or other runtime instrumentation, | 219 # Hook for injecting valgrind or other runtime instrumentation, |
220 # used by e.g. tools/valgrind/valgrind_tests.py. | 220 # used by e.g. tools/valgrind/valgrind_tests.py. |
221 return shlex.split(wrapper_option) if wrapper_option else [] | 221 return shlex.split(wrapper_option) if wrapper_option else [] |
222 | 222 |
223 HTTP_DIR = "http/tests/" | 223 HTTP_DIR = "http/tests/" |
224 HTTP_LOCAL_DIR = "http/tests/local/" | 224 HTTP_LOCAL_DIR = "http/tests/local/" |
225 WPT_DIR = "imported/web-platform-tests/" | |
225 | 226 |
226 def is_http_test(self, test_name): | 227 def is_http_test(self, test_name): |
227 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith( self.HTTP_LOCAL_DIR) | 228 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith( self.HTTP_LOCAL_DIR) |
228 | 229 |
230 def is_wpt_test(self, test_name): | |
231 # TODO(burnik): Remove feature flag check once WPT behaves stable. | |
232 return self._port.is_wpt_enabled() and "web-platform-tests" in test_name | |
jsbell
2015/06/04 17:43:25
Use WPT_DIR here?
Dirk Pranke
2015/06/04 20:51:53
I would add an is_wpt_test() method on the port, a
burnik
2015/06/05 12:59:28
Factored out.
burnik
2015/06/05 12:59:29
Done.
| |
233 | |
234 def _get_http_host_and_ports_for_test(self, test_name): | |
235 if self.is_wpt_test(test_name): | |
236 # TODO(burnik): Read from config or args. | |
Dirk Pranke
2015/06/04 20:51:53
Do you imagine needing multiple entries here? Why
burnik
2015/06/05 12:59:28
Hardcoded is good enough for now. I believe it wou
| |
237 return ("web-platform.test", 8001, 8444) | |
238 else: | |
239 return ("127.0.0.1", 8000, 8443) | |
240 | |
229 def test_to_uri(self, test_name): | 241 def test_to_uri(self, test_name): |
230 """Convert a test name to a URI. | 242 """Convert a test name to a URI. |
231 | 243 |
232 Tests which have an 'https' directory in their paths (e.g. | 244 Tests which have an 'https' directory in their paths (e.g. |
233 '/http/tests/security/mixedContent/https/test1.html') or '.https.' in | 245 '/http/tests/security/mixedContent/https/test1.html') or '.https.' in |
234 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 |
235 be loaded over HTTPS; all other tests over HTTP. | 247 be loaded over HTTPS; all other tests over HTTP. |
236 """ | 248 """ |
237 if not self.is_http_test(test_name): | 249 is_wpt_test = self.is_wpt_test(test_name) |
250 | |
251 if not self.is_http_test(test_name) and not is_wpt_test: | |
238 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)) |
239 | 253 |
240 relative_path = test_name[len(self.HTTP_DIR):] | 254 if self.is_wpt_test(test_name): |
jsbell
2015/06/04 17:43:25
Use is_wpt_test var from above?
burnik
2015/06/05 12:59:29
Done. Forgot to commit and repush this the first t
| |
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) | |
241 | 261 |
242 if "/https/" in test_name or ".https." in test_name: | 262 if "/https/" in test_name or ".https." in test_name: |
243 return "https://127.0.0.1:8443/" + relative_path | 263 return "https://%s:%d/%s" % (hostname, secure_port, relative_path) |
244 return "http://127.0.0.1:8000/" + relative_path | 264 return "http://%s:%d/%s" % (hostname, insecure_port, relative_path) |
245 | 265 |
246 def uri_to_test(self, uri): | 266 def uri_to_test(self, uri): |
247 """Return the base layout test name for a given URI. | 267 """Return the base layout test name for a given URI. |
248 | 268 |
249 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 |
250 "file:///src/LayoutTests/fast/html/keygen.html" it would return | 270 "file:///src/LayoutTests/fast/html/keygen.html" it would return |
251 "fast/html/keygen.html". | 271 "fast/html/keygen.html". |
252 | 272 |
253 """ | 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 | |
254 if uri.startswith("file:///"): | 278 if uri.startswith("file:///"): |
255 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()) |
256 if not prefix.endswith('/'): | 280 if not prefix.endswith('/'): |
257 prefix += '/' | 281 prefix += '/' |
258 return uri[len(prefix):] | 282 return uri[len(prefix):] |
259 if uri.startswith("http://"): | 283 if uri.startswith("http://"): |
260 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) |
261 if uri.startswith("https://"): | 285 if uri.startswith("https://"): |
262 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) |
263 raise NotImplementedError('unknown url type: %s' % uri) | 287 raise NotImplementedError('unknown url type: %s' % uri) |
264 | 288 |
265 def has_crashed(self): | 289 def has_crashed(self): |
266 if self._server_process is None: | 290 if self._server_process is None: |
267 return False | 291 return False |
268 if self._crashed_process_name: | 292 if self._crashed_process_name: |
269 return True | 293 return True |
270 if self._server_process.has_crashed(): | 294 if self._server_process.has_crashed(): |
271 self._crashed_process_name = self._server_process.name() | 295 self._crashed_process_name = self._server_process.name() |
272 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... | |
380 if error_line.startswith("#LEAK - "): | 404 if error_line.startswith("#LEAK - "): |
381 self._leaked = True | 405 self._leaked = True |
382 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) | 406 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) |
383 self._leak_log = match.group(3) | 407 self._leak_log = match.group(3) |
384 return self._leaked | 408 return self._leaked |
385 | 409 |
386 def _command_from_driver_input(self, driver_input): | 410 def _command_from_driver_input(self, driver_input): |
387 # FIXME: performance tests pass in full URLs instead of test names. | 411 # FIXME: performance tests pass in full URLs instead of test names. |
388 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'): |
389 command = driver_input.test_name | 413 command = driver_input.test_name |
390 elif self.is_http_test(driver_input.test_name): | 414 elif self.is_http_test(driver_input.test_name) or self.is_wpt_test(drive r_input.test_name): |
391 command = self.test_to_uri(driver_input.test_name) | 415 command = self.test_to_uri(driver_input.test_name) |
392 else: | 416 else: |
393 command = self._port.abspath_for_test(driver_input.test_name) | 417 command = self._port.abspath_for_test(driver_input.test_name) |
394 if sys.platform == 'cygwin': | 418 if sys.platform == 'cygwin': |
395 command = path.cygpath(command) | 419 command = path.cygpath(command) |
396 | 420 |
397 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 |
398 | 422 |
399 # ' is the separator between arguments. | 423 # ' is the separator between arguments. |
400 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... | |
516 self.decoded_content = None | 540 self.decoded_content = None |
517 self.malloc = None | 541 self.malloc = None |
518 self.js_heap = None | 542 self.js_heap = None |
519 self.stdin_path = None | 543 self.stdin_path = None |
520 | 544 |
521 def decode_content(self): | 545 def decode_content(self): |
522 if self.encoding == 'base64' and self.content is not None: | 546 if self.encoding == 'base64' and self.content is not None: |
523 self.decoded_content = base64.b64decode(self.content) | 547 self.decoded_content = base64.b64decode(self.content) |
524 else: | 548 else: |
525 self.decoded_content = self.content | 549 self.decoded_content = self.content |
OLD | NEW |