diff -r 805467de22fc Lib/test/support/__init__.py --- a/Lib/test/support/__init__.py Sun Nov 06 13:19:38 2016 +0200 +++ b/Lib/test/support/__init__.py Mon Nov 07 09:30:14 2016 +0100 @@ -90,7 +90,7 @@ "bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute", "requires_IEEE_754", "skip_unless_xattr", "requires_zlib", "anticipate_failure", "load_package_tests", "detect_api_mismatch", - "check__all__", + "check__all__", "requires_android_level", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell", # network @@ -735,7 +735,8 @@ is_jython = sys.platform.startswith('java') -is_android = bool(sysconfig.get_config_var('ANDROID_API_LEVEL')) +_android_api_level = sysconfig.get_config_var('ANDROID_API_LEVEL') +is_android = (_android_api_level > 0) if sys.platform != 'win32': unix_shell = '/system/bin/sh' if is_android else '/bin/sh' @@ -1725,6 +1726,13 @@ 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 -r 805467de22fc Lib/test/test_faulthandler.py --- a/Lib/test/test_faulthandler.py Sun Nov 06 13:19:38 2016 +0200 +++ b/Lib/test/test_faulthandler.py Mon Nov 07 09:30:14 2016 +0100 @@ -7,7 +7,7 @@ import subprocess import sys from test import support -from test.support import script_helper +from test.support import script_helper, requires_android_level import tempfile import unittest from textwrap import dedent @@ -141,6 +141,7 @@ 3, 'access violation') + @requires_android_level(24, "raise() is buggy") def test_sigsegv(self): self.check_fatal_error(""" import faulthandler @@ -183,6 +184,7 @@ @unittest.skipIf(_testcapi is None, 'need _testcapi') @unittest.skipUnless(hasattr(signal, 'SIGBUS'), 'need signal.SIGBUS') + @requires_android_level(24, "raise() is buggy") def test_sigbus(self): self.check_fatal_error(""" import _testcapi @@ -197,6 +199,7 @@ @unittest.skipIf(_testcapi is None, 'need _testcapi') @unittest.skipUnless(hasattr(signal, 'SIGILL'), 'need signal.SIGILL') + @requires_android_level(24, "raise() is buggy") def test_sigill(self): self.check_fatal_error(""" import _testcapi @@ -240,6 +243,7 @@ '(?:Segmentation fault|Bus error)', other_regex='unable to raise a stack overflow') + @requires_android_level(24, "raise() is buggy") def test_gil_released(self): self.check_fatal_error(""" import faulthandler @@ -255,10 +259,12 @@ import faulthandler output = open({filename}, 'wb') faulthandler.enable(output) - faulthandler._sigsegv() + faulthandler._read_null() """.format(filename=repr(filename)), 4, - 'Segmentation fault', + '(?:Segmentation fault' + '|Bus error' + '|Illegal instruction)', filename=filename) @unittest.skipIf(sys.platform == "win32", @@ -270,20 +276,24 @@ import faulthandler import sys faulthandler.enable(%s) - faulthandler._sigsegv() + faulthandler._read_null() """ % fd, 4, - 'Segmentation fault', + '(?:Segmentation fault' + '|Bus error' + '|Illegal instruction)', fd=fd) def test_enable_single_thread(self): self.check_fatal_error(""" import faulthandler faulthandler.enable(all_threads=False) - faulthandler._sigsegv() + faulthandler._read_null() """, 3, - 'Segmentation fault', + '(?:Segmentation fault' + '|Bus error' + '|Illegal instruction)', all_threads=False) def test_disable(self): @@ -291,7 +301,7 @@ import faulthandler faulthandler.enable() faulthandler.disable() - faulthandler._sigsegv() + faulthandler._read_null() """ not_expected = 'Fatal Python error' stderr, exitcode = self.get_output(code)