summaryrefslogtreecommitdiffstats
path: root/test_gdb.py
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2010-02-25 20:47:19 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2010-02-25 20:47:19 -0500
commit21dc2fe23c9186f67f7170c70e69127e2a317269 (patch)
treec286b686f0c758010b7746a2a2de551c457cc805 /test_gdb.py
parent8f8e182856fed32ce0a67a04cc054bb7e88d1e14 (diff)
downloadlibpython-21dc2fe23c9186f67f7170c70e69127e2a317269.zip
libpython-21dc2fe23c9186f67f7170c70e69127e2a317269.tar.gz
libpython-21dc2fe23c9186f67f7170c70e69127e2a317269.tar.xz
Verify stderr from gdb contains nothing unexpected (and stop some noise during test runs)
Diffstat (limited to 'test_gdb.py')
-rw-r--r--test_gdb.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/test_gdb.py b/test_gdb.py
index bf57a13..36aa8de 100644
--- a/test_gdb.py
+++ b/test_gdb.py
@@ -36,16 +36,12 @@ class DebuggerTests(unittest.TestCase):
"""Test that the debugger can debug Python."""
def run_gdb(self, *args):
- """Runs gdb with the command line given by *args. Returns its stdout.
-
- Forwards stderr to the current process's stderr.
+ """Runs gdb with the command line given by *args. Returns its stdout, stderr
"""
- # err winds up empty.
out, err = subprocess.Popen(
- args, stdout=subprocess.PIPE,
- stderr=None, # Forward stderr to the current process's stderr.
+ args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
).communicate()
- return out
+ return out, err
def get_stack_trace(self, source, breakpoint='PyObject_Print'):
'''
@@ -65,15 +61,22 @@ class DebuggerTests(unittest.TestCase):
# Initially I had "--eval-command=continue" here, but removed it to
# avoid repeated print breakpoints when traversing hierarchical data
# structures
- gdb_output = self.run_gdb("gdb", "--batch",
- "--eval-command=set breakpoint pending yes",
- "--eval-command=break %s" % breakpoint,
-
- "--eval-command=run",
- "--eval-command=backtrace",
- "--args",
- sys.executable, "-S", "-c", source)
- return gdb_output
+ out, err = self.run_gdb("gdb", "--batch",
+ "--eval-command=set breakpoint pending yes",
+ "--eval-command=break %s" % breakpoint,
+
+ "--eval-command=run",
+ "--eval-command=backtrace",
+ "--args",
+ sys.executable, "-S", "-c", source)
+
+ # Ignore some noise on stderr due to the pending breakpoint:
+ err = err.replace('Function "%s" not defined.\n' % breakpoint, '')
+
+ # Ensure no unexpected error messages:
+ self.assertEquals(err, '')
+
+ return out
def get_gdb_repr(self, source):
# Given an input python source representation of data,