<!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>[204341] 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/204341">204341</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-08-10 12:59:08 -0700 (Wed, 10 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>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):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpyportiospy">trunk/Tools/Scripts/webkitpy/port/ios.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 (204340 => 204341)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-08-10 19:37:38 UTC (rev 204340)
+++ trunk/Tools/ChangeLog        2016-08-10 19:59:08 UTC (rev 204341)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-08-09 Simon Fraser <simon.fraser@apple.com>
+
+ 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):
+
</ins><span class="cx"> 2016-08-10 Carlos Alberto Lopez Perez <clopez@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK][EFL] ALSA_CARD environment variable is not passed for layout tests.
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportiospy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (204340 => 204341)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/ios.py        2016-08-10 19:37:38 UTC (rev 204340)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py        2016-08-10 19:59:08 UTC (rev 204341)
</span><span class="lines">@@ -210,8 +210,9 @@
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><span class="cx"> device_udid = self.testing_device(i).udid
</span><span class="cx"> # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator
</span><ins>+
</ins><span class="cx"> self._executive.run_command([
</span><del>- 'open', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
</del><ins>+ 'open', '-g', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
</ins><span class="cx"> '--args', '-CurrentDeviceUDID', device_udid])
</span><span class="cx">
</span><span class="cx"> if mac_os_version in ['elcapitan', 'yosemite', 'mavericks']:
</span><span class="lines">@@ -222,11 +223,13 @@
</span><span class="cx"> Simulator.wait_until_device_is_booted(self.testing_device(i).udid)
</span><span class="cx">
</span><span class="cx"> def _quit_ios_simulator(self):
</span><ins>+ _log.debug("_quit_ios_simulator")
</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="cx"> def clean_up_test_run(self):
</span><span class="cx"> super(IOSSimulatorPort, self).clean_up_test_run()
</span><ins>+ _log.debug("clean_up_test_run")
</ins><span class="cx"> self._quit_ios_simulator()
</span><span class="cx"> fifos = [path for path in os.listdir('/tmp') if re.search('org.webkit.(DumpRenderTree|WebKitTestRunner).*_(IN|OUT|ERROR)', path)]
</span><span class="cx"> for fifo in fifos:
</span><span class="lines">@@ -237,20 +240,30 @@
</span><span class="cx"> pass
</span><span class="cx">
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><del>- if not os.path.exists(self.get_simulator_path(i)):
</del><ins>+ simulator_path = self.get_simulator_path(i)
+ device_udid = self.testing_device(i).udid
+ if not os.path.exists(simulator_path):
</ins><span class="cx"> continue
</span><span class="cx"> try:
</span><del>- subprocess.call([self.LSREGISTER_PATH, "-u", self.get_simulator_path(i)])
- shutil.rmtree(self.get_simulator_path(i), ignore_errors=True)
- shutil.rmtree(os.path.join(os.path.expanduser("~"), "Library/Logs/CoreSimulator/",
- self.testing_device(i).udid), ignore_errors=True)
- shutil.rmtree(os.path.join(os.path.expanduser("~"), "Library/Saved Application State/",
- self.SIMULATOR_BUNDLE_ID + str(i) + ".savedState"), ignore_errors=True)
- Simulator().delete_device(self.testing_device(i).udid)
</del><ins>+ self._executive.run_command([self.LSREGISTER_PATH, "-u", simulator_path])
+
+ _log.debug('rmtree %s', simulator_path)
+ self._filesystem.rmtree(simulator_path)
+
+ logs_path = self._filesystem.join(self._filesystem.expanduser("~"), "Library/Logs/CoreSimulator/", device_udid)
+ _log.debug('rmtree %s', logs_path)
+ self._filesystem.rmtree(logs_path)
+
+ saved_state_path = self._filesystem.join(self._filesystem.expanduser("~"), "Library/Saved Application State/", self.SIMULATOR_BUNDLE_ID + str(i) + ".savedState")
+ _log.debug('rmtree %s', saved_state_path)
+ self._filesystem.rmtree(saved_state_path)
+
+ Simulator().delete_device(device_udid)
</ins><span class="cx"> except:
</span><span class="cx"> _log.warning('Unable to remove Simulator' + str(i))
</span><span class="cx">
</span><span class="cx"> def setup_environ_for_server(self, server_name=None):
</span><ins>+ _log.debug("setup_environ_for_server")
</ins><span class="cx"> env = super(IOSSimulatorPort, self).setup_environ_for_server(server_name)
</span><span class="cx"> if server_name == self.driver_name():
</span><span class="cx"> if self.get_option('leaks'):
</span><span class="lines">@@ -336,6 +349,7 @@
</span><span class="cx"> return self._image_differ.diff_image(expected_contents, actual_contents, tolerance)
</span><span class="cx">
</span><span class="cx"> def reset_preferences(self):
</span><ins>+ _log.debug("reset_preferences")
</ins><span class="cx"> if (self.default_child_processes() < self.child_processes()):
</span><span class="cx"> _log.warn("You have specified very high value({0}) for --child-processes".format(self.child_processes()))
</span><span class="cx"> _log.warn("maximum child-processes which can be supported on this system are: {0}".format(self.default_child_processes()))
</span><span class="lines">@@ -346,11 +360,8 @@
</span><span class="cx">
</span><span class="cx"> for i in xrange(self.child_processes()):
</span><span class="cx"> Simulator.wait_until_device_is_in_state(self.testing_device(i).udid, Simulator.DeviceState.SHUTDOWN)
</span><ins>+ Simulator.reset_device(self.testing_device(i).udid)
</ins><span class="cx">
</span><del>- data_path = os.path.join(self.testing_device(i).path, 'data')
- if os.path.isdir(data_path):
- shutil.rmtree(data_path)
-
</del><span class="cx"> def nm_command(self):
</span><span class="cx"> return self.xcrun_find('nm')
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyxcodesimulatorpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/xcode/simulator.py (204340 => 204341)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/xcode/simulator.py        2016-08-10 19:37:38 UTC (rev 204340)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulator.py        2016-08-10 19:59:08 UTC (rev 204341)
</span><span class="lines">@@ -213,6 +213,7 @@
</span><span class="cx"> :rtype: Device
</span><span class="cx"> """
</span><span class="cx"> device_udid = subprocess.check_output(['xcrun', 'simctl', 'create', name, device_type.identifier, runtime.identifier]).rstrip()
</span><ins>+ _log.debug('"xcrun simctl create %s %s %s" returned %s', name, device_type.identifier, runtime.identifier, device_udid)
</ins><span class="cx"> Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN)
</span><span class="cx"> return Simulator().find_device_by_udid(device_udid)
</span><span class="cx">
</span><span class="lines">@@ -223,8 +224,29 @@
</span><span class="cx"> :param udid: The udid of the device.
</span><span class="cx"> :type udid: str
</span><span class="cx"> """
</span><del>- subprocess.call(['xcrun', 'simctl', 'delete', udid])
</del><ins>+ _log.debug('deleting device %s', udid)
+ Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
+ try:
+ _log.debug('xcrun simctl delete %s', udid)
+ subprocess.check_call(['xcrun', 'simctl', 'delete', udid])
+ except subprocess.CalledProcessError:
+ raise RuntimeError('"xcrun simctl delete" failed: device state is {}'.format(Simulator.device_state(udid)))
</ins><span class="cx">
</span><ins>+ @classmethod
+ def reset(cls, udid):
+ """
+ Reset the given CoreSimulator device.
+ :param udid: The udid of the device.
+ :type udid: str
+ """
+ _log.debug('resetting device %s', udid)
+ Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
+ try:
+ _log.debug('xcrun simctl erase %s', udid)
+ subprocess.check_call(['xcrun', 'simctl', 'erase', udid])
+ except subprocess.CalledProcessError:
+ raise RuntimeError('"xcrun simctl erase" failed: device state is {}'.format(Simulator.device_state(udid)))
+
</ins><span class="cx"> def __eq__(self, other):
</span><span class="cx"> return self.udid == other.udid
</span><span class="cx">
</span><span class="lines">@@ -281,6 +303,8 @@
</span><span class="cx"> while True:
</span><span class="cx"> try:
</span><span class="cx"> state = subprocess.check_output(['xcrun', 'simctl', 'spawn', udid, 'launchctl', 'print', 'system']).strip()
</span><ins>+ _log.debug('xcrun simctl spawn %s', udid)
+
</ins><span class="cx"> if re.search("A[\s]+com.apple.springboard.services", state):
</span><span class="cx"> return
</span><span class="cx"> except subprocess.CalledProcessError:
</span><span class="lines">@@ -291,10 +315,18 @@
</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><ins>+ _log.debug('waiting for device %s to enter state %s with timeout %s', udid, wait_until_state, timeout_seconds)
</ins><span class="cx"> with timeout(seconds=timeout_seconds):
</span><del>- while (Simulator.device_state(udid) != wait_until_state):
</del><ins>+ device_state = Simulator.device_state(udid)
+ while (device_state != wait_until_state):
+ device_state = Simulator.device_state(udid)
+ _log.debug(' device state %s', device_state)
</ins><span class="cx"> time.sleep(0.5)
</span><span class="cx">
</span><ins>+ end_state = Simulator.device_state(udid)
+ if (end_state != wait_until_state):
+ raise RuntimeError('Timed out waiting for simulator device to enter state {0}; current state is {1}'.format(wait_until_state, end_state))
+
</ins><span class="cx"> @staticmethod
</span><span class="cx"> def device_state(udid):
</span><span class="cx"> device_plist = os.path.join(Simulator.device_directory(udid), 'device.plist')
</span><span class="lines">@@ -306,10 +338,14 @@
</span><span class="cx"> def device_directory(udid):
</span><span class="cx"> return os.path.realpath(os.path.expanduser(os.path.join('~/Library/Developer/CoreSimulator/Devices', udid)))
</span><span class="cx">
</span><del>- def delete_device(self, udid):
- Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
</del><ins>+ @staticmethod
+ def delete_device(udid):
</ins><span class="cx"> Device.delete(udid)
</span><span class="cx">
</span><ins>+ @staticmethod
+ def reset_device(udid):
+ Device.reset(udid)
+
</ins><span class="cx"> def refresh(self):
</span><span class="cx"> """
</span><span class="cx"> Refresh runtime and device type information from ``simctl list``.
</span><span class="lines">@@ -512,8 +548,10 @@
</span><span class="cx"> assert(runtime.available)
</span><span class="cx"> testing_device = self.device(name=name, runtime=runtime, should_ignore_unavailable_devices=True)
</span><span class="cx"> if testing_device:
</span><ins>+ _log.debug('lookup_or_create_device %s %s %s found %s', name, device_type, runtime, testing_device.name)
</ins><span class="cx"> return testing_device
</span><span class="cx"> testing_device = Device.create(name, device_type, runtime)
</span><ins>+ _log.debug('lookup_or_create_device %s %s %s created %s', name, device_type, runtime, testing_device.name)
</ins><span class="cx"> assert(testing_device.available)
</span><span class="cx"> return testing_device
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>