summaryrefslogtreecommitdiffstats
path: root/test_gdb.py
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2010-02-25 19:43:16 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2010-02-25 19:43:16 -0500
commitbb12aba0beb09ecc262a8e61a7b49b5aef1049b9 (patch)
treeaa34fd909cb3004e7db1218f4d0a130df760c97e /test_gdb.py
parent33067f32c1243b9cf580de798db38defc98bd3a9 (diff)
downloadlibpython-bb12aba0beb09ecc262a8e61a7b49b5aef1049b9.zip
libpython-bb12aba0beb09ecc262a8e61a7b49b5aef1049b9.tar.gz
libpython-bb12aba0beb09ecc262a8e61a7b49b5aef1049b9.tar.xz
Add test for the gdb representation of old-style classes
Diffstat (limited to 'test_gdb.py')
-rw-r--r--test_gdb.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/test_gdb.py b/test_gdb.py
index 127f19a..bf57a13 100644
--- a/test_gdb.py
+++ b/test_gdb.py
@@ -75,7 +75,7 @@ class DebuggerTests(unittest.TestCase):
sys.executable, "-S", "-c", source)
return gdb_output
- def get_gdb_repr(self, in_repr):
+ def get_gdb_repr(self, source):
# Given an input python source representation of data,
# run "python -c'print DATA'" under gdb with a breakpoint on
# PyObject_Print and scrape out gdb's representation of the "op"
@@ -83,7 +83,7 @@ class DebuggerTests(unittest.TestCase):
#
# For a nested structure, the first time we hit the breakpoint will
# give us the top-level structure
- gdb_output = self.get_stack_trace('print ' + in_repr)
+ gdb_output = self.get_stack_trace(source)
m = re.match('.*Breakpoint 1, PyObject_Print \(op\=(.*?), fp=.*\).*', gdb_output, re.DOTALL)
# print m.groups()
return m.group(1), gdb_output
@@ -95,7 +95,7 @@ class DebuggerTests(unittest.TestCase):
def assertGdbRepr(self, val):
# Ensure that gdb's rendering of the value in a debugged process
# matches repr(value) in this process:
- gdb_repr, gdb_output = self.get_gdb_repr(repr(val))
+ gdb_repr, gdb_output = self.get_gdb_repr('print ' + repr(val))
self.assertEquals(gdb_repr, repr(val), gdb_output)
def test_int(self):
@@ -136,13 +136,24 @@ class DebuggerTests(unittest.TestCase):
self.assertGdbRepr( u'hello world', )
self.assertGdbRepr( u'\u2620')
+ def test_classic_class(self):
+ gdb_repr, gdb_output = self.get_gdb_repr('''
+class Foo:
+ pass
+foo = Foo();
+foo.an_int = 42;
+print foo''')
+ # FIXME: is there an "assertMatches"; should there be?
+ m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+ self.assertTrue(m, msg='Unexpected classic-class rendering %r' % gdb_repr)
+
# TODO:
- # old-style classes
# new-style classes
# frames
def test_main():
- run_unittest(DebuggerTests)
+ #run_unittest(DebuggerTests)
+ unittest.main()
if __name__ == "__main__":