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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 def run_test(self, driver_input, stop_when_done): | 143 def run_test(self, driver_input, stop_when_done): |
144 """Run a single test and return the results. | 144 """Run a single test and return the results. |
145 | 145 |
146 Note that it is okay if a test times out or crashes and leaves | 146 Note that it is okay if a test times out or crashes and leaves |
147 the driver in an indeterminate state. The upper layers of the program | 147 the driver in an indeterminate state. The upper layers of the program |
148 are responsible for cleaning up and ensuring things are okay. | 148 are responsible for cleaning up and ensuring things are okay. |
149 | 149 |
150 Returns a DriverOutput object. | 150 Returns a DriverOutput object. |
151 """ | 151 """ |
152 start_time = time.time() | 152 start_time = time.time() |
153 self.start(driver_input.should_run_pixel_test, driver_input.args) | 153 stdin_deadline = start_time + int(driver_input.timeout) / 2000.0 |
| 154 self.start(driver_input.should_run_pixel_test, driver_input.args, stdin_
deadline) |
154 test_begin_time = time.time() | 155 test_begin_time = time.time() |
155 self.error_from_test = str() | 156 self.error_from_test = str() |
156 self.err_seen_eof = False | 157 self.err_seen_eof = False |
157 | 158 |
158 command = self._command_from_driver_input(driver_input) | 159 command = self._command_from_driver_input(driver_input) |
159 deadline = test_begin_time + int(driver_input.timeout) / 1000.0 | 160 deadline = test_begin_time + int(driver_input.timeout) / 1000.0 |
160 | 161 |
161 self._server_process.write(command) | 162 self._server_process.write(command) |
162 text, audio = self._read_first_block(deadline) # First block is either
text or audio | 163 text, audio = self._read_first_block(deadline) # First block is either
text or audio |
163 image, actual_image_hash = self._read_optional_image_block(deadline) #
The second (optional) block is image data. | 164 image, actual_image_hash = self._read_optional_image_block(deadline) #
The second (optional) block is image data. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if self._server_process is None: | 259 if self._server_process is None: |
259 return False | 260 return False |
260 if self._crashed_process_name: | 261 if self._crashed_process_name: |
261 return True | 262 return True |
262 if self._server_process.has_crashed(): | 263 if self._server_process.has_crashed(): |
263 self._crashed_process_name = self._server_process.name() | 264 self._crashed_process_name = self._server_process.name() |
264 self._crashed_pid = self._server_process.pid() | 265 self._crashed_pid = self._server_process.pid() |
265 return True | 266 return True |
266 return False | 267 return False |
267 | 268 |
268 def start(self, pixel_tests, per_test_args): | 269 def start(self, pixel_tests, per_test_args, deadline): |
269 new_cmd_line = self.cmd_line(pixel_tests, per_test_args) | 270 new_cmd_line = self.cmd_line(pixel_tests, per_test_args) |
270 if not self._server_process or new_cmd_line != self._current_cmd_line: | 271 if not self._server_process or new_cmd_line != self._current_cmd_line: |
271 self._start(pixel_tests, per_test_args) | 272 self._start(pixel_tests, per_test_args) |
272 self._run_post_start_tasks() | 273 self._run_post_start_tasks() |
273 | 274 |
274 def _setup_environ_for_driver(self, environment): | 275 def _setup_environ_for_driver(self, environment): |
275 if self._profiler: | 276 if self._profiler: |
276 environment = self._profiler.adjusted_environment(environment) | 277 environment = self._profiler.adjusted_environment(environment) |
277 return environment | 278 return environment |
278 | 279 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 setattr(block, header_attr, value) | 424 setattr(block, header_attr, value) |
424 return True | 425 return True |
425 return False | 426 return False |
426 | 427 |
427 def _process_stdout_line(self, block, line): | 428 def _process_stdout_line(self, block, line): |
428 if (self._read_header(block, line, 'Content-Type: ', 'content_type') | 429 if (self._read_header(block, line, 'Content-Type: ', 'content_type') |
429 or self._read_header(block, line, 'Content-Transfer-Encoding: ', 'en
coding') | 430 or self._read_header(block, line, 'Content-Transfer-Encoding: ', 'en
coding') |
430 or self._read_header(block, line, 'Content-Length: ', '_content_leng
th', int) | 431 or self._read_header(block, line, 'Content-Length: ', '_content_leng
th', int) |
431 or self._read_header(block, line, 'ActualHash: ', 'content_hash') | 432 or self._read_header(block, line, 'ActualHash: ', 'content_hash') |
432 or self._read_header(block, line, 'DumpMalloc: ', 'malloc') | 433 or self._read_header(block, line, 'DumpMalloc: ', 'malloc') |
433 or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap')): | 434 or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap') |
| 435 or self._read_header(block, line, 'StdinPath', 'stdin_path')): |
434 return | 436 return |
435 # Note, we're not reading ExpectedHash: here, but we could. | 437 # Note, we're not reading ExpectedHash: here, but we could. |
436 # If the line wasn't a header, we just append it to the content. | 438 # If the line wasn't a header, we just append it to the content. |
437 block.content += line | 439 block.content += line |
438 | 440 |
439 def _strip_eof(self, line): | 441 def _strip_eof(self, line): |
440 if line and line.endswith("#EOF\n"): | 442 if line and line.endswith("#EOF\n"): |
441 return line[:-5], True | 443 return line[:-5], True |
442 if line and line.endswith("#EOF\r\n"): | 444 if line and line.endswith("#EOF\r\n"): |
443 _log.error("Got a CRLF-terminated #EOF - this is a driver bug.") | 445 _log.error("Got a CRLF-terminated #EOF - this is a driver bug.") |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 def __init__(self): | 502 def __init__(self): |
501 self.content_type = None | 503 self.content_type = None |
502 self.encoding = None | 504 self.encoding = None |
503 self.content_hash = None | 505 self.content_hash = None |
504 self._content_length = None | 506 self._content_length = None |
505 # Content is treated as binary data even though the text output is usual
ly UTF-8. | 507 # Content is treated as binary data even though the text output is usual
ly UTF-8. |
506 self.content = str() # FIXME: Should be bytearray() once we require Pyt
hon 2.6. | 508 self.content = str() # FIXME: Should be bytearray() once we require Pyt
hon 2.6. |
507 self.decoded_content = None | 509 self.decoded_content = None |
508 self.malloc = None | 510 self.malloc = None |
509 self.js_heap = None | 511 self.js_heap = None |
| 512 self.stdin_path = None |
510 | 513 |
511 def decode_content(self): | 514 def decode_content(self): |
512 if self.encoding == 'base64' and self.content is not None: | 515 if self.encoding == 'base64' and self.content is not None: |
513 self.decoded_content = base64.b64decode(self.content) | 516 self.decoded_content = base64.b64decode(self.content) |
514 else: | 517 else: |
515 self.decoded_content = self.content | 518 self.decoded_content = self.content |
OLD | NEW |