| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 403 |
| 404 def _check_for_leak(self, error_line): | 404 def _check_for_leak(self, error_line): |
| 405 if error_line.startswith("#LEAK - "): | 405 if error_line.startswith("#LEAK - "): |
| 406 self._leaked = True | 406 self._leaked = True |
| 407 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) | 407 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) |
| 408 self._leak_log = match.group(3) | 408 self._leak_log = match.group(3) |
| 409 return self._leaked | 409 return self._leaked |
| 410 | 410 |
| 411 def _command_from_driver_input(self, driver_input): | 411 def _command_from_driver_input(self, driver_input): |
| 412 # FIXME: performance tests pass in full URLs instead of test names. | 412 # FIXME: performance tests pass in full URLs instead of test names. |
| 413 if driver_input.test_name.startswith('http://') or driver_input.test_nam
e.startswith('https://') or driver_input.test_name == ('about:blank'): | 413 if driver_input.test_name.startswith( |
| 414 'http://') or driver_input.test_name.startswith('https://') or d
river_input.test_name == ('about:blank'): |
| 414 command = driver_input.test_name | 415 command = driver_input.test_name |
| 415 elif self.is_http_test(driver_input.test_name) or self._should_treat_as_
wpt_test(driver_input.test_name): | 416 elif self.is_http_test(driver_input.test_name) or self._should_treat_as_
wpt_test(driver_input.test_name): |
| 416 command = self.test_to_uri(driver_input.test_name) | 417 command = self.test_to_uri(driver_input.test_name) |
| 417 else: | 418 else: |
| 418 command = self._port.abspath_for_test(driver_input.test_name) | 419 command = self._port.abspath_for_test(driver_input.test_name) |
| 419 if sys.platform == 'cygwin': | 420 if sys.platform == 'cygwin': |
| 420 command = path.cygpath(command) | 421 command = path.cygpath(command) |
| 421 | 422 |
| 422 assert not driver_input.image_hash or driver_input.should_run_pixel_test | 423 assert not driver_input.image_hash or driver_input.should_run_pixel_test |
| 423 | 424 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 452 if line.startswith(header_text) and getattr(block, header_attr) is None: | 453 if line.startswith(header_text) and getattr(block, header_attr) is None: |
| 453 value = line.split()[1] | 454 value = line.split()[1] |
| 454 if header_filter: | 455 if header_filter: |
| 455 value = header_filter(value) | 456 value = header_filter(value) |
| 456 setattr(block, header_attr, value) | 457 setattr(block, header_attr, value) |
| 457 return True | 458 return True |
| 458 return False | 459 return False |
| 459 | 460 |
| 460 def _process_stdout_line(self, block, line): | 461 def _process_stdout_line(self, block, line): |
| 461 if (self._read_header(block, line, 'Content-Type: ', 'content_type') | 462 if (self._read_header(block, line, 'Content-Type: ', 'content_type') |
| 462 or self._read_header(block, line, 'Content-Transfer-Encoding: ', 'en
coding') | 463 or self._read_header(block, line, 'Content-Transfer-Encoding: ',
'encoding') |
| 463 or self._read_header(block, line, 'Content-Length: ', '_content_leng
th', int) | 464 or self._read_header(block, line, 'Content-Length: ', '_content_
length', int) |
| 464 or self._read_header(block, line, 'ActualHash: ', 'content_hash') | 465 or self._read_header(block, line, 'ActualHash: ', 'content_hash'
) |
| 465 or self._read_header(block, line, 'DumpMalloc: ', 'malloc') | 466 or self._read_header(block, line, 'DumpMalloc: ', 'malloc') |
| 466 or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap') | 467 or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap') |
| 467 or self._read_header(block, line, 'StdinPath', 'stdin_path')): | 468 or self._read_header(block, line, 'StdinPath', 'stdin_path')): |
| 468 return | 469 return |
| 469 # Note, we're not reading ExpectedHash: here, but we could. | 470 # Note, we're not reading ExpectedHash: here, but we could. |
| 470 # If the line wasn't a header, we just append it to the content. | 471 # If the line wasn't a header, we just append it to the content. |
| 471 block.content += line | 472 block.content += line |
| 472 | 473 |
| 473 def _strip_eof(self, line): | 474 def _strip_eof(self, line): |
| 474 if line and line.endswith("#EOF\n"): | 475 if line and line.endswith("#EOF\n"): |
| 475 return line[:-5], True | 476 return line[:-5], True |
| 476 if line and line.endswith("#EOF\r\n"): | 477 if line and line.endswith("#EOF\r\n"): |
| 477 _log.error("Got a CRLF-terminated #EOF - this is a driver bug.") | 478 _log.error("Got a CRLF-terminated #EOF - this is a driver bug.") |
| (...skipping 22 matching lines...) Expand all Loading... |
| 500 | 501 |
| 501 if out_line: | 502 if out_line: |
| 502 assert not out_seen_eof | 503 assert not out_seen_eof |
| 503 out_line, out_seen_eof = self._strip_eof(out_line) | 504 out_line, out_seen_eof = self._strip_eof(out_line) |
| 504 if err_line: | 505 if err_line: |
| 505 assert not self.err_seen_eof | 506 assert not self.err_seen_eof |
| 506 err_line, self.err_seen_eof = self._strip_eof(err_line) | 507 err_line, self.err_seen_eof = self._strip_eof(err_line) |
| 507 | 508 |
| 508 if out_line: | 509 if out_line: |
| 509 if out_line[-1] != "\n": | 510 if out_line[-1] != "\n": |
| 510 _log.error("Last character read from DRT stdout line was not
a newline! This indicates either a NRWT or DRT bug.") | 511 _log.error( |
| 512 "Last character read from DRT stdout line was not a newl
ine! This indicates either a NRWT or DRT bug.") |
| 511 content_length_before_header_check = block._content_length | 513 content_length_before_header_check = block._content_length |
| 512 self._process_stdout_line(block, out_line) | 514 self._process_stdout_line(block, out_line) |
| 513 # FIXME: Unlike HTTP, DRT dumps the content right after printing
a Content-Length header. | 515 # FIXME: Unlike HTTP, DRT dumps the content right after printing
a Content-Length header. |
| 514 # Don't wait until we're done with headers, just read the binary
blob right now. | 516 # Don't wait until we're done with headers, just read the binary
blob right now. |
| 515 if content_length_before_header_check != block._content_length: | 517 if content_length_before_header_check != block._content_length: |
| 516 if block._content_length > 0: | 518 if block._content_length > 0: |
| 517 block.content = self._server_process.read_stdout(deadlin
e, block._content_length) | 519 block.content = self._server_process.read_stdout(deadlin
e, block._content_length) |
| 518 else: | 520 else: |
| 519 _log.error("Received content of type %s with Content-Len
gth of 0! This indicates a bug in %s.", | 521 _log.error("Received content of type %s with Content-Len
gth of 0! This indicates a bug in %s.", |
| 520 block.content_type, self._server_process.name
()) | 522 block.content_type, self._server_process.name
()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 542 self.decoded_content = None | 544 self.decoded_content = None |
| 543 self.malloc = None | 545 self.malloc = None |
| 544 self.js_heap = None | 546 self.js_heap = None |
| 545 self.stdin_path = None | 547 self.stdin_path = None |
| 546 | 548 |
| 547 def decode_content(self): | 549 def decode_content(self): |
| 548 if self.encoding == 'base64' and self.content is not None: | 550 if self.encoding == 'base64' and self.content is not None: |
| 549 self.decoded_content = base64.b64decode(self.content) | 551 self.decoded_content = base64.b64decode(self.content) |
| 550 else: | 552 else: |
| 551 self.decoded_content = self.content | 553 self.decoded_content = self.content |
| OLD | NEW |