Title: [214473] trunk/Tools
- Revision
- 214473
- Author
- [email protected]
- Date
- 2017-03-28 07:06:49 -0700 (Tue, 28 Mar 2017)
Log Message
webkitpy: Use host pattern for devices
https://bugs.webkit.org/show_bug.cgi?id=170121
Reviewed by Daniel Bates.
Devices should be treated like hosts throughout webkitpy
so that more code can be re-used. Add the needed properties
and use executive over custom implemented polling/killing
functions.
* Scripts/webkitpy/port/device.py:
(Device):
(Device.executive): Add optional executive property.
(Device.filesystem): Add optional filesystem property.
(Device.user): Add optional user property.
(Device.platform): Add optional platform property.
(Device.workspace): Add optional workspace property.
(Device.poll): Deleted.
* Scripts/webkitpy/port/simulator_process.py:
(SimulatorProcess.Popen.poll): Use the devices executive.
(SimulatorProcess.stop): Ditto.
(SimulatorProcess._kill): Ditto.
* Scripts/webkitpy/xcode/simulated_device.py:
(SimulatedDevice.__init__): Add executive, filesystem, user, platform
and workspace to the platform device.
(SimulatedDevice.poll): Deleted.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (214472 => 214473)
--- trunk/Tools/ChangeLog 2017-03-28 11:56:52 UTC (rev 214472)
+++ trunk/Tools/ChangeLog 2017-03-28 14:06:49 UTC (rev 214473)
@@ -1,3 +1,32 @@
+2017-03-28 Jonathan Bedard <[email protected]>
+
+ webkitpy: Use host pattern for devices
+ https://bugs.webkit.org/show_bug.cgi?id=170121
+
+ Reviewed by Daniel Bates.
+
+ Devices should be treated like hosts throughout webkitpy
+ so that more code can be re-used. Add the needed properties
+ and use executive over custom implemented polling/killing
+ functions.
+
+ * Scripts/webkitpy/port/device.py:
+ (Device):
+ (Device.executive): Add optional executive property.
+ (Device.filesystem): Add optional filesystem property.
+ (Device.user): Add optional user property.
+ (Device.platform): Add optional platform property.
+ (Device.workspace): Add optional workspace property.
+ (Device.poll): Deleted.
+ * Scripts/webkitpy/port/simulator_process.py:
+ (SimulatorProcess.Popen.poll): Use the devices executive.
+ (SimulatorProcess.stop): Ditto.
+ (SimulatorProcess._kill): Ditto.
+ * Scripts/webkitpy/xcode/simulated_device.py:
+ (SimulatedDevice.__init__): Add executive, filesystem, user, platform
+ and workspace to the platform device.
+ (SimulatedDevice.poll): Deleted.
+
2017-03-28 Aakash Jain <[email protected]>
Dashboard test fails with error: latestIterationGetter is not a function
Modified: trunk/Tools/Scripts/webkitpy/port/device.py (214472 => 214473)
--- trunk/Tools/Scripts/webkitpy/port/device.py 2017-03-28 11:56:52 UTC (rev 214472)
+++ trunk/Tools/Scripts/webkitpy/port/device.py 2017-03-28 14:06:49 UTC (rev 214473)
@@ -31,11 +31,27 @@
def launch_app(self, bundle_id, args, env=None):
return self.platform_device.launch_app(bundle_id, args, env)
- # FIXME: This should be implemented through an executive
- def poll(self, pid):
- return self.platform_device.poll(pid)
+ @property
+ def executive(self):
+ return self.platform_device.executive
@property
+ def filesystem(self):
+ return self.platform_device.filesystem
+
+ @property
+ def user(self):
+ return self.platform_device.user
+
+ @property
+ def platform(self):
+ return self.platform_device.platform
+
+ @property
+ def workspace(self):
+ return self.platform_device.workspace
+
+ @property
def udid(self):
return self.platform_device.udid
Modified: trunk/Tools/Scripts/webkitpy/port/simulator_process.py (214472 => 214473)
--- trunk/Tools/Scripts/webkitpy/port/simulator_process.py 2017-03-28 11:56:52 UTC (rev 214472)
+++ trunk/Tools/Scripts/webkitpy/port/simulator_process.py 2017-03-28 14:06:49 UTC (rev 214473)
@@ -21,13 +21,11 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import errno
import os
import signal
import time
from webkitpy.port.server_process import ServerProcess
-from webkitpy.xcode.simulator import Simulator
class SimulatorProcess(ServerProcess):
@@ -45,7 +43,10 @@
def poll(self):
if self.returncode:
return self.returncode
- self.returncode = self._device.poll(self.pid)
+ if self._device.executive.check_running_pid(self.pid):
+ self.returncode = None
+ else:
+ self.returncode = 1
return self.returncode
def wait(self):
@@ -125,9 +126,11 @@
self._proc = SimulatorProcess.Popen(self._pid, stdin, stdout, stderr, self._device)
def stop(self, timeout_secs=3.0):
- try:
- os.kill(self._pid, signal.SIGTERM)
- except OSError as err:
- assert err.errno == errno.ESRCH
- pass
+ if self._proc:
+ self._device.executive.kill_process(self._proc.pid)
return super(SimulatorProcess, self).stop(timeout_secs)
+
+ def _kill(self):
+ self._device.executive.kill_process(self._proc.pid)
+ if self._proc.poll() is not None:
+ self._proc.wait()
Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py (214472 => 214473)
--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py 2017-03-28 11:56:52 UTC (rev 214472)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py 2017-03-28 14:06:49 UTC (rev 214473)
@@ -20,8 +20,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import errno
-import os
import logging
import re
import signal
@@ -57,6 +55,12 @@
self.name = name
self.udid = udid
+ self.executive = host.executive
+ self.filesystem = host.filesystem
+ self.user = None
+ self.platform = host.platform
+ self.workspace = host.workspace
+
@property
def state(self):
"""
@@ -180,7 +184,7 @@
)
match = re.match(r'(?P<bundle>[^:]+): (?P<pid>\d+)\n', output)
# FIXME: We shouldn't need to check the PID <rdar://problem/31154075>.
- if match and self.poll(int(match.group('pid'))) is None:
+ if match and self.executive.check_running_pid(int(match.group('pid'))):
break
signal.alarm(0) # Cancel alarm
@@ -189,14 +193,6 @@
raise RuntimeError('Failed to find process id for {}: {}'.format(bundle_id, output))
return int(match.group('pid'))
- def poll(self, pid):
- try:
- os.kill(pid, 0)
- except OSError as err:
- assert err.errno == errno.ESRCH
- return 1
- return None
-
def __eq__(self, other):
return self.udid == other.udid
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes