Changeset 209136 in webkit


Ignore:
Timestamp:
Nov 30, 2016 10:30:47 AM (7 years ago)
Author:
Jonathan Bedard
Message:

Make it possible to use an existing simulator instance for one-off testing
https://bugs.webkit.org/show_bug.cgi?id=164568
<rdar://problem/29189133>

Reviewed by Daniel Bates.

With this patch, if a simulator is currently running on the machine and
'--dedicated-simulators' is not passed into the application, only one simulator
instance will be used, and this instance will be the existing instance.
If no simulator is running or '--dedicated-simulators' is passed to the script,
previous behavior will be used.

  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:

(parse_args):

  • Scripts/webkitpy/port/ios.py:

(IOSSimulatorPort.init): Logic for enabling usage of currently running simulator.
(IOSSimulatorPort._create_simulators): Only create simulators when needed, don't reset already running simulators.
(IOSSimulatorPort.setup_test_run): Don't open already running simulators.
(IOSSimulatorPort._quit_ios_simulator): Only quit simulators if we manage them.
(IOSSimulatorPort.clean_up_test_run): Only clean up simulators if we manage them.
(IOSSimulatorPort._using_dedicated_simulators): True if simulators need to be managed, false if using an existing instance.
(IOSSimulatorPort.device_id_for_worker_number): Access currently running simulator if not managing devices.

  • Scripts/webkitpy/xcode/simulator.py:

(Simulator.current_device): Get currently running device.

Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r209090 r209136  
     12016-11-30  Jonathan Bedard  <jbedard@apple.com>
     2
     3        Make it possible to use an existing simulator instance for one-off testing
     4        https://bugs.webkit.org/show_bug.cgi?id=164568
     5        <rdar://problem/29189133>
     6
     7        Reviewed by Daniel Bates.
     8
     9        With this patch, if a simulator is currently running on the machine and
     10        '--dedicated-simulators' is not passed into the application, only one simulator
     11        instance will be used, and this instance will be the existing instance.
     12        If no simulator is running or '--dedicated-simulators' is passed to the script,
     13        previous behavior will be used.
     14
     15        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     16        (parse_args):
     17        * Scripts/webkitpy/port/ios.py:
     18        (IOSSimulatorPort.__init__): Logic for enabling usage of currently running simulator.
     19        (IOSSimulatorPort._create_simulators): Only create simulators when needed, don't reset already running simulators.
     20        (IOSSimulatorPort.setup_test_run): Don't open already running simulators.
     21        (IOSSimulatorPort._quit_ios_simulator): Only quit simulators if we manage them.
     22        (IOSSimulatorPort.clean_up_test_run): Only clean up simulators if we manage them.
     23        (IOSSimulatorPort._using_dedicated_simulators): True if simulators need to be managed, false if using an existing instance.
     24        (IOSSimulatorPort.device_id_for_worker_number): Access currently running simulator if not managing devices.
     25        * Scripts/webkitpy/xcode/simulator.py:
     26        (Simulator.current_device): Get currently running device.
     27
    1282016-11-29  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    229
  • trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r205351 r209136  
    297297        optparse.make_option('--runtime', help='iOS Simulator runtime identifier (default: latest runtime)'),
    298298        optparse.make_option('--device-type', help='iOS Simulator device type identifier (default: i386 -> iPhone 5, x86_64 -> iPhone 5s)'),
     299        optparse.make_option('--dedicated-simulators', action="store_true", default=False,
     300            help="If set, dedicated iOS simulators will always be created.  If not set, the script will attempt to use any currently running simulator."),
    299301    ]))
    300302
  • trunk/Tools/Scripts/webkitpy/port/ios.py

    r208430 r209136  
    104104        _log.debug('IOSSimulatorPort _device_class is %s', self._device_class)
    105105
     106        self._current_device = Simulator().current_device()
     107        if not self._current_device:
     108            self.set_option('dedicated_simulators', True)
     109        if not self.get_option('dedicated_simulators'):
     110            if self.get_option('child_processes') > 1:
     111                _log.warn('Cannot have more than one child process when using a running simulator.  Setting child_processes to 1.')
     112            self.set_option('child_processes', 1)
     113
    106114    def driver_name(self):
    107115        if self.get_option('driver_name'):
     
    277285                _log.warn("This is very likely to fail.")
    278286
    279         self._createSimulatorApps()
    280 
    281         for i in xrange(self.child_processes()):
    282             self._create_device(i)
    283 
    284         for i in xrange(self.child_processes()):
    285             device_udid = self._testing_device(i).udid
    286             Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
    287             Simulator.reset_device(device_udid)
     287        if self._using_dedicated_simulators():
     288            self._createSimulatorApps()
     289
     290            for i in xrange(self.child_processes()):
     291                self._create_device(i)
     292
     293            for i in xrange(self.child_processes()):
     294                device_udid = self._testing_device(i).udid
     295                Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
     296                Simulator.reset_device(device_udid)
     297        else:
     298            assert(self._current_device)
     299            if self._current_device.name != self.simulator_device_type().name:
     300                _log.warn("Expected simulator of type '" + self.simulator_device_type().name + "' but found simulator of type '" + self._current_device.name + "'")
     301                _log.warn('The next block of tests may fail due to device mis-match')
    288302
    289303    def setup_test_run(self, device_class=None):
     
    296310
    297311        self._create_simulators()
     312
     313        if not self._using_dedicated_simulators():
     314            return
    298315
    299316        for i in xrange(self.child_processes()):
     
    314331
    315332    def _quit_ios_simulator(self):
     333        if not self._using_dedicated_simulators():
     334            return
    316335        _log.debug("_quit_ios_simulator killing all Simulator processes")
    317336        # FIXME: We should kill only the Simulators we started.
     
    329348                _log.warning('Unable to remove ' + fifo)
    330349                pass
     350
     351        if not self._using_dedicated_simulators():
     352            return
    331353
    332354        for i in xrange(self.child_processes()):
     
    380402    SUBPROCESS_CRASH_REGEX = re.compile('#CRASHED - (?P<subprocess_name>\S+) \(pid (?P<subprocess_pid>\d+)\)')
    381403
     404    def _using_dedicated_simulators(self):
     405        return self.get_option('dedicated_simulators')
     406
    382407    def _create_device(self, number):
    383408        return Simulator.create_device(number, self.simulator_device_type(), self.simulator_runtime)
     
    393418        if self._printing_cmd_line:
    394419            return '<dummy id>'
    395         return self._testing_device(number).udid
     420        if self._using_dedicated_simulators():
     421            return self._testing_device(number).udid
     422        return self._current_device.udid
    396423
    397424    def get_simulator_path(self, suffix=""):
  • trunk/Tools/Scripts/webkitpy/xcode/simulator.py

    r204680 r209136  
    530530        return None
    531531
     532    def current_device(self):
     533        # FIXME: Find the simulator device that was booted by Simulator.app. For now, pick some booted simulator device, which
     534        # may have been booted using the simctl command line tool.
     535        for device in self.devices:
     536            if device.state == Simulator.DeviceState.BOOTED:
     537                return device
     538        return None
     539
    532540    # FIXME: We should find an existing device with respect to its name, device type and runtime.
    533541    def device(self, name=None, runtime=None, should_ignore_unavailable_devices=False):
Note: See TracChangeset for help on using the changeset viewer.