Skip to content

Commit 5cc5442

Browse files
committed
Update gdb test to account for fewer C calls.
1 parent 73041b5 commit 5cc5442

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

Lib/test/test_gdb.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -724,24 +724,36 @@ def test_two_abs_args(self):
724724
' 3 def foo(a, b, c):\n',
725725
bt)
726726

727+
SAMPLE_WITH_C_CALL = """
728+
729+
from _testcapi import pyobject_fastcall
730+
731+
def foo(a, b, c):
732+
bar(a, b, c)
733+
734+
def bar(a, b, c):
735+
pyobject_fastcall(baz, (a, b, c))
736+
737+
def baz(*args):
738+
id(42)
739+
740+
foo(1, 2, 3)
741+
742+
"""
743+
744+
727745
class StackNavigationTests(DebuggerTests):
728746
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
729747
@unittest.skipIf(python_is_optimized(),
730748
"Python was compiled with optimizations")
731749
def test_pyup_command(self):
732750
'Verify that the "py-up" command works'
733-
bt = self.get_stack_trace(script=self.get_sample_script(),
751+
bt = self.get_stack_trace(source=SAMPLE_WITH_C_CALL,
734752
cmds_after_breakpoint=['py-up', 'py-up'])
735753
self.assertMultilineMatches(bt,
736754
r'''^.*
737-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
738-
id\(42\)
739-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
740-
baz\(a, b, c\)
741-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
742-
bar\(a=a, b=b, c=c\)
743-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
744-
foo\(1, 2, 3\)
755+
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
756+
#[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
745757
$''')
746758

747759
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
@@ -765,22 +777,13 @@ def test_up_at_top(self):
765777
"Python was compiled with optimizations")
766778
def test_up_then_down(self):
767779
'Verify "py-up" followed by "py-down"'
768-
bt = self.get_stack_trace(script=self.get_sample_script(),
780+
bt = self.get_stack_trace(source=SAMPLE_WITH_C_CALL,
769781
cmds_after_breakpoint=['py-up', 'py-up', 'py-down'])
770782
self.assertMultilineMatches(bt,
771783
r'''^.*
772-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
773-
id\(42\)
774-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
775-
baz\(a, b, c\)
776-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
777-
bar\(a=a, b=b, c=c\)
778-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
779-
foo\(1, 2, 3\)
780-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
781-
id\(42\)
782-
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
783-
baz\(a, b, c\)
784+
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
785+
#[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
786+
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
784787
$''')
785788

786789
class PyBtTests(DebuggerTests):
@@ -970,13 +973,12 @@ def __init__(self):
970973
self.assertRegex(gdb_output,
971974
r"<method-wrapper u?'__init__' of MyList object at ")
972975

973-
974976
class PyPrintTests(DebuggerTests):
975977
@unittest.skipIf(python_is_optimized(),
976978
"Python was compiled with optimizations")
977979
def test_basic_command(self):
978980
'Verify that the "py-print" command works'
979-
bt = self.get_stack_trace(script=self.get_sample_script(),
981+
bt = self.get_stack_trace(source=SAMPLE_WITH_C_CALL,
980982
cmds_after_breakpoint=['py-up', 'py-print args'])
981983
self.assertMultilineMatches(bt,
982984
r".*\nlocal 'args' = \(1, 2, 3\)\n.*")
@@ -985,7 +987,7 @@ def test_basic_command(self):
985987
"Python was compiled with optimizations")
986988
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
987989
def test_print_after_up(self):
988-
bt = self.get_stack_trace(script=self.get_sample_script(),
990+
bt = self.get_stack_trace(source=SAMPLE_WITH_C_CALL,
989991
cmds_after_breakpoint=['py-up', 'py-up', 'py-print c', 'py-print b', 'py-print a'])
990992
self.assertMultilineMatches(bt,
991993
r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*")

0 commit comments

Comments
 (0)