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 21:06:43 +0000 (21:06 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Oct 2016 21:06:43 +0000 (21:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160709

Reviewed by Darin Adler.

* Scripts/webkitpy/port/apple.py:
(ApplePort.determine_full_port_name): Specific iOS port check.
(ApplePort.__init__): Move leak detector to DarwinPort.
(ApplePort._make_leak_detector): Moved to DarwinPort.
(ApplePort.supports_per_test_timeout): Moved to Port.
(ApplePort.check_for_leaks): Moved to DarwinPort.
(ApplePort.print_leaks_summary): Moved to DarwinPort.
(ApplePort._path_to_webcore_library): Moved to DarwinPort.
(ApplePort.show_results_html_file): Moved to DarwinPort.
(ApplePort._merge_crash_logs): Moved to DarwinPort.
(ApplePort._look_for_all_crash_logs_in_log_dir): Moved to DarwinPort.
(ApplePort._get_crash_log): Moved to DarwinPort.
(ApplePort.look_for_new_crash_logs): Moved to DarwinPort.
(ApplePort.sample_process): Moved to DarwinPort.
(ApplePort.sample_file_path): Moved to DarwinPort.
(ApplePort.look_for_new_samples): Moved to DarwinPort.
* Scripts/webkitpy/port/base.py:
(Port.supports_per_test_timeout): Return true for all ports.
* Scripts/webkitpy/port/darwin.py: Added.
(DarwinPort): Shared iOS and Mac functions.
* Scripts/webkitpy/port/darwin_testcase.py: Added.
(DarwinTest): Shared iOS and Mac testing.
* Scripts/webkitpy/port/efl.py:
(EflPort):
(EflPort.supports_per_test_timeout): Moved to Port.
* Scripts/webkitpy/port/gtk.py:
(GtkPort._driver_class):
(GtkPort):
(GtkPort.supports_per_test_timeout): Moved to Port.
* Scripts/webkitpy/port/ios.py:
(IOSPort):
(IOSPort.operating_system):
(IOSSimulatorPort):
(IOSSimulatorPort.__init__): Inherits from DarwinPort.
(IOSSimulatorPort._port_specific_expectations_files): Moved to DarwinPort.
(IOSSimulatorPort._get_crash_log): Deleted.
(IOSSimulatorPort.xcrun_find): Deleted.
* Scripts/webkitpy/port/ios_unittest.py: Added.
(iosTest): Unit tests for the iOS port.
* Scripts/webkitpy/port/mac.py:
(MacPort):
(MacPort.__init__): Inherits from DarwinPort.
(MacPort._port_specific_expectations_files): Moved to DarwinPort.
(MacPort.make_command): Moved to DarwinPort.
(MacPort._get_crash_log): Moved to DarwinPort.
(MacPort.nm_command): Moved to DarwinPort.
* Scripts/webkitpy/port/mac_unittest.py:
(MacTest):
(MacTest.test_sdk_name): Added test.
(MacTest.test_xcrun): Added test.
(MacTest.assert_skipped_file_search_paths): Moved to DarwinTest.
(MacTest.test_default_timeout_ms): Moved to DarwinTest.
(MacTest.assert_name): Moved to DarwinTest.
(MacTest.test_helper_starts): Moved to DarwinTest.
(MacTest.test_helper_fails_to_start): Moved to DarwinTest.
(MacTest.test_helper_fails_to_stop): Moved to DarwinTest.
(MacTest.test_spindump): Moved to DarwinTest.
(MacTest.test_sample_process): Moved to DarwinTest.
(MacTest.test_sample_process_exception): Moved to DarwinTest.
* Scripts/webkitpy/port/port_testcase.py:
(PortTestCase):
(PortTestCase.test_diff_image): Added is_simulator flag.
(PortTestCase.test_diff_image): Skip test if on a simulator.
(PortTestCase.test_diff_image_crashed): Skip test if on a simulator.
* Scripts/webkitpy/port/win.py:
(WinPort):
(WinPort.look_for_new_samples): Used default, ApplePort no longer implements.
(WinPort.sample_process): Ditto.
(WinPort._make_leak_detector): Ditto.
(WinPort.check_for_leaks): Ditto.
(WinPort.print_leaks_summary): Ditto.
(WinPort._path_to_webcore_library): Ditto.

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

13 files changed:
Tools/ChangeLog
Tools/Scripts/webkitpy/port/apple.py
Tools/Scripts/webkitpy/port/base.py
Tools/Scripts/webkitpy/port/darwin.py [new file with mode: 0644]
Tools/Scripts/webkitpy/port/darwin_testcase.py [new file with mode: 0644]
Tools/Scripts/webkitpy/port/efl.py
Tools/Scripts/webkitpy/port/gtk.py
Tools/Scripts/webkitpy/port/ios.py
Tools/Scripts/webkitpy/port/ios_unittest.py [new file with mode: 0644]
Tools/Scripts/webkitpy/port/mac.py
Tools/Scripts/webkitpy/port/mac_unittest.py
Tools/Scripts/webkitpy/port/port_testcase.py
Tools/Scripts/webkitpy/port/win.py

index ae272e7..085f3b5 100644 (file)
@@ -1,3 +1,83 @@
+2016-10-07  Jonathan Bedard  <jbedard@apple.com>
+
+        Move functionality common to Darwin ports into a base class
+        https://bugs.webkit.org/show_bug.cgi?id=160709
+
+        Reviewed by Darin Adler.
+
+        * Scripts/webkitpy/port/apple.py:
+        (ApplePort.determine_full_port_name): Specific iOS port check.
+        (ApplePort.__init__): Move leak detector to DarwinPort.
+        (ApplePort._make_leak_detector): Moved to DarwinPort.
+        (ApplePort.supports_per_test_timeout): Moved to Port.
+        (ApplePort.check_for_leaks): Moved to DarwinPort.
+        (ApplePort.print_leaks_summary): Moved to DarwinPort.
+        (ApplePort._path_to_webcore_library): Moved to DarwinPort.
+        (ApplePort.show_results_html_file): Moved to DarwinPort.
+        (ApplePort._merge_crash_logs): Moved to DarwinPort.
+        (ApplePort._look_for_all_crash_logs_in_log_dir): Moved to DarwinPort.
+        (ApplePort._get_crash_log): Moved to DarwinPort.
+        (ApplePort.look_for_new_crash_logs): Moved to DarwinPort.
+        (ApplePort.sample_process): Moved to DarwinPort.
+        (ApplePort.sample_file_path): Moved to DarwinPort.
+        (ApplePort.look_for_new_samples): Moved to DarwinPort.
+        * Scripts/webkitpy/port/base.py:
+        (Port.supports_per_test_timeout): Return true for all ports.
+        * Scripts/webkitpy/port/darwin.py: Added.
+        (DarwinPort): Shared iOS and Mac functions.
+        * Scripts/webkitpy/port/darwin_testcase.py: Added.
+        (DarwinTest): Shared iOS and Mac testing.
+        * Scripts/webkitpy/port/efl.py:
+        (EflPort):
+        (EflPort.supports_per_test_timeout): Moved to Port.
+        * Scripts/webkitpy/port/gtk.py:
+        (GtkPort._driver_class):
+        (GtkPort):
+        (GtkPort.supports_per_test_timeout): Moved to Port.
+        * Scripts/webkitpy/port/ios.py:
+        (IOSPort):
+        (IOSPort.operating_system):
+        (IOSSimulatorPort):
+        (IOSSimulatorPort.__init__): Inherits from DarwinPort.
+        (IOSSimulatorPort._port_specific_expectations_files): Moved to DarwinPort.
+        (IOSSimulatorPort._get_crash_log): Deleted.
+        (IOSSimulatorPort.xcrun_find): Deleted.
+        * Scripts/webkitpy/port/ios_unittest.py: Added.
+        (iosTest): Unit tests for the iOS port.
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort):
+        (MacPort.__init__): Inherits from DarwinPort.
+        (MacPort._port_specific_expectations_files): Moved to DarwinPort.
+        (MacPort.make_command): Moved to DarwinPort.
+        (MacPort._get_crash_log): Moved to DarwinPort.
+        (MacPort.nm_command): Moved to DarwinPort.
+        * Scripts/webkitpy/port/mac_unittest.py:
+        (MacTest):
+        (MacTest.test_sdk_name): Added test.
+        (MacTest.test_xcrun): Added test.
+        (MacTest.assert_skipped_file_search_paths): Moved to DarwinTest.
+        (MacTest.test_default_timeout_ms): Moved to DarwinTest.
+        (MacTest.assert_name): Moved to DarwinTest.
+        (MacTest.test_helper_starts): Moved to DarwinTest.
+        (MacTest.test_helper_fails_to_start): Moved to DarwinTest.
+        (MacTest.test_helper_fails_to_stop): Moved to DarwinTest.
+        (MacTest.test_spindump): Moved to DarwinTest.
+        (MacTest.test_sample_process): Moved to DarwinTest.
+        (MacTest.test_sample_process_exception): Moved to DarwinTest.
+        * Scripts/webkitpy/port/port_testcase.py:
+        (PortTestCase):
+        (PortTestCase.test_diff_image): Added is_simulator flag.
+        (PortTestCase.test_diff_image): Skip test if on a simulator.
+        (PortTestCase.test_diff_image_crashed): Skip test if on a simulator.
+        * Scripts/webkitpy/port/win.py:
+        (WinPort):
+        (WinPort.look_for_new_samples): Used default, ApplePort no longer implements.
+        (WinPort.sample_process): Ditto.
+        (WinPort._make_leak_detector): Ditto.
+        (WinPort.check_for_leaks): Ditto.
+        (WinPort.print_leaks_summary): Ditto.
+        (WinPort._path_to_webcore_library): Ditto.
+
 2016-10-07  Anders Carlsson  <andersca@apple.com>
 
         Get rid of WKPageSetSession
index 3abb6c4..96ad09c 100644 (file)
@@ -33,7 +33,6 @@ from webkitpy.common.system.crashlogs import CrashLogs
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.port.base import Port
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
-from webkitpy.port.leakdetector import LeakDetector
 
 
 _log = logging.getLogger(__name__)
@@ -61,6 +60,11 @@ class ApplePort(Port):
     def determine_full_port_name(cls, host, options, port_name):
         options = options or {}
         if port_name in (cls.port_name, cls.port_name + '-wk2'):
+
+            # Since IOS simulator run on mac, they need a special check
+            if host.platform.os_name == 'mac' and 'ios-simulator' in port_name:
+                return port_name
+
             # If the port_name matches the (badly named) cls.port_name, that
             # means that they passed 'mac' or 'win' and didn't specify a version.
             # That convention means that we're supposed to use the version currently
@@ -89,23 +93,11 @@ class ApplePort(Port):
         port_name = port_name.replace('-wk2', '')
         self._version = self._strip_port_name_prefix(port_name)
 
-        self._leak_detector = self._make_leak_detector()
-        if self.get_option("leaks"):
-            # DumpRenderTree slows down noticably if we run more than about 1000 tests in a batch
-            # with MallocStackLogging enabled.
-            self.set_option_default("batch_size", 1000)
-
-    def _make_leak_detector(self):
-        return LeakDetector(self)
-
     def default_timeout_ms(self):
         if self.get_option('guard_malloc'):
             return 350 * 1000
         return super(ApplePort, self).default_timeout_ms()
 
-    def supports_per_test_timeout(self):
-        return True
-
     def should_retry_crashes(self):
         return True
 
@@ -129,113 +121,6 @@ class ApplePort(Port):
                     configurations.append(TestConfiguration(version=self._strip_port_name_prefix(port_name), architecture=architecture, build_type=build_type))
         return configurations
 
-    def check_for_leaks(self, process_name, process_pid):
-        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)
-
-    def print_leaks_summary(self):
-        if not self.get_option('leaks'):
-            return
-        # We're in the manager process, so the leak detector will not have a valid list of leak files.
-        # FIXME: This is a hack, but we don't have a better way to get this information from the workers yet.
-        # FIXME: This will include too many leaks in subsequent runs until the results directory is cleared!
-        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.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 _path_to_webcore_library(self):
-        return self._build_path('WebCore.framework/Versions/A/WebCore')
-
-    def show_results_html_file(self, results_filename):
-        # We don't use self._run_script() because we don't want to wait for the script
-        # to exit and we want the output to show up on stdout in case there are errors
-        # launching the browser.
-        self._executive.popen([self.path_to_script('run-safari')] + self._arguments_for_configuration() + ['--no-saved-state', '-NSOpen', results_filename],
-            cwd=self.webkit_base(), stdout=file(os.devnull), stderr=file(os.devnull))
-
-    def _merge_crash_logs(self, logs, new_logs, crashed_processes):
-        for test, crash_log in new_logs.iteritems():
-            try:
-                process_name = test.split("-")[0]
-                pid = int(test.split("-")[1])
-            except IndexError:
-                continue
-            if not any(entry[1] == process_name and entry[2] == pid for entry in crashed_processes):
-                # if this is a new crash, then append the logs
-                logs[test] = crash_log
-        return logs
-
-    def _look_for_all_crash_logs_in_log_dir(self, newer_than):
-        crash_log = CrashLogs(self.host)
-        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, sleep_fn, wait_for_log):
-        return None
-
-    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
-           under stress do a second pass at the end of the test run.
-
-           crashes: test_name -> pid, process_name tuple of crashed process
-           start_time: time the tests started at.  We're looking for crash
-               logs after that time.
-        """
-        crash_logs = {}
-        for (test_name, process_name, pid) in crashed_processes:
-            # Passing None for output.  This is a second pass after the test finished so
-            # if the output had any logging we would have already collected it.
-            crash_log = self._get_crash_log(process_name, pid, None, None, start_time, wait_for_log=False)[1]
-            if not crash_log:
-                continue
-            crash_logs[test_name] = crash_log
-        all_crash_log = self._look_for_all_crash_logs_in_log_dir(start_time)
-        return self._merge_crash_logs(crash_logs, all_crash_log, crashed_processes)
-
-    def sample_process(self, name, pid):
-        exit_status = self._executive.run_command([
-            "/usr/bin/sudo",
-            "-n",
-            "/usr/sbin/spindump",
-            pid,
-            10,
-            10,
-            "-file",
-            self.spindump_file_path(name, pid),
-        ], return_exit_code=True)
-        if exit_status:
-            try:
-                self._executive.run_command([
-                    "/usr/bin/sample",
-                    pid,
-                    10,
-                    10,
-                    "-file",
-                    self.sample_file_path(name, pid),
-                ])
-            except ScriptError as e:
-                _log.warning('Unable to sample process:' + str(e))
-
-    def sample_file_path(self, name, pid):
-        return self._filesystem.join(self.results_directory(), "{0}-{1}-sample.txt".format(name, pid))
-
-    def spindump_file_path(self, name, pid):
-        return self._filesystem.join(self.results_directory(), "{0}-{1}-spindump.txt".format(name, pid))
-
-    def look_for_new_samples(self, unresponsive_processes, start_time):
-        sample_files = {}
-        for (test_name, process_name, pid) in unresponsive_processes:
-            sample_file = self.sample_file_path(process_name, pid)
-            if not self._filesystem.isfile(sample_file):
-                continue
-            sample_files[test_name] = sample_file
-        return sample_files
-
     def _path_to_helper(self):
         binary_name = 'LayoutTestHelper'
         return self._build_path(binary_name)
index 8841b0c..321559f 100644 (file)
@@ -153,9 +153,7 @@ class Port(object):
         return []
 
     def supports_per_test_timeout(self):
-        # FIXME: Make per-test timeouts unconditional once all ports' DumpRenderTrees support that.
-        # Windows DumpRenderTree may be the only one remaining to be fixed at this time.
-        return False
+        return True
 
     def default_pixel_tests(self):
         # FIXME: Disable until they are run by default on build.webkit.org.
diff --git a/Tools/Scripts/webkitpy/port/darwin.py b/Tools/Scripts/webkitpy/port/darwin.py
new file mode 100644 (file)
index 0000000..60564ae
--- /dev/null
@@ -0,0 +1,176 @@
+# Copyright (C) 2014-2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# 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 logging
+import os
+import time
+
+from webkitpy.common.system.crashlogs import CrashLogs
+from webkitpy.common.system.executive import ScriptError
+from webkitpy.port.apple import ApplePort
+from webkitpy.port.leakdetector import LeakDetector
+
+
+_log = logging.getLogger(__name__)
+
+
+class DarwinPort(ApplePort):
+
+    SDK = None
+
+    def __init__(self, host, port_name, **kwargs):
+        ApplePort.__init__(self, host, port_name, **kwargs)
+
+        self._leak_detector = LeakDetector(self)
+        if self.get_option("leaks"):
+            # DumpRenderTree slows down noticably if we run more than about 1000 tests in a batch
+            # with MallocStackLogging enabled.
+            self.set_option_default("batch_size", 1000)
+
+    def default_timeout_ms(self):
+        if self.get_option('guard_malloc'):
+            return 350 * 1000
+        return super(DarwinPort, self).default_timeout_ms()
+
+    def _port_specific_expectations_files(self):
+        return list(reversed([self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in self.baseline_search_path()]))
+
+    def check_for_leaks(self, process_name, process_pid):
+        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)
+
+    def print_leaks_summary(self):
+        if not self.get_option('leaks'):
+            return
+        # We're in the manager process, so the leak detector will not have a valid list of leak files.
+        # FIXME: This is a hack, but we don't have a better way to get this information from the workers yet.
+        # FIXME: This will include too many leaks in subsequent runs until the results directory is cleared!
+        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.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 _path_to_webcore_library(self):
+        return self._build_path('WebCore.framework/Versions/A/WebCore')
+
+    def show_results_html_file(self, results_filename):
+        # We don't use self._run_script() because we don't want to wait for the script
+        # to exit and we want the output to show up on stdout in case there are errors
+        # launching the browser.
+        self._executive.popen([self.path_to_script('run-safari')] + self._arguments_for_configuration() + ['--no-saved-state', '-NSOpen', results_filename],
+            cwd=self.webkit_base(), stdout=file(os.devnull), stderr=file(os.devnull))
+
+    def _merge_crash_logs(self, logs, new_logs, crashed_processes):
+        for test, crash_log in new_logs.iteritems():
+            try:
+                process_name = test.split("-")[0]
+                pid = int(test.split("-")[1])
+            except IndexError:
+                continue
+            if not any(entry[1] == process_name and entry[2] == pid for entry in crashed_processes):
+                # if this is a new crash, then append the logs
+                logs[test] = crash_log
+        return logs
+
+    def _look_for_all_crash_logs_in_log_dir(self, newer_than):
+        crash_log = CrashLogs(self.host)
+        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 None
+
+    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
+           under stress do a second pass at the end of the test run.
+
+           crashes: test_name -> pid, process_name tuple of crashed process
+           start_time: time the tests started at.  We're looking for crash
+               logs after that time.
+        """
+        crash_logs = {}
+        for (test_name, process_name, pid) in crashed_processes:
+            # Passing None for output.  This is a second pass after the test finished so
+            # if the output had any logging we would have already collected it.
+            crash_log = self._get_crash_log(process_name, pid, None, None, start_time, wait_for_log=False)[1]
+            if not crash_log:
+                continue
+            crash_logs[test_name] = crash_log
+        all_crash_log = self._look_for_all_crash_logs_in_log_dir(start_time)
+        return self._merge_crash_logs(crash_logs, all_crash_log, crashed_processes)
+
+    def sample_process(self, name, pid):
+        exit_status = self._executive.run_command([
+            "/usr/bin/sudo",
+            "-n",
+            "/usr/sbin/spindump",
+            pid,
+            10,
+            10,
+            "-file",
+            self.spindump_file_path(name, pid),
+        ], return_exit_code=True)
+        if exit_status:
+            try:
+                self._executive.run_command([
+                    "/usr/bin/sample",
+                    pid,
+                    10,
+                    10,
+                    "-file",
+                    self.sample_file_path(name, pid),
+                ])
+            except ScriptError as e:
+                _log.warning('Unable to sample process:' + str(e))
+
+    def sample_file_path(self, name, pid):
+        return self._filesystem.join(self.results_directory(), "{0}-{1}-sample.txt".format(name, pid))
+
+    def spindump_file_path(self, name, pid):
+        return self._filesystem.join(self.results_directory(), "{0}-{1}-spindump.txt".format(name, pid))
+
+    def look_for_new_samples(self, unresponsive_processes, start_time):
+        sample_files = {}
+        for (test_name, process_name, pid) in unresponsive_processes:
+            sample_file = self.sample_file_path(process_name, pid)
+            if not self._filesystem.isfile(sample_file):
+                continue
+            sample_files[test_name] = sample_file
+        return sample_files
+
+    def make_command(self):
+        return self.xcrun_find('make', '/usr/bin/make')
+
+    def nm_command(self):
+        return self.xcrun_find('nm', 'nm')
+
+    def xcrun_find(self, command, fallback=None):
+        fallback = fallback or command
+        try:
+            return self._executive.run_command(['xcrun', '--sdk', self.SDK, '-find', command]).rstrip()
+        except ScriptError:
+            _log.warn("xcrun failed; falling back to '%s'." % fallback)
+            return fallback
diff --git a/Tools/Scripts/webkitpy/port/darwin_testcase.py b/Tools/Scripts/webkitpy/port/darwin_testcase.py
new file mode 100644 (file)
index 0000000..52b7805
--- /dev/null
@@ -0,0 +1,121 @@
+# Copyright (C) 2014-2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# 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.
+
+from webkitpy.port import port_testcase
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.tool.mocktool import MockOptions
+from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, MockProcess, ScriptError
+from webkitpy.common.system.systemhost_mock import MockSystemHost
+
+
+class DarwinTest(port_testcase.PortTestCase):
+
+    def assert_skipped_file_search_paths(self, port_name, expected_paths, use_webkit2=False):
+        port = self.make_port(port_name=port_name, options=MockOptions(webkit_test_runner=use_webkit2))
+        self.assertEqual(port._skipped_file_search_paths(), expected_paths)
+
+    def test_default_timeout_ms(self):
+        super(DarwinTest, self).test_default_timeout_ms()
+        self.assertEqual(self.make_port(options=MockOptions(guard_malloc=True)).default_timeout_ms(), 350000)
+
+    def assert_name(self, port_name, os_version_string, expected):
+        host = MockSystemHost(os_name=self.os_name, os_version=os_version_string)
+        port = self.make_port(host=host, port_name=port_name)
+        self.assertEqual(expected, port.name())
+
+    def test_show_results_html_file(self):
+        port = self.make_port()
+        # Delay setting a should_log executive to avoid logging from MacPort.__init__.
+        port._executive = MockExecutive(should_log=True)
+        expected_logs = "MOCK popen: ['Tools/Scripts/run-safari', '--release', '--no-saved-state', '-NSOpen', 'test.html'], cwd=/mock-checkout\n"
+        OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_logs=expected_logs)
+
+    def test_helper_starts(self):
+        host = MockSystemHost(MockExecutive())
+        port = self.make_port(host)
+        oc = OutputCapture()
+        oc.capture_output()
+        host.executive._proc = MockProcess('ready\n')
+        port.start_helper()
+        port.stop_helper()
+        oc.restore_output()
+
+        # make sure trying to stop the helper twice is safe.
+        port.stop_helper()
+
+    def test_helper_fails_to_start(self):
+        host = MockSystemHost(MockExecutive())
+        port = self.make_port(host)
+        oc = OutputCapture()
+        oc.capture_output()
+        port.start_helper()
+        port.stop_helper()
+        oc.restore_output()
+
+    def test_helper_fails_to_stop(self):
+        host = MockSystemHost(MockExecutive())
+        host.executive._proc = MockProcess()
+
+        def bad_waiter():
+            raise IOError('failed to wait')
+        host.executive._proc.wait = bad_waiter
+
+        port = self.make_port(host)
+        oc = OutputCapture()
+        oc.capture_output()
+        port.start_helper()
+        port.stop_helper()
+        oc.restore_output()
+
+    def test_spindump(self):
+
+        def logging_run_command(args):
+            print args
+
+        port = self.make_port()
+        port._executive = MockExecutive2(run_command_fn=logging_run_command)
+        expected_stdout = "['/usr/bin/sudo', '-n', '/usr/sbin/spindump', 42, 10, 10, '-file', '/mock-build/layout-test-results/test-42-spindump.txt']\n"
+        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
+
+    def test_sample_process(self):
+
+        def logging_run_command(args):
+            if args[0] == '/usr/bin/sudo':
+                return 1
+            print args
+            return 0
+
+        port = self.make_port()
+        port._executive = MockExecutive2(run_command_fn=logging_run_command)
+        expected_stdout = "['/usr/bin/sample', 42, 10, 10, '-file', '/mock-build/layout-test-results/test-42-sample.txt']\n"
+        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
+
+    def test_sample_process_exception(self):
+        def throwing_run_command(args):
+            if args[0] == '/usr/bin/sudo':
+                return 1
+            raise ScriptError("MOCK script error")
+
+        port = self.make_port()
+        port._executive = MockExecutive2(run_command_fn=throwing_run_command)
+        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42])
index 6a3ca33..deb34ff 100644 (file)
@@ -80,9 +80,6 @@ class EflPort(Port):
 
         return env
 
-    def supports_per_test_timeout(self):
-        return True
-
     def default_timeout_ms(self):
         # Tests run considerably slower under gdb
         # or valgrind.
index c8a96a7..27ba640 100644 (file)
@@ -86,9 +86,6 @@ class GtkPort(Port):
             return XorgDriver
         return XvfbDriver
 
-    def supports_per_test_timeout(self):
-        return True
-
     def default_timeout_ms(self):
         # Starting an application under Valgrind takes a lot longer than normal
         # so increase the timeout (empirically 10x is enough to avoid timeouts).
index 7a58eda..cbfcc72 100644 (file)
@@ -29,20 +29,19 @@ import subprocess
 import time
 
 from webkitpy.common.memoized import memoized
-from webkitpy.common.system.crashlogs import CrashLogs
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
 from webkitpy.port import config as port_config
 from webkitpy.port import driver, image_diff
-from webkitpy.port.apple import ApplePort
-from webkitpy.port.base import Port
+from webkitpy.port.darwin import DarwinPort
 from webkitpy.xcode.simulator import Simulator, Runtime, DeviceType
+from webkitpy.common.system.crashlogs import CrashLogs
 
 
 _log = logging.getLogger(__name__)
 
 
-class IOSPort(ApplePort):
+class IOSPort(DarwinPort):
     port_name = "ios"
 
     ARCHITECTURES = ['armv7', 'armv7s', 'arm64']
@@ -67,7 +66,7 @@ class IOSPort(ApplePort):
         return 'ios'
 
 
-class IOSSimulatorPort(ApplePort):
+class IOSSimulatorPort(DarwinPort):
     port_name = "ios-simulator"
 
     FUTURE_VERSION = 'future'
@@ -76,6 +75,7 @@ class IOSSimulatorPort(ApplePort):
 
     DEFAULT_DEVICE_CLASS = 'iphone'
     CUSTOM_DEVICE_CLASSES = ['ipad']
+    SDK = 'iphonesimulator'
 
     SIMULATOR_BUNDLE_ID = 'com.apple.iphonesimulator'
     relay_name = 'LayoutTestRelay'
@@ -95,7 +95,7 @@ class IOSSimulatorPort(ApplePort):
     }
 
     def __init__(self, host, port_name, **kwargs):
-        super(IOSSimulatorPort, self).__init__(host, port_name, **kwargs)
+        DarwinPort.__init__(self, host, port_name, **kwargs)
 
         optional_device_class = self.get_option('device_class')
         self._printing_cmd_line = False
@@ -228,9 +228,6 @@ class IOSSimulatorPort(ApplePort):
 
         return map(self._webkit_baseline_path, fallback_names)
 
-    def _port_specific_expectations_files(self):
-        return list(reversed([self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in self.baseline_search_path()]))
-
     def _set_device_class(self, device_class):
         self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
 
@@ -343,44 +340,6 @@ class IOSSimulatorPort(ApplePort):
 
     SUBPROCESS_CRASH_REGEX = re.compile('#CRASHED - (?P<subprocess_name>\S+) \(pid (?P<subprocess_pid>\d+)\)')
 
-    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 _create_device(self, number):
         return Simulator.create_device(number, self.simulator_device_type(), self.simulator_runtime)
 
@@ -419,14 +378,6 @@ class IOSSimulatorPort(ApplePort):
     def nm_command(self):
         return self.xcrun_find('nm')
 
-    def xcrun_find(self, command, fallback=None):
-        fallback = fallback or command
-        try:
-            return self._executive.run_command(['xcrun', '--sdk', 'iphonesimulator', '-find', command]).rstrip()
-        except ScriptError:
-            _log.warn("xcrun failed; falling back to '%s'." % fallback)
-            return fallback
-
     @property
     @memoized
     def developer_dir(self):
diff --git a/Tools/Scripts/webkitpy/port/ios_unittest.py b/Tools/Scripts/webkitpy/port/ios_unittest.py
new file mode 100644 (file)
index 0000000..fdf8e6c
--- /dev/null
@@ -0,0 +1,99 @@
+# Copyright (C) 2014-2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# 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.ios import IOSSimulatorPort
+from webkitpy.port import darwin_testcase
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.tool.mocktool import MockOptions
+from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, MockProcess, ScriptError
+from webkitpy.common.system.systemhost_mock import MockSystemHost
+
+
+class iosTest(darwin_testcase.DarwinTest):
+    os_name = 'ios-simulator'
+    os_version = ''
+    port_name = 'ios-simulator'
+    port_maker = IOSSimulatorPort
+    is_simulator = True
+
+    def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=None, **kwargs):
+        port = super(iosTest, self).make_port(host=host, port_name=port_name, options=options, os_name=os_name, s_version=os_version, kwargs=kwargs)
+        port.set_option('child_processes', 1)
+        return port
+
+    def test_setup_environ_for_server(self):
+        port = self.make_port(options=MockOptions(leaks=True, guard_malloc=True))
+        env = port.setup_environ_for_server(port.driver_name())
+        self.assertEqual(env['MallocStackLogging'], '1')
+        self.assertEqual(env['MallocScribble'], '1')
+        self.assertEqual(env['DYLD_INSERT_LIBRARIES'], '/usr/lib/libgmalloc.dylib')
+
+    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='ios-simulator')
+        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'))
+
+        def run_script(script, args=None, env=None):
+            self.args = args
+
+        port._run_script = run_script
+        self.assertEqual(port.architecture(), 'x86')
+        port._build_driver()
+        self.assertEqual(self.args, ['--ios-simulator'])
+
+    def test_64bit(self):
+        # Apple Mac port is 64-bit by default
+        port = self.make_port()
+        self.assertEqual(port.architecture(), 'x86_64')
+
+        def run_script(script, args=None, env=None):
+            self.args = args
+
+        port._run_script = run_script
+        port._build_driver()
+        self.assertEqual(self.args, ['--ios-simulator'])
+
+    def test_sdk_name(self):
+        port = self.make_port()
+        self.assertEqual(port.SDK, 'iphonesimulator')
+
+    def test_xcrun(self):
+        def throwing_run_command(args):
+            print args
+            raise ScriptError("MOCK script error")
+
+        port = self.make_port()
+        port._executive = MockExecutive2(run_command_fn=throwing_run_command)
+        expected_stdout = "['xcrun', '--sdk', 'iphonesimulator', '-find', 'test']\n"
+        OutputCapture().assert_outputs(self, port.xcrun_find, args=['test', 'falling'], expected_stdout=expected_stdout)
index dc38b58..06e9ffa 100644 (file)
@@ -34,22 +34,23 @@ import re
 
 from webkitpy.common.system.crashlogs import CrashLogs
 from webkitpy.common.system.executive import ScriptError
-from webkitpy.port.apple import ApplePort
+from webkitpy.port.darwin import DarwinPort
 
 _log = logging.getLogger(__name__)
 
 
-class MacPort(ApplePort):
+class MacPort(DarwinPort):
     port_name = "mac"
 
     VERSION_FALLBACK_ORDER = ['mac-snowleopard', 'mac-lion', 'mac-mountainlion', 'mac-mavericks', 'mac-yosemite', 'mac-elcapitan', 'mac-sierra']
+    SDK = 'macosx'
 
     ARCHITECTURES = ['x86_64', 'x86']
 
     DEFAULT_ARCHITECTURE = 'x86_64'
 
     def __init__(self, host, port_name, **kwargs):
-        super(MacPort, self).__init__(host, port_name, **kwargs)
+        DarwinPort.__init__(self, host, port_name, **kwargs)
 
     def _build_driver_flags(self):
         return ['ARCHS=i386'] if self.architecture() == 'x86' else []
@@ -66,9 +67,6 @@ class MacPort(ApplePort):
             fallback_names = [self._wk2_port_name(), 'wk2'] + fallback_names
         return map(self._webkit_baseline_path, fallback_names)
 
-    def _port_specific_expectations_files(self):
-        return list(reversed([self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in self.baseline_search_path()]))
-
     def configuration_specifier_macros(self):
         return {
             "sierra+": ["sierra", "future"],
@@ -152,9 +150,6 @@ class MacPort(ApplePort):
             supportable_instances = default_count
         return min(supportable_instances, default_count)
 
-    def make_command(self):
-        return self.xcrun_find('make', '/usr/bin/make')
-
     def _build_java_test_support(self):
         # FIXME: This is unused. Remove.
         java_tests_path = self._filesystem.join(self.layout_tests_dir(), "java")
@@ -167,31 +162,6 @@ class MacPort(ApplePort):
     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:
@@ -229,16 +199,6 @@ class MacPort(ApplePort):
                 _log.debug("IOError raised while stopping helper: %s" % str(e))
             self._helper = None
 
-    def nm_command(self):
-        return self.xcrun_find('nm', 'nm')
-
-    def xcrun_find(self, command, fallback):
-        try:
-            return self._executive.run_command(['xcrun', '-find', command]).rstrip()
-        except ScriptError:
-            _log.warn("xcrun failed; falling back to '%s'." % fallback)
-            return fallback
-
     def logging_patterns_to_strip(self):
         # FIXME: Remove this after <rdar://problem/15605007> is fixed
         return [(re.compile('(AVF|GVA) info:.*\n'), '')]
index 1738a23..a33dc86 100644 (file)
@@ -1,4 +1,5 @@
 # Copyright (C) 2010 Google Inc. All rights reserved.
+# Copyright (C) 2014-2016 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # (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.mac import MacPort
-from webkitpy.port import port_testcase
+from webkitpy.port import darwin_testcase
 from webkitpy.common.system.filesystem_mock import MockFileSystem
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.mocktool import MockOptions
@@ -35,25 +38,12 @@ from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2,
 from webkitpy.common.system.systemhost_mock import MockSystemHost
 
 
-class MacTest(port_testcase.PortTestCase):
+class MacTest(darwin_testcase.DarwinTest):
     os_name = 'mac'
     os_version = 'lion'
     port_name = 'mac-lion'
     port_maker = MacPort
 
-    def assert_skipped_file_search_paths(self, port_name, expected_paths, use_webkit2=False):
-        port = self.make_port(port_name=port_name, options=MockOptions(webkit_test_runner=use_webkit2))
-        self.assertEqual(port._skipped_file_search_paths(), expected_paths)
-
-    def test_default_timeout_ms(self):
-        super(MacTest, self).test_default_timeout_ms()
-        self.assertEqual(self.make_port(options=MockOptions(guard_malloc=True)).default_timeout_ms(), 350000)
-
-    def assert_name(self, port_name, os_version_string, expected):
-        host = MockSystemHost(os_name='mac', os_version=os_version_string)
-        port = self.make_port(host=host, port_name=port_name)
-        self.assertEqual(expected, port.name())
-
     def test_tests_for_other_platforms(self):
         platforms = ['mac', 'mac-snowleopard']
         port = self.make_port(port_name='mac-snowleopard')
@@ -157,78 +147,7 @@ class MacTest(port_testcase.PortTestCase):
             times = [0, 20, 40]
             return lambda: times.pop(0)
         port = self.make_port(port_name='mac-snowleopard')
-        port._get_crash_log('DumpRenderTree', 1234, '', '', 0,
-            time_fn=fake_time_cb(), sleep_fn=lambda delay: None)
-
-    def test_helper_starts(self):
-        host = MockSystemHost(MockExecutive())
-        port = self.make_port(host)
-        oc = OutputCapture()
-        oc.capture_output()
-        host.executive._proc = MockProcess('ready\n')
-        port.start_helper()
-        port.stop_helper()
-        oc.restore_output()
-
-        # make sure trying to stop the helper twice is safe.
-        port.stop_helper()
-
-    def test_helper_fails_to_start(self):
-        host = MockSystemHost(MockExecutive())
-        port = self.make_port(host)
-        oc = OutputCapture()
-        oc.capture_output()
-        port.start_helper()
-        port.stop_helper()
-        oc.restore_output()
-
-    def test_helper_fails_to_stop(self):
-        host = MockSystemHost(MockExecutive())
-        host.executive._proc = MockProcess()
-
-        def bad_waiter():
-            raise IOError('failed to wait')
-        host.executive._proc.wait = bad_waiter
-
-        port = self.make_port(host)
-        oc = OutputCapture()
-        oc.capture_output()
-        port.start_helper()
-        port.stop_helper()
-        oc.restore_output()
-
-    def test_spindump(self):
-
-        def logging_run_command(args):
-            print args
-
-        port = self.make_port()
-        port._executive = MockExecutive2(run_command_fn=logging_run_command)
-        expected_stdout = "['/usr/bin/sudo', '-n', '/usr/sbin/spindump', 42, 10, 10, '-file', '/mock-build/layout-test-results/test-42-spindump.txt']\n"
-        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
-
-    def test_sample_process(self):
-
-        def logging_run_command(args):
-            if args[0] == '/usr/bin/sudo':
-                return 1
-            print args
-            return 0
-
-        port = self.make_port()
-        port._executive = MockExecutive2(run_command_fn=logging_run_command)
-        expected_stdout = "['/usr/bin/sample', 42, 10, 10, '-file', '/mock-build/layout-test-results/test-42-sample.txt']\n"
-        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
-
-    def test_sample_process_exception(self):
-        def throwing_run_command(args):
-            if args[0] == '/usr/bin/sudo':
-                return 1
-            raise ScriptError("MOCK script error")
-
-        port = self.make_port()
-        port._executive = MockExecutive2(run_command_fn=throwing_run_command)
-        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42])
+        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'))
@@ -252,3 +171,17 @@ class MacTest(port_testcase.PortTestCase):
         port._run_script = run_script
         port._build_driver()
         self.assertEqual(self.args, [])
+
+    def test_sdk_name(self):
+        port = self.make_port()
+        self.assertEqual(port.SDK, 'macosx')
+
+    def test_xcrun(self):
+        def throwing_run_command(args):
+            print args
+            raise ScriptError("MOCK script error")
+
+        port = self.make_port()
+        port._executive = MockExecutive2(run_command_fn=throwing_run_command)
+        expected_stdout = "['xcrun', '--sdk', 'macosx', '-find', 'test']\n"
+        OutputCapture().assert_outputs(self, port.xcrun_find, args=['test', 'falling'], expected_stdout=expected_stdout)
index 7830839..79856ed 100644 (file)
@@ -1,4 +1,5 @@
 # Copyright (C) 2010 Google Inc. All rights reserved.
+# Copyright (C) 2014-2016 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -81,6 +82,7 @@ class PortTestCase(unittest.TestCase):
     os_version = None
     port_maker = TestWebKitPort
     port_name = None
+    is_simulator = False
 
     def make_port(self, host=None, port_name=None, options=None, os_name=None, os_version=None, **kwargs):
         host = host or MockSystemHost(os_name=(os_name or self.os_name), os_version=(os_version or self.os_version))
@@ -250,6 +252,10 @@ class PortTestCase(unittest.TestCase):
             self.proc = MockServerProcess(port, nm, cmd, env, lines=['diff: 100% failed\n', 'diff: 100% failed\n'])
             return self.proc
 
+        # FIXME: Can't pretend to run a simulator's setup, so just skip this test.
+        if self.is_simulator:
+            return
+
         port._server_process_constructor = make_proc
         port.setup_test_run()
         self.assertEqual(port.diff_image('foo', 'bar'), ('', 100.0, None))
@@ -273,6 +279,10 @@ class PortTestCase(unittest.TestCase):
             self.proc = MockServerProcess(port, nm, cmd, env, crashed=True)
             return self.proc
 
+        # FIXME: Can't pretend to run a simulator's setup, so just skip this test.
+        if self.is_simulator:
+            return
+
         port._server_process_constructor = make_proc
         port.setup_test_run()
         self.assertEqual(port.diff_image('foo', 'bar'), ('', 0, 'ImageDiff crashed\n'))
index d2938e6..91d001a 100644 (file)
@@ -404,28 +404,6 @@ class WinPort(ApplePort):
                 crash_logs[test_name] = crash_log
         return crash_logs
 
-    def look_for_new_samples(self, unresponsive_processes, start_time):
-        # No sampling on Windows.
-        pass
-
-    def sample_process(self, name, pid):
-        # No sampling on Windows.
-        pass
-
-    def _make_leak_detector(self):
-        return None
-
-    def check_for_leaks(self, process_name, process_pid):
-        # No leak checking on Windows.
-        pass
-
-    def print_leaks_summary(self):
-        # No leak checking on Windows.
-        pass
-
-    def _path_to_webcore_library(self):
-        return None
-
     def find_system_pid(self, name, pid):
         system_pid = int(pid)