<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[204680] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/204680">204680</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-08-20 10:29:05 -0700 (Sat, 20 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/204477">r204477</a>): Running LayoutTests on ios-simulator became ~15 minutes slower
https://bugs.webkit.org/show_bug.cgi?id=160985
Re-land <a href="http://trac.webkit.org/projects/webkit/changeset/204672">r204672</a>, but don't check the result of 'xcrun simctl shutdown', because
device shutdown seems to happen as result of killing Simulator.apps, and we're racing
with that.
* Scripts/webkitpy/layout_tests/views/printing.py:
(Printer.print_config):
* Scripts/webkitpy/port/base.py:
(Port.driver_cmd_line_for_logging):
(Port.driver_cmd_line): Deleted.
* Scripts/webkitpy/port/driver.py:
(IOSSimulatorDriver.cmd_line):
* Scripts/webkitpy/port/ios.py:
(IOSSimulatorPort.__init__):
(IOSSimulatorPort.driver_cmd_line_for_logging):
(IOSSimulatorPort._create_simulators):
(IOSSimulatorPort.setup_test_run):
(IOSSimulatorPort._quit_ios_simulator):
(IOSSimulatorPort.clean_up_test_run):
(IOSSimulatorPort._create_device):
(IOSSimulatorPort):
(IOSSimulatorPort._remove_device):
(IOSSimulatorPort._testing_device):
(IOSSimulatorPort.device_id_for_worker_number):
(IOSSimulatorPort._set_device_class): Deleted.
(IOSSimulatorPort.testing_device): Deleted.
* Scripts/webkitpy/port/port_testcase.py:
(PortTestCase.test_driver_cmd_line):
* Scripts/webkitpy/xcode/simulator.py:
(Device.shutdown):
(Device):
(Device.delete):
(Device.reset):
(Simulator):
(Simulator.create_device):
(Simulator.remove_device):
(Simulator.device_number):
(Simulator.device_state_description):
(Simulator.wait_until_device_is_in_state):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testsviewsprintingpy">trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportbasepy">trunk/Tools/Scripts/webkitpy/port/base.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportdriverpy">trunk/Tools/Scripts/webkitpy/port/driver.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportiospy">trunk/Tools/Scripts/webkitpy/port/ios.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportport_testcasepy">trunk/Tools/Scripts/webkitpy/port/port_testcase.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyxcodesimulatorpy">trunk/Tools/Scripts/webkitpy/xcode/simulator.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/ChangeLog        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2016-08-20 Simon Fraser <simon.fraser@apple.com>
+
+ REGRESSION (r204477): Running LayoutTests on ios-simulator became ~15 minutes slower
+ https://bugs.webkit.org/show_bug.cgi?id=160985
+
+ Re-land r204672, but don't check the result of 'xcrun simctl shutdown', because
+ device shutdown seems to happen as result of killing Simulator.apps, and we're racing
+ with that.
+
+ * Scripts/webkitpy/layout_tests/views/printing.py:
+ (Printer.print_config):
+ * Scripts/webkitpy/port/base.py:
+ (Port.driver_cmd_line_for_logging):
+ (Port.driver_cmd_line): Deleted.
+ * Scripts/webkitpy/port/driver.py:
+ (IOSSimulatorDriver.cmd_line):
+ * Scripts/webkitpy/port/ios.py:
+ (IOSSimulatorPort.__init__):
+ (IOSSimulatorPort.driver_cmd_line_for_logging):
+ (IOSSimulatorPort._create_simulators):
+ (IOSSimulatorPort.setup_test_run):
+ (IOSSimulatorPort._quit_ios_simulator):
+ (IOSSimulatorPort.clean_up_test_run):
+ (IOSSimulatorPort._create_device):
+ (IOSSimulatorPort):
+ (IOSSimulatorPort._remove_device):
+ (IOSSimulatorPort._testing_device):
+ (IOSSimulatorPort.device_id_for_worker_number):
+ (IOSSimulatorPort._set_device_class): Deleted.
+ (IOSSimulatorPort.testing_device): Deleted.
+ * Scripts/webkitpy/port/port_testcase.py:
+ (PortTestCase.test_driver_cmd_line):
+ * Scripts/webkitpy/xcode/simulator.py:
+ (Device.shutdown):
+ (Device):
+ (Device.delete):
+ (Device.reset):
+ (Simulator):
+ (Simulator.create_device):
+ (Simulator.remove_device):
+ (Simulator.device_number):
+ (Simulator.device_state_description):
+ (Simulator.wait_until_device_is_in_state):
+
</ins><span class="cx"> 2016-08-19 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r204659.
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testsviewsprintingpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/views/printing.py        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx"> self._print_default("Regular timeout: %s, slow test timeout: %s" %
</span><span class="cx"> (self._options.time_out_ms, self._options.slow_time_out_ms))
</span><span class="cx">
</span><del>- self._print_default('Command line: ' + ' '.join(self._port.driver_cmd_line()))
</del><ins>+ self._print_default('Command line: ' + ' '.join(self._port.driver_cmd_line_for_logging()))
</ins><span class="cx"> self._print_default('')
</span><span class="cx">
</span><span class="cx"> def print_found(self, num_all_test_files, num_to_run, repeat_each, iterations):
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportbasepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/base.py (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/base.py        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/Scripts/webkitpy/port/base.py        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -658,7 +658,7 @@
</span><span class="cx"> return test_name + '/'
</span><span class="cx"> return test_name
</span><span class="cx">
</span><del>- def driver_cmd_line(self):
</del><ins>+ def driver_cmd_line_for_logging(self):
</ins><span class="cx"> """Prints the DRT command line that will be used."""
</span><span class="cx"> driver = self.create_driver(0)
</span><span class="cx"> return driver.cmd_line(self.get_option('pixel_tests'), [])
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportdriverpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/driver.py        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -600,7 +600,7 @@
</span><span class="cx"> product_dir = self._port._build_path()
</span><span class="cx"> relay_args = [
</span><span class="cx"> '-developerDir', self._port.developer_dir,
</span><del>- '-udid', self._port.testing_device(self._worker_number).udid,
</del><ins>+ '-udid', self._port.device_id_for_worker_number(self._worker_number),
</ins><span class="cx"> '-productDir', product_dir,
</span><span class="cx"> '-app', dump_tool,
</span><span class="cx"> ]
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportiospy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/ios.py        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> super(IOSSimulatorPort, self).__init__(host, port_name, **kwargs)
</span><span class="cx">
</span><span class="cx"> optional_device_class = self.get_option('device_class')
</span><ins>+ self._printing_cmd_line = False
</ins><span class="cx"> self._device_class = optional_device_class if optional_device_class else self.DEFAULT_DEVICE_CLASS
</span><span class="cx"> _log.debug('IOSSimulatorPort _device_class is %s', self._device_class)
</span><span class="cx">
</span><span class="lines">@@ -108,6 +109,13 @@
</span><span class="cx"> return 'WebKitTestRunnerApp.app'
</span><span class="cx"> return 'DumpRenderTree.app'
</span><span class="cx">
</span><ins>+ def driver_cmd_line_for_logging(self):
+ # Avoid spinning up devices just for logging the commandline.
+ self._printing_cmd_line = True
+ result = super(IOSSimulatorPort, self).driver_cmd_line_for_logging()
+ self._printing_cmd_line = False
+ return result
+
</ins><span class="cx"> @property
</span><span class="cx"> @memoized
</span><span class="cx"> def simulator_runtime(self):
</span><span class="lines">@@ -224,7 +232,6 @@
</span><span class="cx"> return list(reversed([self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in self.baseline_search_path()]))
</span><span class="cx">
</span><span class="cx"> def _set_device_class(self, device_class):
</span><del>- # Ideally we'd ensure that no simulators are running when this is called.
</del><span class="cx"> self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
</span><span class="cx">
</span><span class="cx"> def _create_simulators(self):
</span><span class="lines">@@ -236,9 +243,13 @@
</span><span class="cx"> self._createSimulatorApps()
</span><span class="cx">
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><del>- Simulator.wait_until_device_is_in_state(self.testing_device(i).udid, Simulator.DeviceState.SHUTDOWN)
- Simulator.reset_device(self.testing_device(i).udid)
</del><ins>+ self._create_device(i)
</ins><span class="cx">
</span><ins>+ for i in xrange(self.child_processes()):
+ device_udid = self._testing_device(i).udid
+ Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
+ Simulator.reset_device(device_udid)
+
</ins><span class="cx"> def setup_test_run(self, device_class=None):
</span><span class="cx"> mac_os_version = self.host.platform.os_version
</span><span class="cx">
</span><span class="lines">@@ -250,7 +261,7 @@
</span><span class="cx"> self._create_simulators()
</span><span class="cx">
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><del>- device_udid = self.testing_device(i).udid
</del><ins>+ device_udid = self._testing_device(i).udid
</ins><span class="cx"> _log.debug('testing device %s has udid %s', i, device_udid)
</span><span class="cx">
</span><span class="cx"> # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator
</span><span class="lines">@@ -263,10 +274,10 @@
</span><span class="cx">
</span><span class="cx"> _log.info('Waiting for all iOS Simulators to finish booting.')
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><del>- Simulator.wait_until_device_is_booted(self.testing_device(i).udid)
</del><ins>+ Simulator.wait_until_device_is_booted(self._testing_device(i).udid)
</ins><span class="cx">
</span><span class="cx"> def _quit_ios_simulator(self):
</span><del>- _log.debug("_quit_ios_simulator")
</del><ins>+ _log.debug("_quit_ios_simulator killing all Simulator processes")
</ins><span class="cx"> # FIXME: We should kill only the Simulators we started.
</span><span class="cx"> subprocess.call(["killall", "-9", "-m", "Simulator"])
</span><span class="cx">
</span><span class="lines">@@ -284,7 +295,9 @@
</span><span class="cx">
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><span class="cx"> simulator_path = self.get_simulator_path(i)
</span><del>- device_udid = self.testing_device(i).udid
</del><ins>+ device_udid = self._testing_device(i).udid
+ self._remove_device(i)
+
</ins><span class="cx"> if not os.path.exists(simulator_path):
</span><span class="cx"> continue
</span><span class="cx"> try:
</span><span class="lines">@@ -301,7 +314,6 @@
</span><span class="cx"> _log.debug('rmtree %s', saved_state_path)
</span><span class="cx"> self._filesystem.rmtree(saved_state_path)
</span><span class="cx">
</span><del>- Simulator().delete_device(device_udid)
</del><span class="cx"> except:
</span><span class="cx"> _log.warning('Unable to remove Simulator' + str(i))
</span><span class="cx">
</span><span class="lines">@@ -369,13 +381,21 @@
</span><span class="cx"> return stderr, None
</span><span class="cx"> return stderr, crash_log
</span><span class="cx">
</span><del>- def testing_device(self, number):
- # FIXME: rather than calling lookup_or_create_device every time, we should just store a mapping of
- # number to device_udid.
- device_type = self.simulator_device_type()
- _log.debug(' testing_device %s using device_type %s', number, device_type)
- return Simulator().lookup_or_create_device(device_type.name + ' WebKit Tester' + str(number), device_type, self.simulator_runtime)
</del><ins>+ def _create_device(self, number):
+ return Simulator.create_device(number, self.simulator_device_type(), self.simulator_runtime)
</ins><span class="cx">
</span><ins>+ def _remove_device(self, number):
+ Simulator.remove_device(number)
+
+ def _testing_device(self, number):
+ return Simulator.device_number(number)
+
+ # This is only exposed so that IOSSimulatorDriver can use it.
+ def device_id_for_worker_number(self, number):
+ if self._printing_cmd_line:
+ return '<dummy id>'
+ return self._testing_device(number).udid
+
</ins><span class="cx"> def get_simulator_path(self, suffix=""):
</span><span class="cx"> return os.path.join(self.SIMULATOR_DIRECTORY, "Simulator" + str(suffix) + ".app")
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportport_testcasepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/port_testcase.py (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/port_testcase.py        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/Scripts/webkitpy/port/port_testcase.py        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -100,11 +100,11 @@
</span><span class="cx">
</span><span class="cx"> def test_driver_cmd_line(self):
</span><span class="cx"> port = self.make_port()
</span><del>- self.assertTrue(len(port.driver_cmd_line()))
</del><ins>+ self.assertTrue(len(port.driver_cmd_line_for_logging()))
</ins><span class="cx">
</span><span class="cx"> options = MockOptions(additional_drt_flag=['--foo=bar', '--foo=baz'])
</span><span class="cx"> port = self.make_port(options=options)
</span><del>- cmd_line = port.driver_cmd_line()
</del><ins>+ cmd_line = port.driver_cmd_line_for_logging()
</ins><span class="cx"> self.assertTrue('--foo=bar' in cmd_line)
</span><span class="cx"> self.assertTrue('--foo=baz' in cmd_line)
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyxcodesimulatorpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/xcode/simulator.py (204679 => 204680)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/xcode/simulator.py        2016-08-20 14:44:52 UTC (rev 204679)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulator.py        2016-08-20 17:29:05 UTC (rev 204680)
</span><span class="lines">@@ -218,6 +218,21 @@
</span><span class="cx"> return Simulator().find_device_by_udid(device_udid)
</span><span class="cx">
</span><span class="cx"> @classmethod
</span><ins>+ def shutdown(cls, udid):
+ """
+ Shut down the given CoreSimulator device.
+ :param udid: The udid of the device.
+ :type udid: str
+ """
+ device_state = Simulator.device_state(udid)
+ if device_state == Simulator.DeviceState.BOOTING or device_state == Simulator.DeviceState.BOOTED:
+ _log.debug('xcrun simctl shutdown %s', udid)
+ # Don't throw on error. Device shutdown seems to be racy with Simulator app killing.
+ subprocess.call(['xcrun', 'simctl', 'shutdown', udid])
+
+ Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
+
+ @classmethod
</ins><span class="cx"> def delete(cls, udid):
</span><span class="cx"> """
</span><span class="cx"> Delete the given CoreSimulator device.
</span><span class="lines">@@ -224,8 +239,7 @@
</span><span class="cx"> :param udid: The udid of the device.
</span><span class="cx"> :type udid: str
</span><span class="cx"> """
</span><del>- _log.debug('deleting device %s', udid)
- Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
</del><ins>+ Device.shutdown(udid)
</ins><span class="cx"> try:
</span><span class="cx"> _log.debug('xcrun simctl delete %s', udid)
</span><span class="cx"> subprocess.check_call(['xcrun', 'simctl', 'delete', udid])
</span><span class="lines">@@ -239,8 +253,7 @@
</span><span class="cx"> :param udid: The udid of the device.
</span><span class="cx"> :type udid: str
</span><span class="cx"> """
</span><del>- _log.debug('resetting device %s', udid)
- Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
</del><ins>+ Device.shutdown(udid)
</ins><span class="cx"> try:
</span><span class="cx"> _log.debug('xcrun simctl erase %s', udid)
</span><span class="cx"> subprocess.check_call(['xcrun', 'simctl', 'erase', udid])
</span><span class="lines">@@ -281,6 +294,8 @@
</span><span class="cx"> devices_re = re.compile(
</span><span class="cx"> '\s*(?P<name>[^(]+ )\((?P<udid>[^)]+)\) \((?P<state>[^)]+)\)( \((?P<availability>[^)]+)\))?')
</span><span class="cx">
</span><ins>+ _managed_devices = {}
+
</ins><span class="cx"> def __init__(self, host=None):
</span><span class="cx"> self._host = host or Host()
</span><span class="cx"> self.runtimes = []
</span><span class="lines">@@ -296,7 +311,41 @@
</span><span class="cx"> BOOTED = 3
</span><span class="cx"> SHUTTING_DOWN = 4
</span><span class="cx">
</span><ins>+ NAME_FOR_STATE = [
+ 'CREATING',
+ 'SHUTDOWN',
+ 'BOOTING',
+ 'BOOTED',
+ 'SHUTTING_DOWN'
+ ]
+
</ins><span class="cx"> @staticmethod
</span><ins>+ def create_device(number, device_type, runtime):
+ device = Simulator().lookup_or_create_device(device_type.name + ' WebKit Tester' + str(number), device_type, runtime)
+ _log.debug('created device {} {}'.format(number, device))
+ assert(len(Simulator._managed_devices) == number)
+ Simulator._managed_devices[number] = device
+
+ @staticmethod
+ def remove_device(number):
+ if not Simulator._managed_devices[number]:
+ return
+ device_udid = Simulator._managed_devices[number].udid
+ _log.debug('removing device {} {}'.format(number, device_udid))
+ del Simulator._managed_devices[number]
+ Simulator.delete_device(device_udid)
+
+ @staticmethod
+ def device_number(number):
+ return Simulator._managed_devices[number]
+
+ @staticmethod
+ def device_state_description(state):
+ if (state == Simulator.DeviceState.DOES_NOT_EXIST):
+ return 'DOES_NOT_EXIST'
+ return Simulator.NAME_FOR_STATE[state]
+
+ @staticmethod
</ins><span class="cx"> def wait_until_device_is_booted(udid, timeout_seconds=60 * 5):
</span><span class="cx"> Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.BOOTED, timeout_seconds)
</span><span class="cx"> with timeout(seconds=timeout_seconds):
</span><span class="lines">@@ -315,17 +364,17 @@
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def wait_until_device_is_in_state(udid, wait_until_state, timeout_seconds=60 * 5):
</span><del>- _log.debug('waiting for device %s to enter state %s with timeout %s', udid, wait_until_state, timeout_seconds)
</del><ins>+ _log.debug('waiting for device %s to enter state %s with timeout %s', udid, Simulator.device_state_description(wait_until_state), timeout_seconds)
</ins><span class="cx"> with timeout(seconds=timeout_seconds):
</span><span class="cx"> device_state = Simulator.device_state(udid)
</span><span class="cx"> while (device_state != wait_until_state):
</span><span class="cx"> device_state = Simulator.device_state(udid)
</span><del>- _log.debug(' device state %s', device_state)
</del><ins>+ _log.debug(' device state %s', Simulator.device_state_description(device_state))
</ins><span class="cx"> time.sleep(0.5)
</span><span class="cx">
</span><span class="cx"> end_state = Simulator.device_state(udid)
</span><span class="cx"> if (end_state != wait_until_state):
</span><del>- raise RuntimeError('Timed out waiting for simulator device to enter state {0}; current state is {1}'.format(wait_until_state, end_state))
</del><ins>+ raise RuntimeError('Timed out waiting for simulator device to enter state {0}; current state is {1}'.format(Simulator.device_state_description(wait_until_state), Simulator.device_state_description(end_state)))
</ins><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def device_state(udid):
</span></span></pre>
</div>
</div>
</body>
</html>