Skip to content

Commit 0bdbc48

Browse files
[3.15] Rename fp unwind test module to C stack unwind (GH-149563) (#149565)
1 parent 54a187d commit 0bdbc48

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""Test in-process C stack unwinders against Python and JIT frames.
2+
3+
The tests build a recursive Python call stack, ask each _testinternalcapi
4+
unwinder for return addresses, and classify those addresses as Python, JIT, or
5+
other frames. The backends include CPython's manual stack-chain unwinder and
6+
GNU backtrace(), so this module is about in-process C stack unwinding rather
7+
than a single unwind mechanism. GDB integration tests live in test_gdb.
8+
"""
9+
110
import json
211
import os
312
import platform
@@ -20,7 +29,7 @@
2029
STACK_DEPTH = 10
2130

2231

23-
def _frame_pointers_expected(machine):
32+
def _manual_unwind_expected(machine):
2433
_Py_WITH_FRAME_POINTERS = getattr(
2534
_testinternalcapi,
2635
"_Py_WITH_FRAME_POINTERS",
@@ -195,7 +204,7 @@ def _annotate_unwind_after_executor_free(unwinder_name="gnu_backtrace_unwind"):
195204

196205
def _run_unwind_helper(helper_name, unwinder_name, **env):
197206
code = (
198-
f"from test.test_frame_pointer_unwind import {helper_name}; "
207+
f"from test.test_c_stack_unwind import {helper_name}; "
199208
f"print({helper_name}({unwinder_name!r}));"
200209
)
201210
run_env = os.environ.copy()
@@ -235,28 +244,32 @@ def _unwind_after_executor_free_result(unwinder_name, **env):
235244

236245
@support.requires_gil_enabled("test requires the GIL enabled")
237246
@unittest.skipIf(support.is_wasi, "test not supported on WASI")
238-
class FramePointerUnwindTests(unittest.TestCase):
247+
class ManualStackUnwindTests(unittest.TestCase):
239248

240249
def setUp(self):
241250
super().setUp()
242251

243252
machine = platform.machine().lower()
244-
expected = _frame_pointers_expected(machine)
253+
expected = _manual_unwind_expected(machine)
245254
if expected is None:
246-
self.skipTest(f"unsupported architecture for frame pointer check: {machine}")
255+
self.skipTest(
256+
f"unsupported architecture for manual stack unwind check: {machine}"
257+
)
247258
if expected == "crash":
248259
self.skipTest(f"test does crash on {machine}")
249260

250261
try:
251262
_testinternalcapi.manual_frame_pointer_unwind()
252263
except RuntimeError as exc:
253264
if "not supported" in str(exc):
254-
self.skipTest("manual frame pointer unwinding not supported on this platform")
265+
self.skipTest(
266+
"manual stack unwinding not supported on this platform"
267+
)
255268
raise
256269
self.machine = machine
257-
self.frame_pointers_expected = expected
270+
self.manual_unwind_expected = expected
258271

259-
def test_manual_unwind_respects_frame_pointers(self):
272+
def test_manual_unwind_finds_expected_frames(self):
260273
jit_available = hasattr(sys, "_jit") and sys._jit.is_available()
261274
envs = [({"PYTHON_JIT": "0"}, False)]
262275
if jit_available:
@@ -268,7 +281,7 @@ def test_manual_unwind_respects_frame_pointers(self):
268281
jit_frames = result["jit_frames"]
269282
python_frames = result.get("python_frames", 0)
270283
jit_backend = result.get("jit_backend")
271-
if self.frame_pointers_expected:
284+
if self.manual_unwind_expected:
272285
self.assertGreaterEqual(
273286
python_frames,
274287
STACK_DEPTH,

0 commit comments

Comments
 (0)