Changeset 217946 in webkit


Ignore:
Timestamp:
Jun 8, 2017 1:39:00 PM (7 years ago)
Author:
Jonathan Bedard
Message:

webkitpy: Run sample/spindump on iOS devices
https://bugs.webkit.org/show_bug.cgi?id=171881
<rdar://problem/32084602>

Reviewed by Daniel Bates.

  • Scripts/webkitpy/port/darwin.py:

(DarwinPort.sample_process): Only add sudo prefix if the platform is Mac, which
requires sudo to run spindump.

  • Scripts/webkitpy/port/ios_device.py:

(IOSDevicePort.look_for_new_samples): Deleted.
(IOSDevicePort.sample_process): Deleted.

  • Scripts/webkitpy/port/ios_device_unittest.py:

(IOSDeviceTest): iOS devices use 'ios' and their os_name.
(IOSDeviceTest.test_spindump):
(IOSDeviceTest.test_sample_process):
(IOSDeviceTest.test_sample_process_exception):

  • Scripts/webkitpy/port/ios_simulator_unittest.py:

(IOSSimulatorTest): iOS Simulators run on Mac and use 'mac' as their os_name.

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r217942 r217946  
     12017-06-08  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkitpy: Run sample/spindump on iOS devices
     4        https://bugs.webkit.org/show_bug.cgi?id=171881
     5        <rdar://problem/32084602>
     6
     7        Reviewed by Daniel Bates.
     8
     9        * Scripts/webkitpy/port/darwin.py:
     10        (DarwinPort.sample_process): Only add sudo prefix if the platform is Mac, which
     11        requires sudo to run spindump.
     12        * Scripts/webkitpy/port/ios_device.py:
     13        (IOSDevicePort.look_for_new_samples): Deleted.
     14        (IOSDevicePort.sample_process): Deleted.
     15        * Scripts/webkitpy/port/ios_device_unittest.py:
     16        (IOSDeviceTest): iOS devices use 'ios' and their os_name.
     17        (IOSDeviceTest.test_spindump):
     18        (IOSDeviceTest.test_sample_process):
     19        (IOSDeviceTest.test_sample_process_exception):
     20        * Scripts/webkitpy/port/ios_simulator_unittest.py:
     21        (IOSSimulatorTest): iOS Simulators run on Mac and use 'mac' as their os_name.
     22
    1232017-06-08  Keith Miller  <keith_miller@apple.com>
    224
  • trunk/Tools/Scripts/webkitpy/port/darwin.py

    r217856 r217946  
    155155        host = target_host or self.host
    156156        tempdir = host.filesystem.mkdtemp()
    157         exit_status = host.executive.run_command([
    158             "/usr/bin/sudo",
    159             "-n",
    160             "/usr/sbin/spindump",
     157        command = [
     158            '/usr/sbin/spindump',
    161159            pid,
    162160            10,
    163161            10,
    164             "-file",
     162            '-file',
    165163            DarwinPort.spindump_file_path(host, name, pid, str(tempdir)),
    166         ], return_exit_code=True)
     164        ]
     165        if self.host.platform.is_mac():
     166            command = ['/usr/bin/sudo', '-n'] + command
     167        exit_status = host.executive.run_command(command, return_exit_code=True)
    167168        if exit_status:
    168169            try:
    169170                host.executive.run_command([
    170                     "/usr/bin/sample",
     171                    '/usr/bin/sample',
    171172                    pid,
    172173                    10,
    173174                    10,
    174                     "-file",
     175                    '-file',
    175176                    DarwinPort.sample_file_path(host, name, pid, str(tempdir)),
    176177                ])
  • trunk/Tools/Scripts/webkitpy/port/ios_device.py

    r217853 r217946  
    9696        pass
    9797
    98     def look_for_new_samples(self, unresponsive_processes, start_time):
    99         return {}
    100 
    101     def sample_process(self, name, pid, target_host=None):
    102         pass
    103 
    10498    # Despite their names, these flags do not actually get passed all the way down to webkit-build.
    10599    def _build_driver_flags(self):
  • trunk/Tools/Scripts/webkitpy/port/ios_device_unittest.py

    r217853 r217946  
    2323import time
    2424
     25from webkitpy.common.system.outputcapture import OutputCapture
     26from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
    2527from webkitpy.port.ios_device import IOSDevicePort
    2628from webkitpy.port import ios_testcase
     
    2830
    2931class IOSDeviceTest(ios_testcase.IOSTest):
    30     os_name = 'ios-device'
     32    os_name = 'ios'
    3133    os_version = ''
    3234    port_name = 'ios-device'
     
    4547            port.path_to_crash_logs()
    4648
     49    def test_spindump(self):
     50        def logging_run_command(args):
     51            print args
     52
     53        port = self.make_port()
     54        port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-spindump.txt'] = 'Spindump file'
     55        port.host.executive = MockExecutive2(run_command_fn=logging_run_command)
     56        expected_stdout = "['/usr/sbin/spindump', 42, 10, 10, '-file', '/__im_tmp/tmp_0_/test-42-spindump.txt']\n"
     57        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
     58        self.assertEqual(port.host.filesystem.files['/mock-build/layout-test-results/test-42-spindump.txt'], 'Spindump file')
     59        self.assertIsNone(port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-spindump.txt'])
     60
     61    def test_sample_process(self):
     62        def logging_run_command(args):
     63            if args[0] == '/usr/sbin/spindump':
     64                return 1
     65            print args
     66            return 0
     67
     68        port = self.make_port()
     69        port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-sample.txt'] = 'Sample file'
     70        port.host.executive = MockExecutive2(run_command_fn=logging_run_command)
     71        expected_stdout = "['/usr/bin/sample', 42, 10, 10, '-file', '/__im_tmp/tmp_0_/test-42-sample.txt']\n"
     72        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
     73        self.assertEqual(port.host.filesystem.files['/mock-build/layout-test-results/test-42-sample.txt'], 'Sample file')
     74        self.assertIsNone(port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-sample.txt'])
     75
     76    def test_sample_process_exception(self):
     77        def throwing_run_command(args):
     78            if args[0] == '/usr/sbin/spindump':
     79                return 1
     80            raise ScriptError('MOCK script error')
     81
     82        port = self.make_port()
     83        port.host.executive = MockExecutive2(run_command_fn=throwing_run_command)
     84        OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42])
     85
    4786    def test_get_crash_log(self):
    4887        port = self.make_port(port_name=self.port_name)
    4988        with self.assertRaises(RuntimeError):
    5089            port._get_crash_log('DumpRenderTree', 1234, None, None, time.time(), wait_for_log=False)
    51 
    52     # FIXME: Update tests when <rdar://problem/30497991> is completed.
    53     def test_spindump(self):
    54         pass
    55 
    56     def test_sample_process(self):
    57         pass
    58 
    59     def test_sample_process_exception(self):
    60         pass
  • trunk/Tools/Scripts/webkitpy/port/ios_simulator_unittest.py

    r216556 r217946  
    3131
    3232class IOSSimulatorTest(ios_testcase.IOSTest):
    33     os_name = 'ios-simulator'
     33    # FIXME: https://bugs.webkit.org/show_bug.cgi?id=173107
     34    os_name = 'mac'
    3435    os_version = ''
    3536    port_name = 'ios-simulator'
Note: See TracChangeset for help on using the changeset viewer.