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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/port/driver.py

Issue 378113003: Modifications to layout test framework so that it can work with browser_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Layout test framework removes the temp directory that the browser test created. Created 6 years, 5 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
OLDNEW
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
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 self.start(driver_input.should_run_pixel_test, driver_input.args, int(dr iver_input.timeout))
154 test_begin_time = time.time() 154 test_begin_time = time.time()
155 self.error_from_test = str() 155 self.error_from_test = str()
156 self.err_seen_eof = False 156 self.err_seen_eof = False
157 157
158 command = self._command_from_driver_input(driver_input) 158 command = self._command_from_driver_input(driver_input)
159 deadline = test_begin_time + int(driver_input.timeout) / 1000.0 159 deadline = test_begin_time + int(driver_input.timeout) / 1000.0
160 160
161 self._server_process.write(command) 161 self._server_process.write(command)
162 text, audio = self._read_first_block(deadline) # First block is either text or audio 162 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. 163 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
258 if self._server_process is None: 258 if self._server_process is None:
259 return False 259 return False
260 if self._crashed_process_name: 260 if self._crashed_process_name:
261 return True 261 return True
262 if self._server_process.has_crashed(): 262 if self._server_process.has_crashed():
263 self._crashed_process_name = self._server_process.name() 263 self._crashed_process_name = self._server_process.name()
264 self._crashed_pid = self._server_process.pid() 264 self._crashed_pid = self._server_process.pid()
265 return True 265 return True
266 return False 266 return False
267 267
268 def start(self, pixel_tests, per_test_args): 268 def start(self, pixel_tests, per_test_args, deadline=0):
269 new_cmd_line = self.cmd_line(pixel_tests, per_test_args) 269 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: 270 if not self._server_process or new_cmd_line != self._current_cmd_line:
271 self._start(pixel_tests, per_test_args) 271 self._start(pixel_tests, per_test_args)
272 self._run_post_start_tasks() 272 self._run_post_start_tasks()
273 273
274 def _setup_environ_for_driver(self, environment): 274 def _setup_environ_for_driver(self, environment):
275 if self._profiler: 275 if self._profiler:
276 environment = self._profiler.adjusted_environment(environment) 276 environment = self._profiler.adjusted_environment(environment)
277 return environment 277 return environment
278 278
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 return (None, block.decoded_content) 408 return (None, block.decoded_content)
409 return (block.decoded_content, None) 409 return (block.decoded_content, None)
410 410
411 def _read_optional_image_block(self, deadline): 411 def _read_optional_image_block(self, deadline):
412 # returns (image, actual_image_hash) 412 # returns (image, actual_image_hash)
413 block = self._read_block(deadline, wait_for_stderr_eof=True) 413 block = self._read_block(deadline, wait_for_stderr_eof=True)
414 if block.content and block.content_type == 'image/png': 414 if block.content and block.content_type == 'image/png':
415 return (block.decoded_content, block.content_hash) 415 return (block.decoded_content, block.content_hash)
416 return (None, block.content_hash) 416 return (None, block.content_hash)
417 417
418 def _read_stdin_path(self, deadline):
419 # returns (stdin_path, bool)
420 block = self._read_block(deadline)
421 if block.stdin_path:
422 return (block.stdin_path, True)
423 return (None, False)
424
418 def _read_header(self, block, line, header_text, header_attr, header_filter= None): 425 def _read_header(self, block, line, header_text, header_attr, header_filter= None):
419 if line.startswith(header_text) and getattr(block, header_attr) is None: 426 if line.startswith(header_text) and getattr(block, header_attr) is None:
420 value = line.split()[1] 427 value = line.split()[1]
421 if header_filter: 428 if header_filter:
422 value = header_filter(value) 429 value = header_filter(value)
423 setattr(block, header_attr, value) 430 setattr(block, header_attr, value)
424 return True 431 return True
425 return False 432 return False
426 433
427 def _process_stdout_line(self, block, line): 434 def _process_stdout_line(self, block, line):
428 if (self._read_header(block, line, 'Content-Type: ', 'content_type') 435 if (self._read_header(block, line, 'Content-Type: ', 'content_type')
429 or self._read_header(block, line, 'Content-Transfer-Encoding: ', 'en coding') 436 or self._read_header(block, line, 'Content-Transfer-Encoding: ', 'en coding')
430 or self._read_header(block, line, 'Content-Length: ', '_content_leng th', int) 437 or self._read_header(block, line, 'Content-Length: ', '_content_leng th', int)
431 or self._read_header(block, line, 'ActualHash: ', 'content_hash') 438 or self._read_header(block, line, 'ActualHash: ', 'content_hash')
432 or self._read_header(block, line, 'DumpMalloc: ', 'malloc') 439 or self._read_header(block, line, 'DumpMalloc: ', 'malloc')
433 or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap')): 440 or self._read_header(block, line, 'DumpJSHeap: ', 'js_heap')
441 or self._read_header(block, line, 'StdinPath', 'stdin_path')):
434 return 442 return
435 # Note, we're not reading ExpectedHash: here, but we could. 443 # 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. 444 # If the line wasn't a header, we just append it to the content.
437 block.content += line 445 block.content += line
438 446
439 def _strip_eof(self, line): 447 def _strip_eof(self, line):
440 if line and line.endswith("#EOF\n"): 448 if line and line.endswith("#EOF\n"):
441 return line[:-5], True 449 return line[:-5], True
442 if line and line.endswith("#EOF\r\n"): 450 if line and line.endswith("#EOF\r\n"):
443 _log.error("Got a CRLF-terminated #EOF - this is a driver bug.") 451 _log.error("Got a CRLF-terminated #EOF - this is a driver bug.")
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 def __init__(self): 508 def __init__(self):
501 self.content_type = None 509 self.content_type = None
502 self.encoding = None 510 self.encoding = None
503 self.content_hash = None 511 self.content_hash = None
504 self._content_length = None 512 self._content_length = None
505 # Content is treated as binary data even though the text output is usual ly UTF-8. 513 # 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. 514 self.content = str() # FIXME: Should be bytearray() once we require Pyt hon 2.6.
507 self.decoded_content = None 515 self.decoded_content = None
508 self.malloc = None 516 self.malloc = None
509 self.js_heap = None 517 self.js_heap = None
518 self.stdin_path = None
510 519
511 def decode_content(self): 520 def decode_content(self):
512 if self.encoding == 'base64' and self.content is not None: 521 if self.encoding == 'base64' and self.content is not None:
513 self.decoded_content = base64.b64decode(self.content) 522 self.decoded_content = base64.b64decode(self.content)
514 else: 523 else:
515 self.decoded_content = self.content 524 self.decoded_content = self.content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698