⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 179712 in webkit


Ignore:
Timestamp:
Feb 5, 2015, 2:46:30 PM (12 years ago)
Author:
dbates@webkit.org
Message:

LayoutTestRelay does not install DumpRenderTree.app/WebKitTestRunnerApp.app
​https://bugs.webkit.org/show_bug.cgi?id=139746
<rdar://problem/19283658>

Reviewed by Alexey Proskuryakov.

Fixes an issues where LayoutTestRelay may fail to install DumpRenderTree.app/WebKitTestRunnerApp.app
if the simulator device is not in state Booted.

Currently run-webkit-test --ios-sim executes LayoutTestRelay immediately after
launching/relaunching the iOS Simulator app and a simulator app can only be installed
on a device that is in the Booted state. LayoutTestRelay may run before the
device is booted and hence fail to install DumpRenderTree.app/WebKitTestRunnerApp.app.
We should defer executing LayoutTestRelay until the simulator device booted by
iOS Simulator is in the Booted state.

  • Scripts/webkitpy/port/ios.py: Import webkitpy.xcode.simulator.Simulator to avoid prefixing

Simulator methods with the module name, simulator.
(IOSSimulatorPort.setup_test_run): Wait for the simulator device to be in the Booted state
after launching iOS Simulator. Also, wait until the simulator device is in the Shutdown state
before launching iOS Simulator to boot it.
(IOSSimulatorPort.testing_device): Fix up caller since we now import webkitpy.xcode.simulator.Simulator.
(IOSSimulatorPort.simulator_path): Deleted; moved this function to class Simulator and renamed to device_directory().

  • Scripts/webkitpy/xcode/simulator.py:

(Device.init): Remove parameter state and an instance variable of the same name, which represented
the state of the device when we created this object as part of parsing the output of simctl list. Callers
interested in the state of the device are more likely interested in the current state of the device as
opposed to the state of the device when the Device object was created.
(Device.state): Added; turn around and call Simulator.device_state() for the current state of the device.
(Device.path): Extracted implementation into Simulator.device_directory() so that it can be called
from both this function and Simulator.device_state().
(Device.create): Use Simulator.wait_until_device_is_in_state() to simplify the implementation of this function.
(Simulator.DeviceState): Added; class of constants.
(Simulator.wait_until_device_is_in_state): Added; this function does not return until the specified
device is in the specified state.
(Simulator.device_state): Added; parses the state of the device from the appropriate CoreSimulator device.plist file.
(Simulator.device_directory): Added.
(Simulator._parse_devices): Do not pass argument state to Device constructor as it no longer accepts it.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r179698 r179712  
     12015-02-05  Daniel Bates  <dabates@apple.com>
     2
     3        LayoutTestRelay does not install DumpRenderTree.app/WebKitTestRunnerApp.app
     4        https://bugs.webkit.org/show_bug.cgi?id=139746
     5        <rdar://problem/19283658>
     6
     7        Reviewed by Alexey Proskuryakov.
     8
     9        Fixes an issues where LayoutTestRelay may fail to install DumpRenderTree.app/WebKitTestRunnerApp.app
     10        if the simulator device is not in state Booted.
     11
     12        Currently run-webkit-test --ios-sim executes LayoutTestRelay immediately after
     13        launching/relaunching the iOS Simulator app and a simulator app can only be installed
     14        on a device that is in the Booted state. LayoutTestRelay may run before the
     15        device is booted and hence fail to install DumpRenderTree.app/WebKitTestRunnerApp.app.
     16        We should defer executing LayoutTestRelay until the simulator device booted by
     17        iOS Simulator is in the Booted state.
     18
     19        * Scripts/webkitpy/port/ios.py: Import webkitpy.xcode.simulator.Simulator to avoid prefixing
     20        Simulator methods with the module name, simulator.
     21        (IOSSimulatorPort.setup_test_run): Wait for the simulator device to be in the Booted state
     22        after launching iOS Simulator. Also, wait until the simulator device is in the Shutdown state
     23        before launching iOS Simulator to boot it.
     24        (IOSSimulatorPort.testing_device): Fix up caller since we now import webkitpy.xcode.simulator.Simulator.
     25        (IOSSimulatorPort.simulator_path): Deleted; moved this function to class Simulator and renamed to device_directory().
     26        * Scripts/webkitpy/xcode/simulator.py:
     27        (Device.__init__): Remove parameter state and an instance variable of the same name, which represented
     28        the state of the device when we created this object as part of parsing the output of `simctl list`. Callers
     29        interested in the state of the device are more likely interested in the current state of the device as
     30        opposed to the state of the device when the Device object was created.
     31        (Device.state): Added; turn around and call Simulator.device_state() for the current state of the device.
     32        (Device.path): Extracted implementation into Simulator.device_directory() so that it can be called
     33        from both this function and Simulator.device_state().
     34        (Device.create): Use Simulator.wait_until_device_is_in_state() to simplify the implementation of this function.
     35        (Simulator.DeviceState): Added; class of constants.
     36        (Simulator.wait_until_device_is_in_state): Added; this function does not return until the specified
     37        device is in the specified state.
     38        (Simulator.device_state): Added; parses the state of the device from the appropriate CoreSimulator device.plist file.
     39        (Simulator.device_directory): Added.
     40        (Simulator._parse_devices): Do not pass argument state to Device constructor as it no longer accepts it.
     41
    1422015-02-05  Alexey Proskuryakov  <ap@apple.com>
    243
  • trunk/Tools/Scripts/webkitpy/port/ios.py

    r179629 r179712  
    3737from webkitpy.port.leakdetector import LeakDetector
    3838from webkitpy.port import config as port_config
    39 from webkitpy.xcode import simulator
     39from webkitpy.xcode.simulator import Simulator
    4040
    4141
    … …  
    180180    def setup_test_run(self):
    181181        self._executive.run_command(['osascript', '-e', 'tell application "iOS Simulator" to quit'])
    182         time.sleep(2)
     182        device_udid = self.testing_device.udid
     183        Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
    183184        self._executive.run_command([
    184185            'open', '-a', os.path.join(self.developer_dir, 'Applications', 'iOS Simulator.app'),
    185             '--args', '-CurrentDeviceUDID', self.testing_device.udid])
     186            '--args', '-CurrentDeviceUDID', device_udid])
     187        Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.BOOTED)
    186188
    187189    def clean_up_test_run(self):
    … …  
    288290        device_type = self.get_option('device_type')
    289291        runtime = self.get_option('runtime')
    290         self._testing_device = simulator.Simulator().lookup_or_create_device(device_type.name + ' WebKit Tester', device_type, runtime)
     292        self._testing_device = Simulator().lookup_or_create_device(device_type.name + ' WebKit Tester', device_type, runtime)
    291293        return self.testing_device
    292 
    293     def simulator_path(self, udid):
    294         if udid:
    295             return os.path.realpath(os.path.expanduser(os.path.join('~/Library/Developer/CoreSimulator/Devices', udid)))
    296294
    297295    def look_for_new_crash_logs(self, crashed_processes, start_time):
  • trunk/Tools/Scripts/webkitpy/xcode/simulator.py

    r178925 r179712  
    22import logging
    33import os
     4import plistlib
    45import re
    56import subprocess
    … …  
    1415Do not use PyObjC to dlopen the framework.
    1516"""
    16 
    1717
    1818class DeviceType(object):
    … …  
    141141    """
    142142
    143     def __init__(self, name, udid, state, available, runtime):
     143    def __init__(self, name, udid, available, runtime):
    144144        """
    145145        :param name: The device name
    … …  
    147147        :param udid: The device UDID (a UUID string)
    148148        :type udid: str
    149         :param state: The last known device state
    150         :type state: str
    151149        :param available: Whether the device is available for use.
    152150        :type available: bool
    … …  
    156154        self.name = name
    157155        self.udid = udid
    158         self.state = state
    159156        self.available = available
    160157        self.runtime = runtime
    161158
    162159    @property
     160    def state(self):
     161        """
     162        :returns: The current state of the device.
     163        :rtype: Simulator.DeviceState
     164        """
     165        return Simulator.device_state(self.udid)
     166
     167    @property
    163168    def path(self):
    164169        """
    … …  
    166171        :rtype: str
    167172        """
    168         return os.path.realpath(
    169             os.path.expanduser(
    170                 os.path.join('~/Library/Developer/CoreSimulator/Devices', self.udid)))
     173        return Simulator.device_directory(self.udid)
    171174
    172175    @classmethod
    … …  
    183186        :rtype: Device
    184187        """
    185         sim = Simulator()
    186188        device_udid = subprocess.check_output(['xcrun', 'simctl', 'create', name, device_type.identifier, runtime.identifier]).rstrip()
    187         assert(device_udid)
    188         while True:
    189             sim.refresh()
    190             device = sim.find_device_by_udid(device_udid)
    191             if not device or device.state == 'Creating':
    192                 time.sleep(2)
    193                 continue
    194             return device
     189        Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
     190        return Simulator().find_device_by_udid(device_udid)
    195191
    196192    def __eq__(self, other):
    … …  
    228224        self.device_types = []
    229225        self.refresh()
     226
     227    # Keep these constants synchronized with the SimDeviceState constants in CoreSimulator/SimDevice.h.
     228    class DeviceState:
     229        DOES_NOT_EXIST = -1
     230        CREATING = 0
     231        SHUTDOWN = 1
     232        BOOTING = 2
     233        BOOTED = 3
     234        SHUTTING_DOWN = 4
     235
     236    @staticmethod
     237    def wait_until_device_is_in_state(udid, wait_until_state):
     238        # FIXME: Implement support for a timed wait.
     239        while (Simulator.device_state(udid) != wait_until_state):
     240            time.sleep(0.5)
     241
     242    @staticmethod
     243    def device_state(udid):
     244        device_plist = os.path.join(Simulator.device_directory(udid), 'device.plist')
     245        if not os.path.isfile(device_plist):
     246            return Simulator.DeviceState.DOES_NOT_EXIST
     247        return plistlib.readPlist(device_plist)['state']
     248
     249    @staticmethod
     250    def device_directory(udid):
     251        return os.path.realpath(os.path.expanduser(os.path.join('~/Library/Developer/CoreSimulator/Devices', udid)))
    230252
    231253    def refresh(self):
    … …  
    306328            device = Device(name=device_match.group('name').rstrip(),
    307329                            udid=device_match.group('udid'),
    308                             state=device_match.group('state'),
    309330                            available=device_match.group('availability') is None,
    310331                            runtime=current_runtime)
Note: See TracChangeset for help on using the changeset viewer.