Skip to content

Commit 30e0232

Browse files
authored
Cleanup test_faulthandler sanitizer skip logic. (GH-11381)
Also skip the same tests when using the undefined behavior sanitizer as they much with the output. Updates a regex in another test to use multi-line mode so that the ubsan buildbot should pass again rather than also adding a skip to that one.
1 parent c7e2191 commit 30e0232

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Lib/test/test_faulthandler.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@
2020

2121
TIMEOUT = 0.5
2222
MS_WINDOWS = (os.name == 'nt')
23+
_cflags = sysconfig.get_config_var('CFLAGS') or ''
24+
_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
25+
UB_SANITIZER = (
26+
'-fsanitizer=undefined' in _cflags or
27+
'--with-undefined-behavior-sanitizer' in _config_args
28+
)
2329
MEMORY_SANITIZER = (
24-
sysconfig.get_config_var("CONFIG_ARGS") and
25-
("--with-memory-sanitizer" in sysconfig.get_config_var("CONFIG_ARGS"))
30+
'-fsanitizer=memory' in _cflags or
31+
'--with-memory-sanitizer' in _config_args
2632
)
2733

34+
2835
def expected_traceback(lineno1, lineno2, header, min_count=1):
2936
regex = header
3037
regex += ' File "<string>", line %s in func\n' % lineno1
@@ -99,7 +106,7 @@ def check_error(self, code, line_number, fatal_error, *,
99106
else:
100107
header = 'Stack'
101108
regex = r"""
102-
^{fatal_error}
109+
(?m)^{fatal_error}
103110
104111
{header} \(most recent call first\):
105112
File "<string>", line {lineno} in <module>
@@ -257,8 +264,8 @@ def test_gil_released(self):
257264
3,
258265
'Segmentation fault')
259266

260-
@unittest.skipIf(MEMORY_SANITIZER,
261-
"memory-sanizer builds change crashing process output.")
267+
@unittest.skipIf(UB_SANITIZER or MEMORY_SANITIZER,
268+
"sanizer builds change crashing process output.")
262269
@skip_segfault_on_android
263270
def test_enable_file(self):
264271
with temporary_filename() as filename:
@@ -274,8 +281,8 @@ def test_enable_file(self):
274281

275282
@unittest.skipIf(sys.platform == "win32",
276283
"subprocess doesn't support pass_fds on Windows")
277-
@unittest.skipIf(MEMORY_SANITIZER,
278-
"memory-sanizer builds change crashing process output.")
284+
@unittest.skipIf(UB_SANITIZER or MEMORY_SANITIZER,
285+
"sanizer builds change crashing process output.")
279286
@skip_segfault_on_android
280287
def test_enable_fd(self):
281288
with tempfile.TemporaryFile('wb+') as fp:

0 commit comments

Comments
 (0)