Permalink
Browse files

use crash that will also kill a Windows engine

crash is from the Python test suite

Windows crash dialog is suppressed prior to crash

also fixed 'assertRaisesRemote' message, which had names backwards
  • Loading branch information...
1 parent 0d3d807 commit 151aca80fb1b7f782aa6ae190f3bbf71897d9b02 @minrk committed Apr 14, 2011
Showing with 23 additions and 8 deletions.
  1. +12 −1 IPython/parallel/tests/clienttest.py
  2. +11 −7 IPython/parallel/tests/test_view.py
@@ -29,6 +29,17 @@ def segfault():
import ctypes
ctypes.memset(-1,0,1)
+def crash():
+ """from stdlib crashers in the test suite"""
+ import types
+ if sys.platform.startswith('win'):
+ import ctypes
+ ctypes.windll.kernel32.SetErrorMode(0x0002);
+
+ co = types.CodeType(0, 0, 0, 0, b'\x04\x71\x00\x00',
+ (), (), (), '', '', 1, b'')
+ exec(co)
+
def wait(n):
"""sleep for a time"""
import time
@@ -86,7 +97,7 @@ def assertRaisesRemote(self, etype, f, *args, **kwargs):
except error.CompositeError as e:
e.raise_exception()
except error.RemoteError as e:
- self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(e.ename, etype.__name__))
+ self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename))
else:
self.fail("should have raised a RemoteError")
@@ -25,33 +25,37 @@
from IPython.parallel.tests import add_engines
-from .clienttest import ClusterTestCase, segfault, wait, skip_without
+from .clienttest import ClusterTestCase, crash, wait, skip_without
def setup():
add_engines(3)
class TestView(ClusterTestCase):
- def test_segfault_task(self):
+ def test_crash_task(self):
"""test graceful handling of engine death (balanced)"""
# self.add_engines(1)
- ar = self.client[-1].apply_async(segfault)
+ ar = self.client[-1].apply_async(crash)
self.assertRaisesRemote(error.EngineError, ar.get)
eid = ar.engine_id
- while eid in self.client.ids:
+ tic = time.time()
+ while eid in self.client.ids and time.time()-tic < 5:
time.sleep(.01)
self.client.spin()
+ self.assertFalse(eid in self.client.ids, "Engine should have died")
- def test_segfault_mux(self):
+ def test_crash_mux(self):
"""test graceful handling of engine death (direct)"""
# self.add_engines(1)
eid = self.client.ids[-1]
- ar = self.client[eid].apply_async(segfault)
+ ar = self.client[eid].apply_async(crash)
self.assertRaisesRemote(error.EngineError, ar.get)
eid = ar.engine_id
- while eid in self.client.ids:
+ tic = time.time()
+ while eid in self.client.ids and time.time()-tic < 5:
time.sleep(.01)
self.client.spin()
+ self.assertFalse(eid in self.client.ids, "Engine should have died")
def test_push_pull(self):
"""test pushing and pulling"""

0 comments on commit 151aca8

Please sign in to comment.