8000 Add tests. · python/cpython@4f09358 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f09358

Browse files
committed
Add tests.
1 parent 8a5b784 commit 4f09358

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Lib/test/test_faulthandler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,20 @@ def check_error(self, code, lineno, fatal_error, *,
9393
fd=None, know_current_thread=True,
9494
py_fatal_error=False,
9595
garbage_collecting=False,
96+
c_stack=True,
9697
function='<module>'):
9798
"""
9899
Check that the fault handler for fatal errors is enabled and check the
99100
traceback from the child process output.
100101
101102
Raise an error if the output doesn't match the expected format.
102103
"""
104+
address_expr = "0x[0-9a-f]+"
103105
if all_threads:
104106
if know_current_thread:
105-
header = 'Current thread 0x[0-9a-f]+'
107+
header = f'Current thread {address_expr}'
106108
else:
107-
header = 'Thread 0x[0-9a-f]+'
109+
header = f'Thread {address_expr}'
108110
else:
109111
header = 'Stack'
110112
regex = [f'^{fatal_error}']
@@ -115,6 +117,9 @@ def check_error(self, code, lineno, fatal_error, *,
115117
if garbage_collecting:
116118
regex.append(' Garbage-collecting')
117119
regex.append(fr' File "<string>", line {lineno} in {function}')
120+
if c_stack:
121+
regex.append("Current thread's C stack (most recent call first):")
122+
regex.append(r" (\/.+\(\+.+\) \[0x[0-9a-f]+\])|(<.+>)")
118123
regex = '\n'.join(regex)
119124

120125
if other_regex:

0 commit comments

Comments
 (0)
0