Tools/ChangeLog

 12011-10-27 Eric Seidel <eric@webkit.org>
 2
 3 REGRESSION (NRWT): build.webkit.org doesn't show the total number of leaks found during a test run on the Leaks bot
 4 https://bugs.webkit.org/show_bug.cgi?id=66227
 5
 6 Reviewed by Adam Roben.
 7
 8 I believe this should fix the bug.
 9
 10 * Scripts/run-webkit-tests: make NRWT default for --leaks
 11 * Scripts/webkitpy/layout_tests/port/leakdetector.py:
 12 (LeakDetector._parse_leaks_output): removed the (unneeded) process_pid argument, and made the regexp use named groups (even though we don't ever grab them by name)
 13 (LeakDetector.count_total_bytes_and_unique_leaks): renamed from parse_leak_files
 14 (LeakDetector.count_total_leaks): new file (the guts of this change) which is used to re-parse the leaks output during the summarize leaks phase.
 15 * Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py:
 16 Changes to reflect the rename of count_total_bytes_and_unique_leaks and a new test for count_total_leaks.
 17 * Scripts/webkitpy/layout_tests/port/mac.py:
 18 Use count_total_leaks to spit out the total leak count like ORWT did, and remove the FIXME on the subject.
 19
1202011-10-27 Stephen Chenney <schenney@chromium.org>
221
322 [Chromium] Need setPrinting

Tools/Scripts/run-webkit-tests

@@sub runningOnBuildBot()
5555 return $isBuildBotUser{$ENV{"USER"}};
5656}
5757
58 sub usingLeaks()
59 {
60  # LeaksViewer gets confused by NRWT's --leaks output, see bugs:
61  # https://bugs.webkit.org/show_bug.cgi?id=66227
62  # https://bugs.webkit.org/show_bug.cgi?id=66228
63  return grep(/--leaks/, @ARGV);
64 }
65 
6658sub useNewRunWebKitTests()
6759{
6860 # Change this check to control which platforms use new-run-webkit-tests by default.

@@sub useNewRunWebKitTests()
7567
7668 # NRWT Windows support still needs work: https://bugs.webkit.org/show_bug.cgi?id=38756
7769
78  # NRWT doesn't support qt-mac, qt-arm and qt-4.8 platforms now: https://bugs.webkit.org/show_bug.cgi?id=64071 and https://bugs.webkit.org/show_bug.cgi?id=64086
 70 # NRWT doesn't support qt-arm and qt-4.8 platforms now: https://bugs.webkit.org/show_bug.cgi?id=64071 and https://bugs.webkit.org/show_bug.cgi?id=64086
7971 if (isQt()) {
8072 return (!isARM());
8173 }
8274
83  return ((isLeopard() or isSnowLeopard() or isLion() or isGtk()) and !usingLeaks());
 75 return (isLeopard() or isSnowLeopard() or isLion() or isGtk());
8476}
8577
8678my $harnessName = "old-run-webkit-tests";

Tools/Scripts/webkitpy/layout_tests/port/leakdetector.py

@@class LeakDetector(object):
8484 leaks_args.append(pid)
8585 return leaks_args
8686
87  def _parse_leaks_output(self, leaks_output, process_pid):
88  count, bytes = re.search(r'Process %s: (\d+) leaks? for (\d+) total' % process_pid, leaks_output).groups()
89  excluded_match = re.search(r'(\d+) leaks? excluded', leaks_output)
 87 def _parse_leaks_output(self, leaks_output):
 88 _, count, bytes = re.search(r'Process (?P<pid>\d+): (?P<count>\d+) leaks? for (?P<bytes>\d+) total', leaks_output).groups()
 89 excluded_match = re.search(r'(?P<excluded>\d+) leaks? excluded', leaks_output)
9090 excluded = excluded_match.group(0) if excluded_match else 0
9191 return int(count), int(excluded), int(bytes)
9292

@@class LeakDetector(object):
9797 # We include the number of files this worker has already written in the name to prevent overwritting previous leak results..
9898 return "%s-%s-leaks.txt" % (process_name, process_pid)
9999
100  def parse_leak_files(self, leak_files):
 100 def count_total_bytes_and_unique_leaks(self, leak_files):
101101 merge_depth = 5 # ORWT had a --merge-leak-depth argument, but that seems out of scope for the run-webkit-tests tool.
102102 args = [
103103 '--merge-depth',

@@class LeakDetector(object):
114114 total_bytes_string = re.search(r'^total\:\s(.+)\s\(', parse_malloc_history_output, re.MULTILINE).group(1)
115115 return (total_bytes_string, unique_leak_count)
116116
 117 def count_total_leaks(self, leak_file_paths):
 118 total_leaks = 0
 119 for leak_file_path in leak_file_paths:
 120 leaks_output = self._filesystem.read_text_file(leak_file_path)
 121 count, _, _ = self._parse_leaks_output(leaks_output)
 122 total_leaks += count
 123 return total_leaks
 124
117125 def check_for_leaks(self, process_name, process_pid):
118126 _log.debug("Checking for leaks in %s" % process_name)
119127 try:

@@class LeakDetector(object):
125133 _log.warn("Failed to run leaks tool: %s" % e.message_with_output())
126134 return
127135
128  # FIXME: We should consider moving leaks parsing to the end when summarizing is done.
129  count, excluded, bytes = self._parse_leaks_output(leaks_output, process_pid)
 136 # FIXME: We end up parsing this output 3 times. Once here and twice for summarizing.
 137 count, excluded, bytes = self._parse_leaks_output(leaks_output)
130138 adjusted_count = count - excluded
131139 if not adjusted_count:
132140 return

Tools/Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py

@@Leak: 0x25102fe0 size=176 zone: DefaultMallocZone_0x1d94000 string 'NSExcept
7979"""
8080
8181 def test_parse_leaks_output(self):
82  self.assertEquals(self._make_detector()._parse_leaks_output(self.example_leaks_output, 5122), (337301, 0, 6525216))
 82 self.assertEquals(self._make_detector()._parse_leaks_output(self.example_leaks_output), (337301, 0, 6525216))
8383
8484 def test_leaks_files_in_directory(self):
8585 detector = self._make_detector()

@@Leak: 0x25102fe0 size=176 zone: DefaultMallocZone_0x1d94000 string 'NSExcept
9191 })
9292 self.assertEquals(len(detector.leaks_files_in_directory('/mock-results')), 3)
9393
94  def test_parse_leak_files(self):
 94 def test_count_total_bytes_and_unique_leaks(self):
9595 detector = self._make_detector()
9696
9797 def mock_run_script(name, args, include_configuration_arguments=False):

@@total: 5,888 bytes (0 bytes excluded)."""
103103
104104 leak_files = ['/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-1235-leaks.txt']
105105 expected_stdout = "MOCK _run_script: parse-malloc-history ['--merge-depth', 5, '/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-1235-leaks.txt']\n"
106  results_tuple = OutputCapture().assert_outputs(self, detector.parse_leak_files, [leak_files], expected_stdout=expected_stdout)
 106 results_tuple = OutputCapture().assert_outputs(self, detector.count_total_bytes_and_unique_leaks, [leak_files], expected_stdout=expected_stdout)
107107 self.assertEquals(results_tuple, ("5,888 bytes", 1))
 108
 109 def test_count_total_leaks(self):
 110 detector = self._make_detector()
 111 detector._filesystem = MockFileSystem({
 112 '/mock-results/DumpRenderTree-1234-leaks.txt': 'Process 1234: 12 leaks for 40 total leaked bytes.\n',
 113 '/mock-results/DumpRenderTree-23423-leaks.txt': 'Process 1235: 12341 leaks for 27934 total leaked bytes.\n',
 114 '/mock-results/DumpRenderTree-823-leaks.txt': 'Process 12356: 23412 leaks for 18 total leaked bytes.\n',
 115 })
 116 leak_file_paths = ['/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-23423-leaks.txt', '/mock-results/DumpRenderTree-823-leaks.txt']
 117 self.assertEquals(detector.count_total_leaks(leak_file_paths), 35765)

Tools/Scripts/webkitpy/layout_tests/port/mac.py

@@class MacPort(ApplePort):
139139 leaks_files = self._leak_detector.leaks_files_in_directory(self.results_directory())
140140 if not leaks_files:
141141 return
142  total_bytes_string, unique_leaks = self._leak_detector.parse_leak_files(leaks_files)
143  # old-run-webkit-tests used to print the "total leaks" count, but that would
144  # require re-parsing each of the leaks files (which we could do at some later point if that would be useful.)
145  # Tools/BuildSlaveSupport/build.webkit.org-config/master.cfg greps for "leaks found".
146  # master.cfg will need an update if these strings change.
147  _log.info("leaks found for a total of %s!" % total_bytes_string)
 142 total_bytes_string, unique_leaks = self._leak_detector.count_total_bytes_and_unique_leaks(leaks_files)
 143 total_leaks = self._leak_detector.count_total_leaks(leaks_files)
 144 _log.info("%s total leaks found for a total of %s!" % (total_leaks, total_bytes_string))
148145 _log.info("%s unique leaks found!" % unique_leaks)
149146
150147 def _check_port_build(self):