Rev 5916: (mbp) remove test_breakin (Martin Pool) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu May 26 07:49:04 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5916 [merge]
revision-id: pqm at pqm.ubuntu.com-20110526074901-tz91yfnl7a8ggkvk
parent: pqm at pqm.ubuntu.com-20110525165736-3hifkztwm0f5jawx
parent: mbp at canonical.com-20110526030040-aesg1r59tdyz5nyf
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-05-26 07:49:01 +0000
message:
(mbp) remove test_breakin (Martin Pool)
removed:
bzrlib/tests/blackbox/test_breakin.py test_breakin.py-20070424043903-qyy6zm4pj3h4sbp3-1
modified:
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py 2011-05-17 13:21:33 +0000
+++ b/bzrlib/tests/blackbox/__init__.py 2011-05-20 13:34:24 +0000
@@ -45,7 +45,6 @@
'test_annotate',
'test_branch',
'test_break_lock',
- 'test_breakin',
'test_bound_branches',
'test_bundle_info',
'test_cat',
=== removed file 'bzrlib/tests/blackbox/test_breakin.py'
--- a/bzrlib/tests/blackbox/test_breakin.py 2011-05-24 19:18:08 +0000
+++ b/bzrlib/tests/blackbox/test_breakin.py 1970-01-01 00:00:00 +0000
@@ -1,205 +0,0 @@
-# Copyright (C) 2006, 2007, 2009 Canonical Ltd
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-"""Blackbox tests for debugger breakin"""
-
-try:
- import ctypes
- have_ctypes = True
-except ImportError:
- have_ctypes = False
-import errno
-import os
-import signal
-import subprocess
-import sys
-import time
-
-from bzrlib import (
- breakin,
- errors,
- tests,
- )
-
-
-class TestBreakin(tests.TestCase):
- # FIXME: If something is broken, these tests may just hang indefinitely in
- # wait() waiting for the child to exit when it's not going to.
-
- def setUp(self):
- super(TestBreakin, self).setUp()
- self.requireFeature(tests.BreakinFeature)
-
- def _send_signal_via_kill(self, pid, sig_type):
- if sig_type == 'break':
- sig_num = signal.SIGQUIT
- elif sig_type == 'kill':
- sig_num = signal.SIGKILL
- else:
- raise ValueError("unknown signal type: %s" % (sig_type,))
- try:
- os.kill(pid, sig_num)
- except OSError, e:
- if e.errno != errno.ESRCH:
- raise
-
- def _send_signal_win32(self, pid, sig_type):
- """Send a 'signal' on Windows.
-
- Windows doesn't really have signals in the same way. All it really
- supports is:
- 1) Sending SIGINT to the *current* process group (so self, and all
- children of self)
- 2) Sending SIGBREAK to a process that shares the current console,
- which can be in its own process group.
- So we have start_bzr_subprocess create a new process group for the
- spawned process (via a flag to Popen), and then we map
- SIGQUIT to GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT)
- SIGKILL to TerminateProcess
- """
- if sig_type == 'break':
- CTRL_BREAK_EVENT = 1
- # CTRL_C_EVENT = 0
- ret = ctypes.windll.kernel32.GenerateConsoleCtrlEvent(
- CTRL_BREAK_EVENT, pid)
- if ret == 0: #error
- err = ctypes.FormatError()
- raise RuntimeError('failed to send CTRL_BREAK: %s'
- % (err,))
- elif sig_type == 'kill':
- # Does the exit code matter? For now we are just setting it to
- # something other than 0
- exit_code = breakin.determine_signal()
- ctypes.windll.kernel32.TerminateProcess(pid, exit_code)
-
- if sys.platform == 'win32':
- _send_signal = _send_signal_win32
- else:
- _send_signal = _send_signal_via_kill
-
- def _popen(self, *args, **kwargs):
- if sys.platform == 'win32':
- CREATE_NEW_PROCESS_GROUP = 512
- # This allows us to send a signal to the child, *without* also
- # sending it to ourselves
- kwargs['creationflags'] = CREATE_NEW_PROCESS_GROUP
- return super(TestBreakin, self)._popen(*args, **kwargs)
-
- def _dont_SIGQUIT_on_darwin(self):
- if sys.platform == 'darwin':
- # At least on Leopard and with python 2.6, this test will raise a
- # popup window asking if the python failure should be reported to
- # Apple... That's not the point of the test :) Marking the test as
- # not applicable Until we find a way to disable that intrusive
- # behavior... --vila20080611
- raise tests.TestNotApplicable(
- '%s raises a popup on OSX' % self.id())
-
- def _wait_for_process(self, pid, sig=None, count=100):
- # We don't know quite how long waiting for the process 'pid' will take,
- # but if it's more than 10s then it's probably not going to work.
- for i in range(count):
- if sig is not None:
- self._send_signal(pid, sig)
- # Use WNOHANG to ensure we don't get blocked, doing so, we may
- # leave the process continue after *we* die...
- # Win32 doesn't support WNOHANG, so we just pass 0
- opts = getattr(os, 'WNOHANG', 0)
- try:
- # TODO: waitpid doesn't work well on windows, we might consider
- # using WaitForSingleObject(proc._handle, TIMEOUT)
- # instead. Most notably, the WNOHANG isn't allowed, so
- # this can hang indefinitely.
- pid_killed, returncode = os.waitpid(pid, opts)
- if pid_killed != 0 and returncode != 0:
- if sig is not None:
- # high bit in low byte says if core was dumped; we
- # don't care
- status, sig = (returncode >> 8, returncode & 0x7f)
- return True, sig
- except OSError, e:
- if e.errno in (errno.ECHILD, errno.ESRCH):
- # The process doesn't exist anymore
- return True, None
- else:
- raise
- if i + 1 != count:
- time.sleep(0.1)
-
- return False, None
-
- # port 0 means to allocate any port
- _test_process_args = ['serve', '--port', 'localhost:0']
-
- def test_breakin(self):
- # 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
- self._send_signal(proc.pid, 'break')
- # Wait for the debugger to acknowledge the signal reception
- # Note that it is possible for this to deadlock if the child doesn't
- # acknowlege the signal and write to stderr. Perhaps we should try
- # os.read(proc.stderr.fileno())?
- err = proc.stderr.readline()
- self.assertContainsRe(err, r'entering debugger')
- # Try to shutdown cleanly;
- # Now that the debugger is entered, we can ask him to quit
- proc.stdin.write("q\n")
- # But we don't really care if it doesn't.
- dead, sig = self._wait_for_process(proc.pid, count=3)
- if not dead:
- # The process didn't finish, let's kill it.
- dead, sig = self._wait_for_process(proc.pid, 'kill', count=10)
- if not dead:
- # process isn't gone, user will have to hunt it down and kill
- # it.
- self.fail("subprocess %d wasn't terminated by repeated SIGKILL" %
- proc.pid)
-
- 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))
- # wait for it to get started, and print the 'listening' line
- proc.stderr.readline()
- # break into the debugger
- self._send_signal(proc.pid, 'break')
- # 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')
- dead, sig = self._wait_for_process(proc.pid, 'break')
- self.assertTrue(dead)
- # Either the child was dead before we could read its status, or the
- # child was dead from the signal we sent it.
- self.assertTrue(sig in (None, breakin.determine_signal()))
-
- def test_breakin_disabled(self):
- self._dont_SIGQUIT_on_darwin()
- proc = self.start_bzr_subprocess(self._test_process_args,
- env_changes=dict(BZR_SIGQUIT_PDB='0'))
- # wait for it to get started, and print the 'listening' line
- proc.stderr.readline()
- # first hit should just kill it
- self._send_signal(proc.pid, 'break')
- proc.wait()
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-05-25 14:17:27 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-05-26 03:00:40 +0000
@@ -177,10 +177,13 @@
restoring the wt_scenarios helper that was accidentally deleted.
(Vincent Ladeuil, #783472)
+* Removed ``test_breakin`` tests that were excessively prone to hanging,
+ did not work on Wine, and partly already disabled.
+ (Martin Pool, #408814, #746985)
+
* Windows locations are different and should be tested accordingly.
(Vincent Ladeuil, #788131)
-
bzr 2.4b2
#########
More information about the bazaar-commits
mailing list