From efda837b76bfe4c64accab28be0c026b195b2a9c Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Sun, 10 Jul 2016 18:20:15 +0200 Subject: Issue #27027: Added test.support.is_android that is True when this is an Android build. --- Lib/test/support/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index ef6b4f505d..2b2966876f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -92,7 +92,7 @@ __all__ = [ "anticipate_failure", "load_package_tests", "detect_api_mismatch", "check__all__", # sys - "is_jython", "check_impl_detail", + "is_jython", "is_android", "check_impl_detail", # network "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", # processes @@ -734,6 +734,8 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') is_jython = sys.platform.startswith('java') +is_android = bool(sysconfig.get_config_var('ANDROID_API_LEVEL')) + # Filename used for testing if os.name == 'java': # Jython disallows @ in module names -- cgit v1.2.1 From 1968105b8f73b8e9efeee7a8735df76f6ad06b29 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Fri, 22 Jul 2016 12:15:29 +0200 Subject: Issue #27472: Add test.support.unix_shell as the path to the default shell. --- Lib/test/support/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 2b2966876f..aa6725feec 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -92,7 +92,7 @@ __all__ = [ "anticipate_failure", "load_package_tests", "detect_api_mismatch", "check__all__", # sys - "is_jython", "is_android", "check_impl_detail", + "is_jython", "is_android", "check_impl_detail", "unix_shell", # network "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", # processes @@ -736,6 +736,11 @@ is_jython = sys.platform.startswith('java') is_android = bool(sysconfig.get_config_var('ANDROID_API_LEVEL')) +if sys.platform != 'win32': + unix_shell = '/system/bin/sh' if is_android else '/bin/sh' +else: + unix_shell = None + # Filename used for testing if os.name == 'java': # Jython disallows @ in module names -- cgit v1.2.1 From bb0ec1fc07628252f17d66a58a4a4b3654e571c3 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Mon, 5 Sep 2016 15:11:23 -0700 Subject: Issue #27355: Removed support for Windows CE. It was never finished, and Windows CE is no longer a relevant platform for Python. --- Lib/test/support/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index d907b108c9..4a7cd40a0f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -811,7 +811,7 @@ TESTFN_ENCODING = sys.getfilesystemencoding() # encoded by the filesystem encoding (in strict mode). It can be None if we # cannot generate such filename. TESTFN_UNENCODABLE = None -if os.name in ('nt', 'ce'): +if os.name == 'nt': # skip win32s (0) or Windows 9x/ME (1) if sys.getwindowsversion().platform >= 2: # Different kinds of characters from various languages to minimize the -- cgit v1.2.1 From 0c5d31799ea0cc8ecf4968187f7c7e6fd3dd3d7f Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 6 Sep 2016 19:38:15 -0700 Subject: Adds test.support.PGO and skips tests that are not useful for PGO. --- Lib/test/support/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 4a7cd40a0f..3e2ab43ca4 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -105,7 +105,7 @@ __all__ = [ "check_warnings", "check_no_resource_warning", "EnvironmentVarGuard", "run_with_locale", "swap_item", "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", - "run_with_tz", + "run_with_tz", "PGO", ] class Error(Exception): @@ -878,6 +878,10 @@ else: # Save the initial cwd SAVEDCWD = os.getcwd() +# Set by libregrtest/main.py so we can skip tests that are not +# useful for PGO +PGO = False + @contextlib.contextmanager def temp_dir(path=None, quiet=False): """Return a context manager that creates a temporary directory. -- cgit v1.2.1 From 03c8a473999b08710ae3661724cf1bf1d76bc555 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Thu, 8 Sep 2016 13:59:53 -0400 Subject: #27364: fix "incorrect" uses of escape character in the stdlib. And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter. --- Lib/test/support/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 3e2ab43ca4..8b66f95ee4 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2202,7 +2202,7 @@ def can_xattr(): os.setxattr(fp.fileno(), b"user.test", b"") # Kernels < 2.6.39 don't respect setxattr flags. kernel_version = platform.release() - m = re.match("2.6.(\d{1,2})", kernel_version) + m = re.match(r"2.6.(\d{1,2})", kernel_version) can = m is None or int(m.group(1)) >= 39 except OSError: can = False -- cgit v1.2.1 From 4c8b8c6298651e1036595b54a80bc2a710073876 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Sun, 13 Nov 2016 20:46:46 +0100 Subject: Fix test_faulthandler on Android where raise() exits with 0 --- Lib/test/support/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 8b66f95ee4..961b735591 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -90,7 +90,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__", + "check__all__", "requires_android_level", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell", # network @@ -735,7 +735,8 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') 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 @@ 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. -- cgit v1.2.1 From 616fe478b7c19709d3262213bc594df4c0f0dd81 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Sun, 13 Nov 2016 21:55:52 +0100 Subject: Issue #26934: Handle _ANDROID_API_LEVEL is None on Windows --- Lib/test/support/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 961b735591..d862d8b457 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -736,7 +736,7 @@ requires_lzma = unittest.skipUnless(lzma, 'requires lzma') is_jython = sys.platform.startswith('java') _ANDROID_API_LEVEL = sysconfig.get_config_var('ANDROID_API_LEVEL') -is_android = (_ANDROID_API_LEVEL > 0) +is_android = (_ANDROID_API_LEVEL is not None and _ANDROID_API_LEVEL > 0) if sys.platform != 'win32': unix_shell = '/system/bin/sh' if is_android else '/bin/sh' -- cgit v1.2.1 From 0d7cbc0265f573f4f3aaad4c93cf2c5175c8ee0a Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Thu, 17 Nov 2016 09:00:19 +0100 Subject: Issue 26931: Skip the test_distutils tests using a compiler executable that is not found --- Lib/test/support/__init__.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 81136100f0..f10672383e 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -105,7 +105,7 @@ __all__ = [ "check_warnings", "check_no_resource_warning", "EnvironmentVarGuard", "run_with_locale", "swap_item", "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", - "run_with_tz", "PGO", + "run_with_tz", "PGO", "missing_compiler_executable", ] class Error(Exception): @@ -2491,3 +2491,28 @@ def check_free_after_iterating(test, iter, cls, args=()): # The sequence should be deallocated just after the end of iterating gc_collect() test.assertTrue(done) + + +def missing_compiler_executable(cmd_names=[]): + """Check if the compiler components used to build the interpreter exist. + + Check for the existence of the compiler executables whose names are listed + in 'cmd_names' or all the compiler executables when 'cmd_names' is empty + and return the first missing executable or None when none is found + missing. + + """ + from distutils import ccompiler, sysconfig, spawn + compiler = ccompiler.new_compiler() + sysconfig.customize_compiler(compiler) + for name in compiler.executables: + if cmd_names and name not in cmd_names: + continue + cmd = getattr(compiler, name) + if cmd_names: + assert cmd is not None, \ + "the '%s' executable is not configured" % name + elif cmd is None: + continue + if spawn.find_executable(cmd[0]) is None: + return cmd[0] -- cgit v1.2.1 From 7b0db7349755e9fdcded21a865e1f81655a7ae6d Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Thu, 8 Dec 2016 11:06:56 +0100 Subject: Issue #26939: Add the support.setswitchinterval() function to fix test_functools hanging on the Android armv7 qemu emulator. --- Lib/test/support/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 1e27777517..fa344ece23 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -93,6 +93,7 @@ __all__ = [ "check__all__", "requires_android_level", "requires_multiprocessing_queue", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell", + "setswitchinterval", # network "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", # processes @@ -2547,3 +2548,18 @@ def missing_compiler_executable(cmd_names=[]): continue if spawn.find_executable(cmd[0]) is None: return cmd[0] + + +_is_android_emulator = None +def setswitchinterval(interval): + # Setting a very low gil interval on the Android emulator causes python + # to hang (issue #26939). + minimum_interval = 1e-5 + if is_android and interval < minimum_interval: + global _is_android_emulator + if _is_android_emulator is None: + _is_android_emulator = (subprocess.check_output( + ['getprop', 'ro.kernel.qemu']).strip() == b'1') + if _is_android_emulator: + interval = minimum_interval + return sys.setswitchinterval(interval) -- cgit v1.2.1 From eab15ffef9e7b28b1274aa48f0175efb43547d84 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Tue, 13 Dec 2016 10:00:01 +0100 Subject: Issue #28759: Fix the tests that fail with PermissionError when run as a non-root user on Android where access rights are controled by SELinux MAC. --- Lib/test/support/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 1a38c4ab32..ed1af2b5a5 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -93,7 +93,7 @@ __all__ = [ "check__all__", "requires_android_level", "requires_multiprocessing_queue", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell", - "setswitchinterval", + "setswitchinterval", "android_not_root", # network "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", # processes @@ -769,6 +769,7 @@ is_jython = sys.platform.startswith('java') _ANDROID_API_LEVEL = sysconfig.get_config_var('ANDROID_API_LEVEL') is_android = (_ANDROID_API_LEVEL is not None and _ANDROID_API_LEVEL > 0) +android_not_root = (is_android and os.geteuid() != 0) if sys.platform != 'win32': unix_shell = '/system/bin/sh' if is_android else '/bin/sh' -- cgit v1.2.1 From bb2e2b4d5fbea49cdd0f9fe842272a4ae8626092 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Wed, 14 Dec 2016 11:52:28 +0100 Subject: Issue #28683: Fix the tests that bind() a unix socket and raise PermissionError on Android for a non-root user. --- Lib/test/support/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Lib/test/support/__init__.py') diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index ed1af2b5a5..15d8fc849b 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -96,6 +96,7 @@ __all__ = [ "setswitchinterval", "android_not_root", # network "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", + "bind_unix_socket", # processes 'temp_umask', "reap_children", # logging @@ -708,6 +709,15 @@ def bind_port(sock, host=HOST): port = sock.getsockname()[1] return port +def bind_unix_socket(sock, addr): + """Bind a unix socket, raising SkipTest if PermissionError is raised.""" + assert sock.family == socket.AF_UNIX + try: + sock.bind(addr) + except PermissionError: + sock.close() + raise unittest.SkipTest('cannot bind AF_UNIX sockets') + def _is_ipv6_enabled(): """Check whether IPv6 is enabled on this host.""" if socket.has_ipv6: -- cgit v1.2.1