summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxdegaye <xdegaye@gmail.com>2017-11-29 10:43:23 (GMT)
committerGitHub <noreply@github.com>2017-11-29 10:43:23 (GMT)
commitef83806f5ec01f34f6cbf4ebb5752875b5961f7e (patch)
treed67ee31ba17b35dcf70adf2aa4daf12a960d2caf
parentcc55e78acab93a495c974b9a2ea71c8bb9cc2f5d (diff)
downloadcpython-ef83806f5ec01f34f6cbf4ebb5752875b5961f7e.zip
cpython-ef83806f5ec01f34f6cbf4ebb5752875b5961f7e.tar.gz
cpython-ef83806f5ec01f34f6cbf4ebb5752875b5961f7e.tar.bz2
bpo-32138: Skip on Android test_faulthandler tests that raise SIGSEGV (GH-4604)
Remove the test.support.requires_android_level decorator.
-rw-r--r--Lib/test/support/__init__.py17
-rw-r--r--Lib/test/test_faulthandler.py27
-rw-r--r--Misc/NEWS.d/next/Tests/2017-11-27-16-18-58.bpo-32138.QsTvf-.rst2
3 files changed, 18 insertions, 28 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index e864896..42c41ff 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -87,7 +87,7 @@ __all__ = [
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
"requires_IEEE_754", "skip_unless_xattr", "requires_zlib",
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
- "check__all__", "requires_android_level", "requires_multiprocessing_queue",
+ "check__all__", "requires_multiprocessing_queue",
"skip_unless_bind_unix_socket",
# sys
"is_jython", "is_android", "check_impl_detail", "unix_shell",
@@ -773,13 +773,7 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma')
is_jython = sys.platform.startswith('java')
-try:
- # constant used by requires_android_level()
- _ANDROID_API_LEVEL = sys.getandroidapilevel()
- is_android = True
-except AttributeError:
- # sys.getandroidapilevel() is only available on Android
- is_android = False
+is_android = hasattr(sys, 'getandroidapilevel')
if sys.platform != 'win32':
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
@@ -1778,13 +1772,6 @@ def requires_resource(resource):
else:
return unittest.skip("resource {0!r} is not enabled".format(resource))
-def requires_android_level(level, reason):
- if is_android and _ANDROID_API_LEVEL < level:
- return unittest.skip('%s at Android API level %d' %
- (reason, _ANDROID_API_LEVEL))
- else:
- return _id
-
def cpython_only(test):
"""
Decorator for tests only applicable on CPython.
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index e0e53c2..3647bfc 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -6,7 +6,7 @@ import signal
import subprocess
import sys
from test import support
-from test.support import script_helper, is_android, requires_android_level
+from test.support import script_helper, is_android
import tempfile
import threading
import unittest
@@ -29,6 +29,11 @@ def expected_traceback(lineno1, lineno2, header, min_count=1):
else:
return '^' + regex + '$'
+def skip_segfault_on_android(test):
+ # Issue #32138: Raising SIGSEGV on Android may not cause a crash.
+ return unittest.skipIf(is_android,
+ 'raising SIGSEGV on Android is unreliable')(test)
+
@contextmanager
def temporary_filename():
filename = tempfile.mktemp()
@@ -37,10 +42,6 @@ def temporary_filename():
finally:
support.unlink(filename)
-def requires_raise(test):
- return (test if not is_android else
- requires_android_level(24, 'raise() is buggy')(test))
-
class FaultHandlerTests(unittest.TestCase):
def get_output(self, code, filename=None, fd=None):
"""
@@ -140,7 +141,7 @@ class FaultHandlerTests(unittest.TestCase):
3,
'access violation')
- @requires_raise
+ @skip_segfault_on_android
def test_sigsegv(self):
self.check_fatal_error("""
import faulthandler
@@ -182,7 +183,7 @@ class FaultHandlerTests(unittest.TestCase):
@unittest.skipIf(_testcapi is None, 'need _testcapi')
@unittest.skipUnless(hasattr(signal, 'SIGBUS'), 'need signal.SIGBUS')
- @requires_raise
+ @skip_segfault_on_android
def test_sigbus(self):
self.check_fatal_error("""
import _testcapi
@@ -197,7 +198,7 @@ class FaultHandlerTests(unittest.TestCase):
@unittest.skipIf(_testcapi is None, 'need _testcapi')
@unittest.skipUnless(hasattr(signal, 'SIGILL'), 'need signal.SIGILL')
- @requires_raise
+ @skip_segfault_on_android
def test_sigill(self):
self.check_fatal_error("""
import _testcapi
@@ -241,7 +242,7 @@ class FaultHandlerTests(unittest.TestCase):
'(?:Segmentation fault|Bus error)',
other_regex='unable to raise a stack overflow')
- @requires_raise
+ @skip_segfault_on_android
def test_gil_released(self):
self.check_fatal_error("""
import faulthandler
@@ -251,7 +252,7 @@ class FaultHandlerTests(unittest.TestCase):
3,
'Segmentation fault')
- @requires_raise
+ @skip_segfault_on_android
def test_enable_file(self):
with temporary_filename() as filename:
self.check_fatal_error("""
@@ -266,7 +267,7 @@ class FaultHandlerTests(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32",
"subprocess doesn't support pass_fds on Windows")
- @requires_raise
+ @skip_segfault_on_android
def test_enable_fd(self):
with tempfile.TemporaryFile('wb+') as fp:
fd = fp.fileno()
@@ -280,7 +281,7 @@ class FaultHandlerTests(unittest.TestCase):
'Segmentation fault',
fd=fd)
- @requires_raise
+ @skip_segfault_on_android
def test_enable_single_thread(self):
self.check_fatal_error("""
import faulthandler
@@ -291,7 +292,7 @@ class FaultHandlerTests(unittest.TestCase):
'Segmentation fault',
all_threads=False)
- @requires_raise
+ @skip_segfault_on_android
def test_disable(self):
code = """
import faulthandler
diff --git a/Misc/NEWS.d/next/Tests/2017-11-27-16-18-58.bpo-32138.QsTvf-.rst b/Misc/NEWS.d/next/Tests/2017-11-27-16-18-58.bpo-32138.QsTvf-.rst
new file mode 100644
index 0000000..2430aa7
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2017-11-27-16-18-58.bpo-32138.QsTvf-.rst
@@ -0,0 +1,2 @@
+Skip on Android test_faulthandler tests that raise SIGSEGV and remove the
+test.support.requires_android_level decorator.