Title: [98639] trunk/Tools
Revision
98639
Author
[email protected]
Date
2011-10-27 14:29:53 -0700 (Thu, 27 Oct 2011)

Log Message

REGRESSION (NRWT): build.webkit.org doesn't show the total number of leaks found during a test run on the Leaks bot
https://bugs.webkit.org/show_bug.cgi?id=66227

Reviewed by Adam Roben.

I believe this should fix the bug.

* Scripts/run-webkit-tests: make NRWT default for --leaks
* Scripts/webkitpy/layout_tests/port/leakdetector.py:
(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)
(LeakDetector.count_total_bytes_and_unique_leaks): renamed from parse_leak_files
(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.
* Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py:
Changes to reflect the rename of count_total_bytes_and_unique_leaks and a new test for count_total_leaks.
* Scripts/webkitpy/layout_tests/port/mac.py:
Use count_total_leaks to spit out the total leak count like ORWT did, and remove the FIXME on the subject.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (98638 => 98639)


--- trunk/Tools/ChangeLog	2011-10-27 21:21:32 UTC (rev 98638)
+++ trunk/Tools/ChangeLog	2011-10-27 21:29:53 UTC (rev 98639)
@@ -1,3 +1,22 @@
+2011-10-27  Eric Seidel  <[email protected]>
+
+        REGRESSION (NRWT): build.webkit.org doesn't show the total number of leaks found during a test run on the Leaks bot
+        https://bugs.webkit.org/show_bug.cgi?id=66227
+
+        Reviewed by Adam Roben.
+
+        I believe this should fix the bug.
+
+        * Scripts/run-webkit-tests: make NRWT default for --leaks
+        * Scripts/webkitpy/layout_tests/port/leakdetector.py:
+        (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)
+        (LeakDetector.count_total_bytes_and_unique_leaks): renamed from parse_leak_files
+        (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.
+        * Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py:
+        Changes to reflect the rename of count_total_bytes_and_unique_leaks and a new test for count_total_leaks.
+        * Scripts/webkitpy/layout_tests/port/mac.py:
+        Use count_total_leaks to spit out the total leak count like ORWT did, and remove the FIXME on the subject.
+
 2011-10-27  Stephen Chenney  <[email protected]>
 
         [Chromium] Need setPrinting

Modified: trunk/Tools/Scripts/run-webkit-tests (98638 => 98639)


--- trunk/Tools/Scripts/run-webkit-tests	2011-10-27 21:21:32 UTC (rev 98638)
+++ trunk/Tools/Scripts/run-webkit-tests	2011-10-27 21:29:53 UTC (rev 98639)
@@ -55,14 +55,6 @@
     return $isBuildBotUser{$ENV{"USER"}};
 }
 
-sub usingLeaks()
-{
-    # LeaksViewer gets confused by NRWT's --leaks output, see bugs:
-    # https://bugs.webkit.org/show_bug.cgi?id=66227
-    # https://bugs.webkit.org/show_bug.cgi?id=66228
-    return grep(/--leaks/, @ARGV);
-}
-
 sub useNewRunWebKitTests()
 {
     # Change this check to control which platforms use new-run-webkit-tests by default.
@@ -75,12 +67,12 @@
 
     # NRWT Windows support still needs work: https://bugs.webkit.org/show_bug.cgi?id=38756
 
-    # 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
+    # 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
     if (isQt()) {
         return (!isARM());
     }
 
-    return ((isLeopard() or isSnowLeopard() or isLion() or isGtk()) and !usingLeaks());
+    return (isLeopard() or isSnowLeopard() or isLion() or isGtk());
 }
 
 my $harnessName = "old-run-webkit-tests";

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/leakdetector.py (98638 => 98639)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/leakdetector.py	2011-10-27 21:21:32 UTC (rev 98638)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/leakdetector.py	2011-10-27 21:29:53 UTC (rev 98639)
@@ -84,9 +84,9 @@
         leaks_args.append(pid)
         return leaks_args
 
-    def _parse_leaks_output(self, leaks_output, process_pid):
-        count, bytes = re.search(r'Process %s: (\d+) leaks? for (\d+) total' % process_pid, leaks_output).groups()
-        excluded_match = re.search(r'(\d+) leaks? excluded', leaks_output)
+    def _parse_leaks_output(self, leaks_output):
+        _, count, bytes = re.search(r'Process (?P<pid>\d+): (?P<count>\d+) leaks? for (?P<bytes>\d+) total', leaks_output).groups()
+        excluded_match = re.search(r'(?P<excluded>\d+) leaks? excluded', leaks_output)
         excluded = excluded_match.group(0) if excluded_match else 0
         return int(count), int(excluded), int(bytes)
 
@@ -97,7 +97,7 @@
         # We include the number of files this worker has already written in the name to prevent overwritting previous leak results..
         return "%s-%s-leaks.txt" % (process_name, process_pid)
 
-    def parse_leak_files(self, leak_files):
+    def count_total_bytes_and_unique_leaks(self, leak_files):
         merge_depth = 5  # ORWT had a --merge-leak-depth argument, but that seems out of scope for the run-webkit-tests tool.
         args = [
             '--merge-depth',
@@ -114,6 +114,14 @@
         total_bytes_string = re.search(r'^total\:\s(.+)\s\(', parse_malloc_history_output, re.MULTILINE).group(1)
         return (total_bytes_string, unique_leak_count)
 
+    def count_total_leaks(self, leak_file_paths):
+        total_leaks = 0
+        for leak_file_path in leak_file_paths:
+            leaks_output = self._filesystem.read_text_file(leak_file_path)
+            count, _, _ = self._parse_leaks_output(leaks_output)
+            total_leaks += count
+        return total_leaks
+
     def check_for_leaks(self, process_name, process_pid):
         _log.debug("Checking for leaks in %s" % process_name)
         try:
@@ -125,8 +133,8 @@
             _log.warn("Failed to run leaks tool: %s" % e.message_with_output())
             return
 
-        # FIXME: We should consider moving leaks parsing to the end when summarizing is done.
-        count, excluded, bytes = self._parse_leaks_output(leaks_output, process_pid)
+        # FIXME: We end up parsing this output 3 times.  Once here and twice for summarizing.
+        count, excluded, bytes = self._parse_leaks_output(leaks_output)
         adjusted_count = count - excluded
         if not adjusted_count:
             return

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py (98638 => 98639)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py	2011-10-27 21:21:32 UTC (rev 98638)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/leakdetector_unittest.py	2011-10-27 21:29:53 UTC (rev 98639)
@@ -79,7 +79,7 @@
 """
 
     def test_parse_leaks_output(self):
-        self.assertEquals(self._make_detector()._parse_leaks_output(self.example_leaks_output, 5122), (337301, 0, 6525216))
+        self.assertEquals(self._make_detector()._parse_leaks_output(self.example_leaks_output), (337301, 0, 6525216))
 
     def test_leaks_files_in_directory(self):
         detector = self._make_detector()
@@ -91,7 +91,7 @@
         })
         self.assertEquals(len(detector.leaks_files_in_directory('/mock-results')), 3)
 
-    def test_parse_leak_files(self):
+    def test_count_total_bytes_and_unique_leaks(self):
         detector = self._make_detector()
 
         def mock_run_script(name, args, include_configuration_arguments=False):
@@ -103,5 +103,15 @@
 
         leak_files = ['/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-1235-leaks.txt']
         expected_stdout = "MOCK _run_script: parse-malloc-history ['--merge-depth', 5, '/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-1235-leaks.txt']\n"
-        results_tuple = OutputCapture().assert_outputs(self, detector.parse_leak_files, [leak_files], expected_stdout=expected_stdout)
+        results_tuple = OutputCapture().assert_outputs(self, detector.count_total_bytes_and_unique_leaks, [leak_files], expected_stdout=expected_stdout)
         self.assertEquals(results_tuple, ("5,888 bytes", 1))
+
+    def test_count_total_leaks(self):
+        detector = self._make_detector()
+        detector._filesystem = MockFileSystem({
+            '/mock-results/DumpRenderTree-1234-leaks.txt': 'Process 1234: 12 leaks for 40 total leaked bytes.\n',
+            '/mock-results/DumpRenderTree-23423-leaks.txt': 'Process 1235: 12341 leaks for 27934 total leaked bytes.\n',
+            '/mock-results/DumpRenderTree-823-leaks.txt': 'Process 12356: 23412 leaks for 18 total leaked bytes.\n',
+        })
+        leak_file_paths = ['/mock-results/DumpRenderTree-1234-leaks.txt', '/mock-results/DumpRenderTree-23423-leaks.txt', '/mock-results/DumpRenderTree-823-leaks.txt']
+        self.assertEquals(detector.count_total_leaks(leak_file_paths), 35765)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py (98638 => 98639)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py	2011-10-27 21:21:32 UTC (rev 98638)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py	2011-10-27 21:29:53 UTC (rev 98639)
@@ -139,12 +139,9 @@
         leaks_files = self._leak_detector.leaks_files_in_directory(self.results_directory())
         if not leaks_files:
             return
-        total_bytes_string, unique_leaks = self._leak_detector.parse_leak_files(leaks_files)
-        # old-run-webkit-tests used to print the "total leaks" count, but that would
-        # require re-parsing each of the leaks files (which we could do at some later point if that would be useful.)
-        # Tools/BuildSlaveSupport/build.webkit.org-config/master.cfg greps for "leaks found".
-        # master.cfg will need an update if these strings change.
-        _log.info("leaks found for a total of %s!" % total_bytes_string)
+        total_bytes_string, unique_leaks = self._leak_detector.count_total_bytes_and_unique_leaks(leaks_files)
+        total_leaks = self._leak_detector.count_total_leaks(leaks_files)
+        _log.info("%s total leaks found for a total of %s!" % (total_leaks, total_bytes_string))
         _log.info("%s unique leaks found!" % unique_leaks)
 
     def _check_port_build(self):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to