Skip to content

Commit ef83806

Browse files
authored
bpo-32138: Skip on Android test_faulthandler tests that raise SIGSEGV (GH-4604)
Remove the test.support.requires_android_level decorator.
1 parent cc55e78 commit ef83806

3 files changed

Lines changed: 18 additions & 28 deletions

File tree

Lib/test/support/__init__.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
8888
"requires_IEEE_754", "skip_unless_xattr", "requires_zlib",
8989
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
90-
"check__all__", "requires_android_level", "requires_multiprocessing_queue",
90+
"check__all__", "requires_multiprocessing_queue",
9191
"skip_unless_bind_unix_socket",
9292
# sys
9393
"is_jython", "is_android", "check_impl_detail", "unix_shell",
@@ -773,13 +773,7 @@ def dec(*args, **kwargs):
773773

774774
is_jython = sys.platform.startswith('java')
775775

776-
try:
777-
# constant used by requires_android_level()
778-
_ANDROID_API_LEVEL = sys.getandroidapilevel()
779-
is_android = True
780-
except AttributeError:
781-
# sys.getandroidapilevel() is only available on Android
782-
is_android = False
776+
is_android = hasattr(sys, 'getandroidapilevel')
783777

784778
if sys.platform != 'win32':
785779
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
@@ -1778,13 +1772,6 @@ def requires_resource(resource):
17781772
else:
17791773
return unittest.skip("resource {0!r} is not enabled".format(resource))
17801774

1781-
def requires_android_level(level, reason):
1782-
if is_android and _ANDROID_API_LEVEL < level:
1783-
return unittest.skip('%s at Android API level %d' %
1784-
(reason, _ANDROID_API_LEVEL))
1785-
else:
1786-
return _id
1787-
17881775
def cpython_only(test):
17891776
"""
17901777
Decorator for tests only applicable on CPython.

Lib/test/test_faulthandler.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import sys
88
from test import support
9-
from test.support import script_helper, is_android, requires_android_level
9+
from test.support import script_helper, is_android
1010
import tempfile
1111
import threading
1212
import unittest
@@ -29,6 +29,11 @@ def expected_traceback(lineno1, lineno2, header, min_count=1):
2929
else:
3030
return '^' + regex + '$'
3131

32+
def skip_segfault_on_android(test):
33+
# Issue #32138: Raising SIGSEGV on Android may not cause a crash.
34+
return unittest.skipIf(is_android,
35+
'raising SIGSEGV on Android is unreliable')(test)
36+
3237
@contextmanager
3338
def temporary_filename():
3439
filename = tempfile.mktemp()
@@ -37,10 +42,6 @@ def temporary_filename():
3742
finally:
3843
support.unlink(filename)
3944

40-
def requires_raise(test):
41-
return (test if not is_android else
42-
requires_android_level(24, 'raise() is buggy')(test))
43-
4445
class FaultHandlerTests(unittest.TestCase):
4546
def get_output(self, code, filename=None, fd=None):
4647
"""
@@ -140,7 +141,7 @@ def test_read_null(self):
140141
3,
141142
'access violation')
142143

143-
@requires_raise
144+
@skip_segfault_on_android
144145
def test_sigsegv(self):
145146
self.check_fatal_error("""
146147
import faulthandler
@@ -182,7 +183,7 @@ def test_sigfpe(self):
182183

183184
@unittest.skipIf(_testcapi is None, 'need _testcapi')
184185
@unittest.skipUnless(hasattr(signal, 'SIGBUS'), 'need signal.SIGBUS')
185-
@requires_raise
186+
@skip_segfault_on_android
186187
def test_sigbus(self):
187188
self.check_fatal_error("""
188189
import _testcapi
@@ -197,7 +198,7 @@ def test_sigbus(self):
197198

198199
@unittest.skipIf(_testcapi is None, 'need _testcapi')
199200
@unittest.skipUnless(hasattr(signal, 'SIGILL'), 'need signal.SIGILL')
200-
@requires_raise
201+
@skip_segfault_on_android
201202
def test_sigill(self):
202203
self.check_fatal_error("""
203204
import _testcapi
@@ -241,7 +242,7 @@ def test_stack_overflow(self):
241242
'(?:Segmentation fault|Bus error)',
242243
other_regex='unable to raise a stack overflow')
243244

244-
@requires_raise
245+
@skip_segfault_on_android
245246
def test_gil_released(self):
246247
self.check_fatal_error("""
247248
import faulthandler
@@ -251,7 +252,7 @@ def test_gil_released(self):
251252
3,
252253
'Segmentation fault')
253254

254-
@requires_raise
255+
@skip_segfault_on_android
255256
def test_enable_file(self):
256257
with temporary_filename() as filename:
257258
self.check_fatal_error("""
@@ -266,7 +267,7 @@ def test_enable_file(self):
266267

267268
@unittest.skipIf(sys.platform == "win32",
268269
"subprocess doesn't support pass_fds on Windows")
269-
@requires_raise
270+
@skip_segfault_on_android
270271
def test_enable_fd(self):
271272
with tempfile.TemporaryFile('wb+') as fp:
272273
fd = fp.fileno()
@@ -280,7 +281,7 @@ def test_enable_fd(self):
280281
'Segmentation fault',
281282
fd=fd)
282283

283-
@requires_raise
284+
@skip_segfault_on_android
284285
def test_enable_single_thread(self):
285286
self.check_fatal_error("""
286287
import faulthandler
@@ -291,7 +292,7 @@ def test_enable_single_thread(self):
291292
'Segmentation fault',
292293
all_threads=False)
293294

294-
@requires_raise
295+
@skip_segfault_on_android
295296
def test_disable(self):
296297
code = """
297298
import faulthandler
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Skip on Android test_faulthandler tests that raise SIGSEGV and remove the
2+
test.support.requires_android_level decorator.

0 commit comments

Comments
 (0)