1
# Copyright (C) 2006, 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Blackbox tests for debugger breakin"""
25
from bzrlib.tests import TestCase, TestSkipped
28
class TestBreakin(TestCase):
29
# FIXME: If something is broken, these tests may just hang indefinitely in
30
# wait() waiting for the child to exit when it's not going to.
33
if sys.platform == 'win32':
34
raise TestSkipped('breakin signal not tested on win32')
35
super(TestBreakin, self).setUp()
37
# port 0 means to allocate any port
38
_test_process_args = ['serve', '--port', 'localhost:0']
40
def test_breakin(self):
41
# Break in to a debugger while bzr is running
42
# we need to test against a command that will wait for
43
# a while -- bzr serve should do
44
proc = self.start_bzr_subprocess(self._test_process_args,
45
env_changes=dict(BZR_SIGQUIT_PDB=None))
46
# wait for it to get started, and print the 'listening' line
47
proc.stdout.readline()
48
# first sigquit pops into debugger
49
os.kill(proc.pid, signal.SIGQUIT)
50
proc.stdin.write("q\n")
52
err = proc.stderr.readline()
53
self.assertContainsRe(err, r'entering debugger')
55
def test_breakin_harder(self):
56
proc = self.start_bzr_subprocess(self._test_process_args,
57
env_changes=dict(BZR_SIGQUIT_PDB=None))
58
# wait for it to get started, and print the 'listening' line
59
proc.stdout.readline()
60
# another hit gives the default behaviour of terminating it
61
os.kill(proc.pid, signal.SIGQUIT)
62
# wait for it to go into pdb
64
os.kill(proc.pid, signal.SIGQUIT)
67
def test_breakin_disabled(self):
68
proc = self.start_bzr_subprocess(self._test_process_args,
69
env_changes=dict(BZR_SIGQUIT_PDB='0'))
70
# wait for it to get started, and print the 'listening' line
71
proc.stdout.readline()
72
# first hit should just kill it
73
os.kill(proc.pid, signal.SIGQUIT)