Changeset 204341 in webkit


Ignore:
Timestamp:
Aug 10, 2016 12:59:08 PM (8 years ago)
Author:
Simon Fraser
Message:

Logging and other minor improvements to iOS webkitpy
https://bugs.webkit.org/show_bug.cgi?id=160722

Reviewed by Dan Bates.

Fix --debug-rwt-logging to log all the calls to simctl as well as device state information,
to make it easier to debug launching issues.

Have reset_preferences() reset the device, rather than just nuking the data
directory (which broke some versions of the simulator).

Make the Simulator.app launch in the background with open -g.

Wait for the simulator device to be in a known state in some more places.

  • Scripts/webkitpy/port/ios.py:

(IOSSimulatorPort.setup_test_run):
(IOSSimulatorPort._quit_ios_simulator):
(IOSSimulatorPort.clean_up_test_run):
(IOSSimulatorPort.setup_environ_for_server):
(IOSSimulatorPort.reset_preferences):

  • Scripts/webkitpy/xcode/simulator.py:

(Device.create):
(Device.delete):
(Device):
(Device.reset):
(Simulator.wait_until_device_is_booted):
(Simulator.wait_until_device_is_in_state):
(Simulator):
(Simulator.delete_device):
(Simulator.reset_device):
(Simulator.lookup_or_create_device):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r204332 r204341  
     12016-08-09  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Logging and other minor improvements to iOS webkitpy
     4        https://bugs.webkit.org/show_bug.cgi?id=160722
     5
     6        Reviewed by Dan Bates.
     7
     8        Fix --debug-rwt-logging to log all the calls to simctl as well as device state information,
     9        to make it easier to debug launching issues.
     10
     11        Have reset_preferences() reset the device, rather than just nuking the data
     12        directory (which broke some versions of the simulator).
     13
     14        Make the Simulator.app launch in the background with open -g.
     15
     16        Wait for the simulator device to be in a known state in some more places.
     17
     18        * Scripts/webkitpy/port/ios.py:
     19        (IOSSimulatorPort.setup_test_run):
     20        (IOSSimulatorPort._quit_ios_simulator):
     21        (IOSSimulatorPort.clean_up_test_run):
     22        (IOSSimulatorPort.setup_environ_for_server):
     23        (IOSSimulatorPort.reset_preferences):
     24        * Scripts/webkitpy/xcode/simulator.py:
     25        (Device.create):
     26        (Device.delete):
     27        (Device):
     28        (Device.reset):
     29        (Simulator.wait_until_device_is_booted):
     30        (Simulator.wait_until_device_is_in_state):
     31        (Simulator):
     32        (Simulator.delete_device):
     33        (Simulator.reset_device):
     34        (Simulator.lookup_or_create_device):
     35
    1362016-08-10  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    237
  • trunk/Tools/Scripts/webkitpy/port/ios.py

    r204271 r204341  
    211211            device_udid = self.testing_device(i).udid
    212212            # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator
     213
    213214            self._executive.run_command([
    214                 'open', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
     215                'open', '-g', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
    215216                '--args', '-CurrentDeviceUDID', device_udid])
    216217
     
    223224
    224225    def _quit_ios_simulator(self):
     226        _log.debug("_quit_ios_simulator")
    225227        # FIXME: We should kill only the Simulators we started.
    226228        subprocess.call(["killall", "-9", "-m", "Simulator"])
     
    228230    def clean_up_test_run(self):
    229231        super(IOSSimulatorPort, self).clean_up_test_run()
     232        _log.debug("clean_up_test_run")
    230233        self._quit_ios_simulator()
    231234        fifos = [path for path in os.listdir('/tmp') if re.search('org.webkit.(DumpRenderTree|WebKitTestRunner).*_(IN|OUT|ERROR)', path)]
     
    238241
    239242        for i in xrange(self.child_processes()):
    240             if not os.path.exists(self.get_simulator_path(i)):
     243            simulator_path = self.get_simulator_path(i)
     244            device_udid = self.testing_device(i).udid
     245            if not os.path.exists(simulator_path):
    241246                continue
    242247            try:
    243                 subprocess.call([self.LSREGISTER_PATH, "-u", self.get_simulator_path(i)])
    244                 shutil.rmtree(self.get_simulator_path(i), ignore_errors=True)
    245                 shutil.rmtree(os.path.join(os.path.expanduser("~"), "Library/Logs/CoreSimulator/",
    246                     self.testing_device(i).udid), ignore_errors=True)
    247                 shutil.rmtree(os.path.join(os.path.expanduser("~"), "Library/Saved Application State/",
    248                     self.SIMULATOR_BUNDLE_ID + str(i) + ".savedState"), ignore_errors=True)
    249                 Simulator().delete_device(self.testing_device(i).udid)
     248                self._executive.run_command([self.LSREGISTER_PATH, "-u", simulator_path])
     249
     250                _log.debug('rmtree %s', simulator_path)
     251                self._filesystem.rmtree(simulator_path)
     252
     253                logs_path = self._filesystem.join(self._filesystem.expanduser("~"), "Library/Logs/CoreSimulator/", device_udid)
     254                _log.debug('rmtree %s', logs_path)
     255                self._filesystem.rmtree(logs_path)
     256
     257                saved_state_path = self._filesystem.join(self._filesystem.expanduser("~"), "Library/Saved Application State/", self.SIMULATOR_BUNDLE_ID + str(i) + ".savedState")
     258                _log.debug('rmtree %s', saved_state_path)
     259                self._filesystem.rmtree(saved_state_path)
     260
     261                Simulator().delete_device(device_udid)
    250262            except:
    251263                _log.warning('Unable to remove Simulator' + str(i))
    252264
    253265    def setup_environ_for_server(self, server_name=None):
     266        _log.debug("setup_environ_for_server")
    254267        env = super(IOSSimulatorPort, self).setup_environ_for_server(server_name)
    255268        if server_name == self.driver_name():
     
    337350
    338351    def reset_preferences(self):
     352        _log.debug("reset_preferences")
    339353        if (self.default_child_processes() < self.child_processes()):
    340354                _log.warn("You have specified very high value({0}) for --child-processes".format(self.child_processes()))
     
    347361        for i in xrange(self.child_processes()):
    348362            Simulator.wait_until_device_is_in_state(self.testing_device(i).udid, Simulator.DeviceState.SHUTDOWN)
    349 
    350             data_path = os.path.join(self.testing_device(i).path, 'data')
    351             if os.path.isdir(data_path):
    352                 shutil.rmtree(data_path)
     363            Simulator.reset_device(self.testing_device(i).udid)
    353364
    354365    def nm_command(self):
  • trunk/Tools/Scripts/webkitpy/xcode/simulator.py

    r202362 r204341  
    214214        """
    215215        device_udid = subprocess.check_output(['xcrun', 'simctl', 'create', name, device_type.identifier, runtime.identifier]).rstrip()
     216        _log.debug('"xcrun simctl create %s %s %s" returned %s', name, device_type.identifier, runtime.identifier, device_udid)
    216217        Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
    217218        return Simulator().find_device_by_udid(device_udid)
     
    224225        :type udid: str
    225226        """
    226         subprocess.call(['xcrun', 'simctl', 'delete', udid])
     227        _log.debug('deleting device %s', udid)
     228        Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
     229        try:
     230            _log.debug('xcrun simctl delete %s', udid)
     231            subprocess.check_call(['xcrun', 'simctl', 'delete', udid])
     232        except subprocess.CalledProcessError:
     233            raise RuntimeError('"xcrun simctl delete" failed: device state is {}'.format(Simulator.device_state(udid)))
     234
     235    @classmethod
     236    def reset(cls, udid):
     237        """
     238        Reset the given CoreSimulator device.
     239        :param udid: The udid of the device.
     240        :type udid: str
     241        """
     242        _log.debug('resetting device %s', udid)
     243        Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
     244        try:
     245            _log.debug('xcrun simctl erase %s', udid)
     246            subprocess.check_call(['xcrun', 'simctl', 'erase', udid])
     247        except subprocess.CalledProcessError:
     248            raise RuntimeError('"xcrun simctl erase" failed: device state is {}'.format(Simulator.device_state(udid)))
    227249
    228250    def __eq__(self, other):
     
    282304                try:
    283305                    state = subprocess.check_output(['xcrun', 'simctl', 'spawn', udid, 'launchctl', 'print', 'system']).strip()
     306                    _log.debug('xcrun simctl spawn %s', udid)
     307
    284308                    if re.search("A[\s]+com.apple.springboard.services", state):
    285309                        return
     
    292316    @staticmethod
    293317    def wait_until_device_is_in_state(udid, wait_until_state, timeout_seconds=60 * 5):
     318        _log.debug('waiting for device %s to enter state %s with timeout %s', udid, wait_until_state, timeout_seconds)
    294319        with timeout(seconds=timeout_seconds):
    295             while (Simulator.device_state(udid) != wait_until_state):
     320            device_state = Simulator.device_state(udid)
     321            while (device_state != wait_until_state):
     322                device_state = Simulator.device_state(udid)
     323                _log.debug(' device state %s', device_state)
    296324                time.sleep(0.5)
     325
     326        end_state = Simulator.device_state(udid)
     327        if (end_state != wait_until_state):
     328            raise RuntimeError('Timed out waiting for simulator device to enter state {0}; current state is {1}'.format(wait_until_state, end_state))
    297329
    298330    @staticmethod
     
    307339        return os.path.realpath(os.path.expanduser(os.path.join('~/Library/Developer/CoreSimulator/Devices', udid)))
    308340
    309     def delete_device(self, udid):
    310         Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
     341    @staticmethod
     342    def delete_device(udid):
    311343        Device.delete(udid)
     344
     345    @staticmethod
     346    def reset_device(udid):
     347        Device.reset(udid)
    312348
    313349    def refresh(self):
     
    513549        testing_device = self.device(name=name, runtime=runtime, should_ignore_unavailable_devices=True)
    514550        if testing_device:
     551            _log.debug('lookup_or_create_device %s %s %s found %s', name, device_type, runtime, testing_device.name)
    515552            return testing_device
    516553        testing_device = Device.create(name, device_type, runtime)
     554        _log.debug('lookup_or_create_device %s %s %s created %s', name, device_type, runtime, testing_device.name)
    517555        assert(testing_device.available)
    518556        return testing_device
Note: See TracChangeset for help on using the changeset viewer.