Rev 2528: Fix race in test_breakin_harder that can cause test suite hang. in http://sourcefrog.net/bzr/breakin
Martin Pool
mbp at sourcefrog.net
Wed Jun 13 10:29:58 BST 2007
At http://sourcefrog.net/bzr/breakin
------------------------------------------------------------
revno: 2528
revision-id: mbp at sourcefrog.net-20070613092840-0v9ph8iklj52agdj
parent: pqm at pqm.ubuntu.com-20070613061627-xx5xk6q0oxcy1etm
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: breakin
timestamp: Wed 2007-06-13 19:28:40 +1000
message:
Fix race in test_breakin_harder that can cause test suite hang.
We don't know quite when the subprocess is ready to receive a signal,
so send it a few times til it has an effect. (#119566)
modified:
bzrlib/tests/blackbox/test_breakin.py test_breakin.py-20070424043903-qyy6zm4pj3h4sbp3-1
=== modified file 'bzrlib/tests/blackbox/test_breakin.py'
--- a/bzrlib/tests/blackbox/test_breakin.py 2007-04-24 04:51:31 +0000
+++ b/bzrlib/tests/blackbox/test_breakin.py 2007-06-13 09:28:40 +0000
@@ -57,12 +57,25 @@
env_changes=dict(BZR_SIGQUIT_PDB=None))
# wait for it to get started, and print the 'listening' line
proc.stdout.readline()
- # another hit gives the default behaviour of terminating it
- os.kill(proc.pid, signal.SIGQUIT)
- # wait for it to go into pdb
- time.sleep(.5)
- os.kill(proc.pid, signal.SIGQUIT)
- proc.wait()
+ # break into the debugger
+ os.kill(proc.pid, signal.SIGQUIT)
+ # now send a second sigquit, which should cause it to exit. That
+ # won't happen until the original signal has been noticed by the
+ # child and it's run its signal handler. We don't know quite how long
+ # this will take, but if it's more than 10s then it's probably not
+ # going to work.
+ for i in range(100):
+ time.sleep(0.1)
+ os.kill(proc.pid, signal.SIGQUIT)
+ # note: waitpid is different on win32, but this test only runs on
+ # unix
+ r = os.waitpid(proc.pid, os.WNOHANG)
+ if r != (0, 0):
+ # high bit says if core was dumped; we don't care
+ self.assertEquals(r[1] & 0x7f, signal.SIGQUIT)
+ break
+ else:
+ self.fail("subprocess wasn't terminated by repeated SIGQUIT")
def test_breakin_disabled(self):
proc = self.start_bzr_subprocess(self._test_process_args,
More information about the bazaar-commits
mailing list