WebKit Bugzilla
Attachment 360017 Details for
Bug 193772
: run-webkit-tests should check for leaks in WebKit processes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Hack to make rwt --leaks work on com.apple.WebKit.*.Development processes
rdar-46526680-ddk-hack-v1.diff (text/plain), 7.83 KB, created by
David Kilzer (:ddkilzer)
on 2019-01-24 09:29:26 PST
(
hide
)
Description:
Hack to make rwt --leaks work on com.apple.WebKit.*.Development processes
Filename:
MIME Type:
Creator:
David Kilzer (:ddkilzer)
Created:
2019-01-24 09:29:26 PST
Size:
7.83 KB
patch
obsolete
>diff --git a/Tools/Scripts/webkitpy/common/system/abstractexecutive.py b/Tools/Scripts/webkitpy/common/system/abstractexecutive.py >index ec6604efd45..f5600f61e82 100644 >--- a/Tools/Scripts/webkitpy/common/system/abstractexecutive.py >+++ b/Tools/Scripts/webkitpy/common/system/abstractexecutive.py >@@ -74,7 +74,7 @@ class AbstractExecutive(object): > if not process_name_filter: > process_name_filter = lambda process_name: True > >- running_pids = self.running_pids(process_name_filter) >+ running_pids, undef = self.running_pids(process_name_filter) > if not running_pids: > return > pid = running_pids[-1] >diff --git a/Tools/Scripts/webkitpy/common/system/executive.py b/Tools/Scripts/webkitpy/common/system/executive.py >index 77cbce8594a..07ade58a7e8 100644 >--- a/Tools/Scripts/webkitpy/common/system/executive.py >+++ b/Tools/Scripts/webkitpy/common/system/executive.py >@@ -268,12 +268,13 @@ class Executive(AbstractExecutive): > def running_pids(self, process_name_filter=None): > if self._is_native_win: > # FIXME: running_pids isn't implemented on native Windows yet... >- return [] >+ return [], [] > > if not process_name_filter: > process_name_filter = lambda process_name: True > > running_pids = [] >+ running_names = [] > if self._is_cygwin: > ps_process = self.run_command(['ps', '-e'], ignore_errors=True) > for line in ps_process.splitlines(): >@@ -282,6 +283,7 @@ class Executive(AbstractExecutive): > pid, ppid, pgid, winpid, tty, uid, stime, process_name = tokens > if process_name_filter(process_name): > running_pids.append(int(pid)) >+ running_names.append(os.path.basename(process_name)) > self.pid_to_system_pid[int(pid)] = int(winpid) > except ValueError as e: > pass >@@ -295,10 +297,11 @@ class Executive(AbstractExecutive): > pid, process_name = line.strip().split(' ', 1) > if process_name_filter(process_name): > running_pids.append(int(pid)) >+ running_names.append(os.path.basename(process_name)) > except ValueError as e: > pass > >- return sorted(running_pids) >+ return running_pids, running_names > > def _windows_image_name(self, process_name): > name, extension = os.path.splitext(process_name) >diff --git a/Tools/Scripts/webkitpy/common/system/executive_mock.py b/Tools/Scripts/webkitpy/common/system/executive_mock.py >index dc063adfe4b..d6d5db8e01b 100644 >--- a/Tools/Scripts/webkitpy/common/system/executive_mock.py >+++ b/Tools/Scripts/webkitpy/common/system/executive_mock.py >@@ -82,12 +82,15 @@ class MockExecutive(object): > > def running_pids(self, process_name_filter): > running_pids = [] >+ running_names = [] > for process_name, process_pid in self._running_pids.iteritems(): > if process_name_filter(process_name): > running_pids.append(process_pid) >+ running_names.append(process_name) > > _log.info("MOCK running_pids: %s" % running_pids) >- return running_pids >+ _log.info("MOCK running_names: %s" % running_names) >+ return running_pids, running_names > > def run_and_throw_if_fail(self, args, quiet=False, cwd=None, env=None): > if self._should_log: >diff --git a/Tools/Scripts/webkitpy/common/system/executive_unittest.py b/Tools/Scripts/webkitpy/common/system/executive_unittest.py >index 78900e79d88..30cded63443 100644 >--- a/Tools/Scripts/webkitpy/common/system/executive_unittest.py >+++ b/Tools/Scripts/webkitpy/common/system/executive_unittest.py >@@ -231,8 +231,9 @@ class ExecutiveTest(unittest.TestCase): > return # This function isn't implemented on Windows yet. > > executive = Executive() >- pids = executive.running_pids() >+ pids, names = executive.running_pids() > self.assertIn(os.getpid(), pids) >+ self.assertIn(os.path.basename(sys.executable), names) > > def serial_test_run_in_parallel(self): > # We run this test serially to avoid overloading the machine and throwing off the timing. >diff --git a/Tools/Scripts/webkitpy/port/darwin.py b/Tools/Scripts/webkitpy/port/darwin.py >index 7833f2e4f79..85d4f5150b4 100644 >--- a/Tools/Scripts/webkitpy/port/darwin.py >+++ b/Tools/Scripts/webkitpy/port/darwin.py >@@ -22,6 +22,7 @@ > > import logging > import os >+import re > import time > > from webkitpy.common.memoized import memoized >@@ -60,7 +61,16 @@ class DarwinPort(ApplePort): > if not self.get_option('leaks'): > return > # We could use http://code.google.com/p/psutil/ to get the process_name from the pid. >- self._leak_detector.check_for_leaks(process_name, process_pid) >+ if self.get_option('webkit_test_runner'): >+ # FIXME: This assumes no other processes spawning WebKit2 processes are running. >+ webkit_process_re = re.compile('.*/com\.apple\.WebKit\.\S+\.Development$') >+ process_name_filter = lambda process_name: re.match(webkit_process_re, process_name) >+ process_ids, process_names = self._executive.running_pids(process_name_filter) or [] >+ process_ids.insert(0, process_pid) >+ process_names.insert(0, process_name) >+ self._leak_detector.check_for_leaks(process_names, process_ids) >+ else: >+ self._leak_detector.check_for_leaks(process_name, process_pid) > > def print_leaks_summary(self): > if not self.get_option('leaks'): >diff --git a/Tools/Scripts/webkitpy/port/leakdetector.py b/Tools/Scripts/webkitpy/port/leakdetector.py >index d07e0959e90..a1ec21c7c57 100644 >--- a/Tools/Scripts/webkitpy/port/leakdetector.py >+++ b/Tools/Scripts/webkitpy/port/leakdetector.py >@@ -118,14 +118,19 @@ class LeakDetector(object): > > def check_for_leaks(self, process_name, process_pid): > _log.debug("Checking for leaks in %s" % process_name) >+ pids = process_pid if isinstance(process_pid, list) else [process_pid] >+ names = process_name if isinstance(process_name, list) else [process_name] > try: >- leaks_filename = self.leaks_file_name(process_name, process_pid) >- leaks_output_path = self._filesystem.join(self._port.results_directory(), leaks_filename) >- # Oddly enough, run-leaks (or the underlying leaks tool) does not seem to always output utf-8, >- # thus we pass decode_output=False. Without this code we've seen errors like: >- # "UnicodeDecodeError: 'utf8' codec can't decode byte 0x88 in position 779874: unexpected code byte" >- self._port._run_script("run-leaks", self._leaks_args(process_name, process_pid), include_configuration_arguments=False, decode_output=False) >- leaks_output = self._filesystem.read_binary_file(leaks_output_path) >+ for i in range(len(pids)): >+ pid = pids[i] >+ name = names[i] >+ leaks_filename = self.leaks_file_name(name, pid) >+ leaks_output_path = self._filesystem.join(self._port.results_directory(), leaks_filename) >+ # Oddly enough, run-leaks (or the underlying leaks tool) does not seem to always output utf-8, >+ # thus we pass decode_output=False. Without this code we've seen errors like: >+ # "UnicodeDecodeError: 'utf8' codec can't decode byte 0x88 in position 779874: unexpected code byte" >+ self._port._run_script("run-leaks", self._leaks_args(name, pid), include_configuration_arguments=False, decode_output=False) >+ leaks_output = self._filesystem.read_binary_file(leaks_output_path) > except ScriptError as e: > _log.warn("Failed to run leaks tool: %s" % e.message_with_output()) > return
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193772
:
360017
|
365715
|
365716
|
365740
|
365840
|
365868
|
366081
|
366084