summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,