Rev 4170: Take Martin and John review comments into account and tighten the tests. in file:///home/vila/src/bzr/experimental/parallel-selftest/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Mar 20 07:49:52 GMT 2009


At file:///home/vila/src/bzr/experimental/parallel-selftest/

------------------------------------------------------------
revno: 4170
revision-id: v.ladeuil+lp at free.fr-20090320074951-t9osiw77vmmj0b8y
parent: v.ladeuil+lp at free.fr-20090320065607-j2vi19cy7x5uhmr9
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: fixes
timestamp: Fri 2009-03-20 08:49:51 +0100
message:
  Take Martin and John review comments into account and tighten the tests.
  
  * bzrlib/tests/blackbox/test_breakin.py:
  (TestBreakin.test_breakin): Restore the test and make its intent
  clearer.
  (TestBreakin.test_breakin_harder): Remove timing dependencies.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_breakin.py'
--- a/bzrlib/tests/blackbox/test_breakin.py	2009-03-20 06:56:07 +0000
+++ b/bzrlib/tests/blackbox/test_breakin.py	2009-03-20 07:49:51 +0000
@@ -47,7 +47,26 @@
     # port 0 means to allocate any port
     _test_process_args = ['serve', '--port', 'localhost:0']
 
+    def test_breakin(self):
+        """Once called, the debugger can be exited and finishes the process."""
+        # Break in to a debugger while bzr is running
+        # we need to test against a command that will wait for
+        # a while -- bzr serve should do
+        proc = self.start_bzr_subprocess(self._test_process_args,
+                env_changes=dict(BZR_SIGQUIT_PDB=None))
+        # wait for it to get started, and print the 'listening' line
+        proc.stderr.readline()
+        # first sigquit pops into debugger
+        os.kill(proc.pid, signal.SIGQUIT)
+        # Wait for the debugger to acknowledge the signal reception
+        err = proc.stderr.readline()
+        self.assertContainsRe(err, r'entering debugger')
+        # Now that the debugger is entered, we can ask him to quit
+        proc.stdin.write("q\n")
+        # And the subprocess should just die quietly...
+
     def test_breakin_harder(self):
+        """SIGQUITting twice ends the process."""
         self._dont_SIGQUIT_on_darwin()
         proc = self.start_bzr_subprocess(self._test_process_args,
                 env_changes=dict(BZR_SIGQUIT_PDB=None))
@@ -55,23 +74,21 @@
         proc.stderr.readline()
         # break into the debugger
         os.kill(proc.pid, signal.SIGQUIT)
+        # Wait for the debugger to acknowledge the signal reception (since we
+        # want to send a second signal, we ensure it doesn't get lost by
+        # validating the first get received and produce its effect).
         err = proc.stderr.readline()
         self.assertContainsRe(err, r'entering debugger')
-        # 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
+        # Now a second signal should make it quit. 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(signal.SIGQUIT, r[1] & 0x7f)
-                break
+        os.kill(proc.pid, signal.SIGQUIT)
+        # note: waitpid is different on win32, but this test only runs on
+        # unix
+        r = os.waitpid(proc.pid, 0)
+        if r != (0, 0):
+            # high bit says if core was dumped; we don't care
+            self.assertEquals(signal.SIGQUIT, r[1] & 0x7f)
         else:
             self.fail("subprocess wasn't terminated by repeated SIGQUIT")
 



More information about the bazaar-commits mailing list