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

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

Issue 148153009: DOM-object leak detection at run_webkit_tests.py (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 # "#CRASHED - PROCESSNAME". Since those can happen at any time 106 # "#CRASHED - PROCESSNAME". Since those can happen at any time
107 # and ServerProcess won't be aware of them (since the actual tool 107 # and ServerProcess won't be aware of them (since the actual tool
108 # didn't crash, just a subprocess) we record the crashed subprocess name here. 108 # didn't crash, just a subprocess) we record the crashed subprocess name here.
109 self._crashed_process_name = None 109 self._crashed_process_name = None
110 self._crashed_pid = None 110 self._crashed_pid = None
111 111
112 # WebKitTestRunner can report back subprocesses that became unresponsive 112 # WebKitTestRunner can report back subprocesses that became unresponsive
113 # This could mean they crashed. 113 # This could mean they crashed.
114 self._subprocess_was_unresponsive = False 114 self._subprocess_was_unresponsive = False
115 115
116 # WebKitTestRunenr can report back subprocess DOM-object leaks by printi ng
Dirk Pranke 2014/01/28 20:11:46 WebKitTestRunner doesn't exist in Blink :) I'd pro
hajimehoshi 2014/02/14 10:18:59 Done.
117 # "#LEAK". This leak detection is enabled only when the flag
118 # --enable-leak-detection is passed to content_shell.
119 self._leaked = False
120
116 # stderr reading is scoped on a per-test (not per-block) basis, so we st ore the accumulated 121 # stderr reading is scoped on a per-test (not per-block) basis, so we st ore the accumulated
117 # stderr output, as well as if we've seen #EOF on this driver instance. 122 # stderr output, as well as if we've seen #EOF on this driver instance.
118 # FIXME: We should probably remove _read_first_block and _read_optional_ image_block and 123 # FIXME: We should probably remove _read_first_block and _read_optional_ image_block and
119 # instead scope these locally in run_test. 124 # instead scope these locally in run_test.
120 self.error_from_test = str() 125 self.error_from_test = str()
121 self.err_seen_eof = False 126 self.err_seen_eof = False
122 self._server_process = None 127 self._server_process = None
123 self._current_cmd_line = None 128 self._current_cmd_line = None
124 129
125 self._measurements = {} 130 self._measurements = {}
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if crashed: 178 if crashed:
174 self.error_from_test, crash_log = self._get_crash_log(text, self.err or_from_test, newer_than=start_time) 179 self.error_from_test, crash_log = self._get_crash_log(text, self.err or_from_test, newer_than=start_time)
175 180
176 # If we don't find a crash log use a placeholder error message inste ad. 181 # If we don't find a crash log use a placeholder error message inste ad.
177 if not crash_log: 182 if not crash_log:
178 pid_str = str(self._crashed_pid) if self._crashed_pid else "unkn own pid" 183 pid_str = str(self._crashed_pid) if self._crashed_pid else "unkn own pid"
179 crash_log = 'No crash log found for %s:%s.\n' % (self._crashed_p rocess_name, pid_str) 184 crash_log = 'No crash log found for %s:%s.\n' % (self._crashed_p rocess_name, pid_str)
180 # If we were unresponsive append a message informing there may n ot have been a crash. 185 # If we were unresponsive append a message informing there may n ot have been a crash.
181 if self._subprocess_was_unresponsive: 186 if self._subprocess_was_unresponsive:
182 crash_log += 'Process failed to become responsive before tim ing out.\n' 187 crash_log += 'Process failed to become responsive before tim ing out.\n'
188 if self._leaked:
189 crash_log += 'DOM-object leaking was detected.\n'
Dirk Pranke 2014/01/30 01:43:21 Given that the process isn't actually crashing, it
hajimehoshi 2014/02/14 10:18:59 Done.
183 190
184 # Print stdout and stderr to the placeholder crash log; we want as much context as possible. 191 # Print stdout and stderr to the placeholder crash log; we want as much context as possible.
185 if self.error_from_test: 192 if self.error_from_test:
186 crash_log += '\nstdout:\n%s\nstderr:\n%s\n' % (text, self.er ror_from_test) 193 crash_log += '\nstdout:\n%s\nstderr:\n%s\n' % (text, self.er ror_from_test)
187 194
188 return DriverOutput(text, image, actual_image_hash, audio, 195 return DriverOutput(text, image, actual_image_hash, audio,
189 crash=crashed, test_time=time.time() - test_begin_time, measurements =self._measurements, 196 crash=crashed, test_time=time.time() - test_begin_time, measurements =self._measurements,
190 timeout=timed_out, error=self.error_from_test, 197 timeout=timed_out, error=self.error_from_test,
191 crashed_process_name=self._crashed_process_name, 198 crashed_process_name=self._crashed_process_name,
192 crashed_pid=self._crashed_pid, crash_log=crash_log, pid=pid) 199 crashed_pid=self._crashed_pid, crash_log=crash_log, pid=pid)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 320
314 self._current_cmd_line = None 321 self._current_cmd_line = None
315 322
316 def cmd_line(self, pixel_tests, per_test_args): 323 def cmd_line(self, pixel_tests, per_test_args):
317 cmd = self._command_wrapper(self._port.get_option('wrapper')) 324 cmd = self._command_wrapper(self._port.get_option('wrapper'))
318 cmd.append(self._port._path_to_driver()) 325 cmd.append(self._port._path_to_driver())
319 if self._no_timeout: 326 if self._no_timeout:
320 cmd.append('--no-timeout') 327 cmd.append('--no-timeout')
321 cmd.extend(self._port.get_option('additional_drt_flag', [])) 328 cmd.extend(self._port.get_option('additional_drt_flag', []))
322 cmd.extend(self._port.additional_drt_flag()) 329 cmd.extend(self._port.additional_drt_flag())
330 if self._port.get_option('enable_leak_detection'):
331 cmd.append('--enable-leak-detection')
323 cmd.extend(per_test_args) 332 cmd.extend(per_test_args)
324 cmd.append('-') 333 cmd.append('-')
325 return cmd 334 return cmd
326 335
327 def _check_for_driver_crash(self, error_line): 336 def _check_for_driver_crash(self, error_line):
328 if error_line == "#CRASHED\n": 337 if error_line == "#CRASHED\n":
329 # This is used on Windows to report that the process has crashed 338 # This is used on Windows to report that the process has crashed
330 # See http://trac.webkit.org/changeset/65537. 339 # See http://trac.webkit.org/changeset/65537.
331 self._crashed_process_name = self._server_process.name() 340 self._crashed_process_name = self._server_process.name()
332 self._crashed_pid = self._server_process.pid() 341 self._crashed_pid = self._server_process.pid()
333 elif (error_line.startswith("#CRASHED - ") 342 elif (error_line.startswith("#CRASHED - ")
334 or error_line.startswith("#PROCESS UNRESPONSIVE - ")): 343 or error_line.startswith("#PROCESS UNRESPONSIVE - ")
344 or error_line.startswith("#LEAK - ")):
Dirk Pranke 2014/01/30 01:43:21 See comments above.
hajimehoshi 2014/02/14 10:18:59 Done.
335 # WebKitTestRunner uses this to report that the WebProcess subproces s crashed. 345 # WebKitTestRunner uses this to report that the WebProcess subproces s crashed.
336 match = re.match('#(?:CRASHED|PROCESS UNRESPONSIVE) - (\S+)', error_ line) 346 match = re.match('#(?:CRASHED|PROCESS UNRESPONSIVE|LEAK) - (\S+)', e rror_line)
337 self._crashed_process_name = match.group(1) if match else 'WebProces s' 347 self._crashed_process_name = match.group(1) if match else 'WebProces s'
338 match = re.search('pid (\d+)', error_line) 348 match = re.search('pid (\d+)', error_line)
339 pid = int(match.group(1)) if match else None 349 pid = int(match.group(1)) if match else None
340 self._crashed_pid = pid 350 self._crashed_pid = pid
341 # FIXME: delete this after we're sure this code is working :) 351 # FIXME: delete this after we're sure this code is working :)
342 _log.debug('%s crash, pid = %s, error_line = %s' % (self._crashed_pr ocess_name, str(pid), error_line)) 352 _log.debug('%s crash, pid = %s, error_line = %s' % (self._crashed_pr ocess_name, str(pid), error_line))
343 if error_line.startswith("#PROCESS UNRESPONSIVE - "): 353 if error_line.startswith("#PROCESS UNRESPONSIVE - "):
344 self._subprocess_was_unresponsive = True 354 self._subprocess_was_unresponsive = True
345 self._port.sample_process(self._crashed_process_name, self._cras hed_pid) 355 self._port.sample_process(self._crashed_process_name, self._cras hed_pid)
346 # We want to show this since it's not a regular crash and probab ly we don't have a crash log. 356 # We want to show this since it's not a regular crash and probab ly we don't have a crash log.
347 self.error_from_test += error_line 357 self.error_from_test += error_line
358 elif error_line.startswith("#LEAK - "):
359 self._leaked = True
360 self.error_from_test += error_line
348 return True 361 return True
349 return self.has_crashed() 362 return self.has_crashed()
350 363
351 def _command_from_driver_input(self, driver_input): 364 def _command_from_driver_input(self, driver_input):
352 # FIXME: performance tests pass in full URLs instead of test names. 365 # FIXME: performance tests pass in full URLs instead of test names.
353 if driver_input.test_name.startswith('http://') or driver_input.test_nam e.startswith('https://') or driver_input.test_name == ('about:blank'): 366 if driver_input.test_name.startswith('http://') or driver_input.test_nam e.startswith('https://') or driver_input.test_name == ('about:blank'):
354 command = driver_input.test_name 367 command = driver_input.test_name
355 elif self.is_http_test(driver_input.test_name): 368 elif self.is_http_test(driver_input.test_name):
356 command = self.test_to_uri(driver_input.test_name) 369 command = self.test_to_uri(driver_input.test_name)
357 else: 370 else:
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 self.content = str() # FIXME: Should be bytearray() once we require Pyt hon 2.6. 490 self.content = str() # FIXME: Should be bytearray() once we require Pyt hon 2.6.
478 self.decoded_content = None 491 self.decoded_content = None
479 self.malloc = None 492 self.malloc = None
480 self.js_heap = None 493 self.js_heap = None
481 494
482 def decode_content(self): 495 def decode_content(self):
483 if self.encoding == 'base64' and self.content is not None: 496 if self.encoding == 'base64' and self.content is not None:
484 self.decoded_content = base64.b64decode(self.content) 497 self.decoded_content = base64.b64decode(self.content)
485 else: 498 else:
486 self.decoded_content = self.content 499 self.decoded_content = self.content
OLDNEW
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698