Build fix for “Move functionality common to Darwin ports into a base class”
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 22:17:06 +0000 (22:17 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 22:17:06 +0000 (22:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160709

Unreviewed build fix.

* Scripts/webkitpy/port/ios.py:
(IOSSimulatorPort._get_crash_log): Added iOS implementation.
* Scripts/webkitpy/port/mac.py:
(MacPort._get_crash_log): Added Mac implementation.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/port/ios.py
Tools/Scripts/webkitpy/port/mac.py

index bdff2af..49729a2 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-07  Jonathan Bedard  <jbedard@apple.com>
+
+        Build fix for “Move functionality common to Darwin ports into a base class”
+        https://bugs.webkit.org/show_bug.cgi?id=160709
+
+        Unreviewed build fix.
+
+        * Scripts/webkitpy/port/ios.py:
+        (IOSSimulatorPort._get_crash_log): Added iOS implementation.
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort._get_crash_log): Added Mac implementation.
+
 2016-10-07  Chelsea Pugh  <cpugh@apple.com>
 
         Unreviewed. Added myself to the list of committers.
index cbfcc72..fc556e7 100644 (file)
@@ -186,6 +186,44 @@ class IOSSimulatorPort(DarwinPort):
             return False
         return True
 
+    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)
+
+        # LayoutTestRelay 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_relay(self):
         environment = self.host.copy_current_environment()
         environment.disable_gcc_smartquotes()
index 06e9ffa..eb166d2 100644 (file)
@@ -162,6 +162,31 @@ 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: