- Revision
- 111750
- Author
- dpra...@chromium.org
- Date
- 2012-03-22 13:29:22 -0700 (Thu, 22 Mar 2012)
Log Message
nrwt: crash while stopping layout test helper on apple mac lion
https://bugs.webkit.org/show_bug.cgi?id=81949
Reviewed by Eric Seidel.
stop_helper() didn't work right if the helper process wasn't
still running or didn't respond properly to being shut down. Fix
this and add some tests. Also add code to MockExecutive() to be
able to mock executive.popen() properly.
* Scripts/webkitpy/common/system/executive_mock.py:
(MockProcess.__init__):
(MockProcess.wait):
(MockExecutive.__init__):
(MockExecutive.popen):
* Scripts/webkitpy/common/system/systemhost_mock.py:
(MockSystemHost.__init__):
* Scripts/webkitpy/layout_tests/port/mac.py:
(MacPort.start_helper):
(MacPort.stop_helper):
* Scripts/webkitpy/layout_tests/port/mac_unittest.py:
(test_get_crash_log):
(test_helper_starts):
(test_helper_fails_to_start):
(test_helper_fails_to_stop):
(test_helper_fails_to_stop.bad_waiter):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (111749 => 111750)
--- trunk/Tools/ChangeLog 2012-03-22 20:23:01 UTC (rev 111749)
+++ trunk/Tools/ChangeLog 2012-03-22 20:29:22 UTC (rev 111750)
@@ -1,3 +1,32 @@
+2012-03-22 Dirk Pranke <dpra...@chromium.org>
+
+ nrwt: crash while stopping layout test helper on apple mac lion
+ https://bugs.webkit.org/show_bug.cgi?id=81949
+
+ Reviewed by Eric Seidel.
+
+ stop_helper() didn't work right if the helper process wasn't
+ still running or didn't respond properly to being shut down. Fix
+ this and add some tests. Also add code to MockExecutive() to be
+ able to mock executive.popen() properly.
+
+ * Scripts/webkitpy/common/system/executive_mock.py:
+ (MockProcess.__init__):
+ (MockProcess.wait):
+ (MockExecutive.__init__):
+ (MockExecutive.popen):
+ * Scripts/webkitpy/common/system/systemhost_mock.py:
+ (MockSystemHost.__init__):
+ * Scripts/webkitpy/layout_tests/port/mac.py:
+ (MacPort.start_helper):
+ (MacPort.stop_helper):
+ * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
+ (test_get_crash_log):
+ (test_helper_starts):
+ (test_helper_fails_to_start):
+ (test_helper_fails_to_stop):
+ (test_helper_fails_to_stop.bad_waiter):
+
2012-03-22 Gustavo Noronha Silva <g...@gnome.org>
[GTK] Add make to the jhbuild moduleset
Modified: trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py (111749 => 111750)
--- trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py 2012-03-22 20:23:01 UTC (rev 111749)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive_mock.py 2012-03-22 20:29:22 UTC (rev 111750)
@@ -27,15 +27,20 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
+import StringIO
from webkitpy.common.system.deprecated_logging import log
from webkitpy.common.system.executive import ScriptError
class MockProcess(object):
- def __init__(self):
+ def __init__(self, stdout='MOCK STDOUT\n'):
self.pid = 42
+ self.stdout = StringIO.StringIO(stdout)
+ self.stdin = StringIO.StringIO()
+ def wait(self):
+ return
# FIXME: This should be unified with MockExecutive2
class MockExecutive(object):
@@ -52,6 +57,7 @@
self._should_throw_when_run = should_throw_when_run or set()
# FIXME: Once executive wraps os.getpid() we can just use a static pid for "this" process.
self._running_pids = [os.getpid()]
+ self._proc = None
def check_running_pid(self, pid):
return pid in self._running_pids
@@ -91,7 +97,9 @@
def popen(self, *args, **kwargs):
# FIXME: Implement logging when self._should_log is set.
- return MockProcess()
+ if not self._proc:
+ self._proc = MockProcess()
+ return self._proc
class MockExecutive2(object):
Modified: trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py (111749 => 111750)
--- trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py 2012-03-22 20:23:01 UTC (rev 111749)
+++ trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py 2012-03-22 20:29:22 UTC (rev 111750)
@@ -35,8 +35,8 @@
class MockSystemHost(object):
- def __init__(self, log_executive=False, executive_throws_when_run=None, os_name=None, os_version=None):
- self.executive = MockExecutive(should_log=log_executive, should_throw_when_run=executive_throws_when_run)
+ def __init__(self, log_executive=False, executive_throws_when_run=None, os_name=None, os_version=None, executive=None):
+ self.executive = executive or MockExecutive(should_log=log_executive, should_throw_when_run=executive_throws_when_run)
self.filesystem = MockFileSystem()
self.user = MockUser()
self.platform = MockPlatformInfo()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py (111749 => 111750)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py 2012-03-22 20:23:01 UTC (rev 111749)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py 2012-03-22 20:29:22 UTC (rev 111750)
@@ -186,7 +186,7 @@
if helper_path:
_log.debug("Starting layout helper %s" % helper_path)
# Note: Not thread safe: http://bugs.python.org/issue2320
- self._helper = subprocess.Popen([helper_path],
+ self._helper = self._executive.popen([helper_path],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None)
is_ready = self._helper.stdout.readline()
if not is_ready.startswith('ready'):
@@ -195,6 +195,11 @@
def stop_helper(self):
if self._helper:
_log.debug("Stopping LayoutTestHelper")
- self._helper.stdin.write("x\n")
- self._helper.stdin.close()
- self._helper.wait()
+ try:
+ self._helper.stdin.write("x\n")
+ self._helper.stdin.close()
+ self._helper.wait()
+ except IOError, e:
+ _log.debug("IOError raised while stopping helper: %s" % str(e))
+ pass
+ self._helper = None
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py (111749 => 111750)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py 2012-03-22 20:23:01 UTC (rev 111749)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py 2012-03-22 20:29:22 UTC (rev 111750)
@@ -31,7 +31,7 @@
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.tool.mocktool import MockOptions
-from webkitpy.common.system.executive_mock import MockExecutive
+from webkitpy.common.system.executive_mock import MockExecutive, MockProcess
from webkitpy.common.system.systemhost_mock import MockSystemHost
@@ -192,3 +192,31 @@
def test_get_crash_log(self):
# Mac crash logs are tested elsewhere
pass
+
+ def test_helper_starts(self):
+ host = MockSystemHost(MockExecutive())
+ port = self.make_port(host)
+ host.executive._proc = MockProcess('ready\n')
+ port.start_helper()
+ port.stop_helper()
+
+ # make sure trying to stop the helper twice is safe.
+ port.stop_helper()
+
+ def test_helper_fails_to_start(self):
+ host = MockSystemHost(MockExecutive())
+ port = self.make_port(host)
+ port.start_helper()
+ port.stop_helper()
+
+ def test_helper_fails_to_stop(self):
+ host = MockSystemHost(MockExecutive())
+ host.executive._proc = MockProcess()
+
+ def bad_waiter():
+ raise IOError('failed to wait')
+ host.executive._proc.wait = bad_waiter
+
+ port = self.make_port(host)
+ port.start_helper()
+ port.stop_helper()