webkitpy: Remove unneeded crash log retrieval, refactor Darwin crash retrieval
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 May 2017 23:19:07 +0000 (23:19 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 May 2017 23:19:07 +0000 (23:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170857
<rdar://problem/31635373>

Reviewed by Aakash Jain.

Since LayoutTestRelay has been removed, iOS Simulators and Macs can use the same
code to search for crash logs.

* Scripts/webkitpy/port/darwin.py:
(DarwinPort._get_crash_log): Moved from MacPort.
* Scripts/webkitpy/port/darwin_testcase.py:
(DarwinTest.test_get_crash_log): Moved from MacTest.
* Scripts/webkitpy/port/ios_device.py:
(IOSDevicePort._get_crash_log): Implement pass-through for iOS device, since iOS
devices must search for crash-logs remotely.
* Scripts/webkitpy/port/ios_simulator.py:
(IOSSimulatorPort._get_crash_log): Deleted.
* Scripts/webkitpy/port/ios_simulator_unittest.py:
(IOSSimulatorTest.test_get_crash_log): Deleted.
* Scripts/webkitpy/port/mac.py:
(MacPort._get_crash_log): Moved to DarwinPort
* Scripts/webkitpy/port/mac_unittest.py:
(MacTest.test_get_crash_log): Moved to DarwinTest.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216556 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/port/darwin.py
Tools/Scripts/webkitpy/port/darwin_testcase.py
Tools/Scripts/webkitpy/port/ios_device.py
Tools/Scripts/webkitpy/port/ios_simulator.py
Tools/Scripts/webkitpy/port/ios_simulator_unittest.py
Tools/Scripts/webkitpy/port/mac.py
Tools/Scripts/webkitpy/port/mac_unittest.py

index 1f11669..a82d57a 100644 (file)
@@ -1,5 +1,32 @@
 2017-05-09  Jonathan Bedard  <jbedard@apple.com>
 
+        webkitpy: Remove unneeded crash log retrieval, refactor Darwin crash retrieval
+        https://bugs.webkit.org/show_bug.cgi?id=170857
+        <rdar://problem/31635373>
+
+        Reviewed by Aakash Jain.
+
+        Since LayoutTestRelay has been removed, iOS Simulators and Macs can use the same
+        code to search for crash logs.
+
+        * Scripts/webkitpy/port/darwin.py:
+        (DarwinPort._get_crash_log): Moved from MacPort.
+        * Scripts/webkitpy/port/darwin_testcase.py:
+        (DarwinTest.test_get_crash_log): Moved from MacTest.
+        * Scripts/webkitpy/port/ios_device.py:
+        (IOSDevicePort._get_crash_log): Implement pass-through for iOS device, since iOS
+        devices must search for crash-logs remotely.
+        * Scripts/webkitpy/port/ios_simulator.py:
+        (IOSSimulatorPort._get_crash_log): Deleted.
+        * Scripts/webkitpy/port/ios_simulator_unittest.py:
+        (IOSSimulatorTest.test_get_crash_log): Deleted.
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort._get_crash_log): Moved to DarwinPort
+        * Scripts/webkitpy/port/mac_unittest.py:
+        (MacTest.test_get_crash_log): Moved to DarwinTest.
+
+2017-05-09  Jonathan Bedard  <jbedard@apple.com>
+
         build ImageDiff with host SDK from Make
         https://bugs.webkit.org/show_bug.cgi?id=171835
 
index 0e0c370..9b94d94 100644 (file)
@@ -22,6 +22,7 @@
 
 import logging
 import os
+import time
 
 from webkitpy.common.memoized import memoized
 from webkitpy.common.system.crashlogs import CrashLogs
@@ -101,7 +102,26 @@ class DarwinPort(ApplePort):
         return crash_log.find_all_logs(include_errors=True, newer_than=newer_than)
 
     def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True):
-        return super(DarwinPort, self)._get_crash_log(name, pid, stdout, stderr, newer_than)
+        # Note that we do slow-spin here and wait, since it appears the time
+        # ReportCrash takes to actually write and flush the file varies when there are
+        # lots of simultaneous crashes going on.
+        time_fn = time_fn or time.time
+        sleep_fn = sleep_fn or time.sleep
+        crash_log = ''
+        crash_logs = CrashLogs(self.host)
+        now = time_fn()
+        deadline = now + 5 * int(self.get_option('child_processes', 1))
+        while not crash_log and now <= deadline:
+            crash_log = crash_logs.find_newest_log(name, pid, include_errors=True, newer_than=newer_than)
+            if not wait_for_log:
+                break
+            if not crash_log or not [line for line in crash_log.splitlines() if not line.startswith('ERROR')]:
+                sleep_fn(0.1)
+                now = time_fn()
+
+        if not crash_log:
+            return (stderr, None)
+        return (stderr, crash_log)
 
     def look_for_new_crash_logs(self, crashed_processes, start_time):
         """Since crash logs can take a long time to be written out if the system is
index 8661d7a..1e8da6b 100644 (file)
@@ -20,6 +20,8 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import time
+
 from webkitpy.port import port_testcase
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.mocktool import MockOptions
@@ -124,3 +126,11 @@ class DarwinTest(port_testcase.PortTestCase):
         port = self.make_port()
         port.host.executive = MockExecutive2(run_command_fn=throwing_run_command)
         OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42])
+
+    def test_get_crash_log(self):
+        # Darwin crash logs are tested elsewhere, so here we just make sure we don't crash.
+        def fake_time_cb():
+            times = [0, 20, 40]
+            return lambda: times.pop(0)
+        port = self.make_port(port_name=self.port_name)
+        port._get_crash_log('DumpRenderTree', 1234, None, None, time.time(), wait_for_log=False)
index 8b55193..3f87b46 100644 (file)
@@ -87,6 +87,9 @@ class IOSDevicePort(IOSPort):
     def operating_system(self):
         return 'ios-device'
 
+    def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True):
+        return (stderr, None)
+
     def _create_devices(self, device_class):
         if not apple_additions():
             raise RuntimeError(self.NO_ON_DEVICE_TESTING)
index 155281e..7681927 100644 (file)
@@ -134,44 +134,6 @@ class IOSSimulatorPort(IOSPort):
 
         return min(maximum_simulator_count_on_this_system, best_child_process_count_for_cpu)
 
-    def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=time.time, sleep_fn=time.sleep, wait_for_log=True):
-        time_fn = time_fn or time.time
-        sleep_fn = sleep_fn or time.sleep
-
-        # FIXME: We should collect the actual crash log for DumpRenderTree.app because it includes more
-        # information (e.g. exception codes) than is available in the stack trace written to standard error.
-        stderr_lines = []
-        crashed_subprocess_name_and_pid = None  # e.g. ('DumpRenderTree.app', 1234)
-        for line in (stderr or '').splitlines():
-            if not crashed_subprocess_name_and_pid:
-                match = self.SUBPROCESS_CRASH_REGEX.match(line)
-                if match:
-                    crashed_subprocess_name_and_pid = (match.group('subprocess_name'), int(match.group('subprocess_pid')))
-                    continue
-            stderr_lines.append(line)
-
-        if crashed_subprocess_name_and_pid:
-            return self._get_crash_log(crashed_subprocess_name_and_pid[0], crashed_subprocess_name_and_pid[1], stdout,
-                '\n'.join(stderr_lines), newer_than, time_fn, sleep_fn, wait_for_log)
-
-        # App crashed
-        _log.debug('looking for crash log for %s:%s' % (name, str(pid)))
-        crash_log = ''
-        crash_logs = CrashLogs(self.host)
-        now = time_fn()
-        deadline = now + 5 * int(self.get_option('child_processes', 1))
-        while not crash_log and now <= deadline:
-            crash_log = crash_logs.find_newest_log(name, pid, include_errors=True, newer_than=newer_than)
-            if not wait_for_log:
-                break
-            if not crash_log or not [line for line in crash_log.splitlines() if not line.startswith('ERROR')]:
-                sleep_fn(0.1)
-                now = time_fn()
-
-        if not crash_log:
-            return stderr, None
-        return stderr, crash_log
-
     def _build_driver_flags(self):
         archs = ['ARCHS=i386'] if self.architecture() == 'x86' else []
         sdk = ['--sdk', 'iphonesimulator']
index 556400c..24b194d 100644 (file)
@@ -50,14 +50,6 @@ class IOSSimulatorTest(ios_testcase.IOSTest):
     def test_operating_system(self):
         self.assertEqual('ios-simulator', self.make_port().operating_system())
 
-    def test_get_crash_log(self):
-        # Mac crash logs are tested elsewhere, so here we just make sure we don't crash.
-        def fake_time_cb():
-            times = [0, 20, 40]
-            return lambda: times.pop(0)
-        port = self.make_port(port_name=self.port_name)
-        port._get_crash_log('DumpRenderTree', 1234, None, None, time.time(), wait_for_log=False)
-
     def test_32bit(self):
         port = self.make_port(options=MockOptions(architecture='x86'))
 
index eb166d2..06e9ffa 100644 (file)
@@ -162,31 +162,6 @@ class MacPort(DarwinPort):
     def _check_port_build(self):
         return not self.get_option('java') or self._build_java_test_support()
 
-    def _get_crash_log(self, name, pid, stdout, stderr, newer_than, time_fn=None, sleep_fn=None, wait_for_log=True):
-        # Note that we do slow-spin here and wait, since it appears the time
-        # ReportCrash takes to actually write and flush the file varies when there are
-        # lots of simultaneous crashes going on.
-        # FIXME: Should most of this be moved into CrashLogs()?
-        time_fn = time_fn or time.time
-        sleep_fn = sleep_fn or time.sleep
-        crash_log = ''
-        crash_logs = CrashLogs(self.host)
-        now = time_fn()
-        # FIXME: delete this after we're sure this code is working ...
-        _log.debug('looking for crash log for %s:%s' % (name, str(pid)))
-        deadline = now + 5 * int(self.get_option('child_processes', 1))
-        while not crash_log and now <= deadline:
-            crash_log = crash_logs.find_newest_log(name, pid, include_errors=True, newer_than=newer_than)
-            if not wait_for_log:
-                break
-            if not crash_log or not [line for line in crash_log.splitlines() if not line.startswith('ERROR')]:
-                sleep_fn(0.1)
-                now = time_fn()
-
-        if not crash_log:
-            return (stderr, None)
-        return (stderr, crash_log)
-
     def start_helper(self, pixel_tests=False):
         helper_path = self._path_to_helper()
         if not helper_path:
index a33dc86..5de57b4 100644 (file)
@@ -141,14 +141,6 @@ class MacTest(darwin_testcase.DarwinTest):
         child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_logs=expected_logs)
         self.assertEqual(child_processes, 1)
 
-    def test_get_crash_log(self):
-        # Mac crash logs are tested elsewhere, so here we just make sure we don't crash.
-        def fake_time_cb():
-            times = [0, 20, 40]
-            return lambda: times.pop(0)
-        port = self.make_port(port_name='mac-snowleopard')
-        port._get_crash_log('DumpRenderTree', 1234, None, None, time.time(), wait_for_log=False)
-
     def test_32bit(self):
         port = self.make_port(options=MockOptions(architecture='x86'))