From 6c625e609edaf2df1bf6b2f3f466410b4b41cbc1 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Wed, 20 Mar 2024 18:00:10 +0000 Subject: [PATCH 1/5] Re-enable test_fcntl_64_bit on Linux aarch64, but disable it on all Android ABIs --- Lib/test/test_fcntl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 5fae0de7423c87..4dc81149ccc0e3 100644 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -129,9 +129,9 @@ def test_fcntl_bad_file_overflow(self): fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK) @unittest.skipIf( - platform.machine().startswith(("arm", "aarch")) - and platform.system() in ("Linux", "Android"), - "ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT") + (platform.machine().startswith("arm") and platform.system() == "Linux") + or platform.system() == "Android", + "this platform returns EINVAL for F_NOTIFY DN_MULTISHOT") def test_fcntl_64_bit(self): # Issue #1309352: fcntl shouldn't fail when the third arg fits in a # C 'long' but not in a C 'int'. From c8914cfa5a72f9483e4aa71cc2c1380ba030c18c Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Wed, 20 Mar 2024 22:04:05 +0000 Subject: [PATCH 2/5] Use support.setswitchinterval in all relevant tests --- Lib/test/_test_multiprocessing.py | 2 +- Lib/test/test_concurrent_futures/test_wait.py | 2 +- Lib/test/test_gc.py | 3 ++- Lib/test/test_importlib/test_threaded_import.py | 3 ++- Lib/test/test_threading.py | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index b63b567bbcad08..a74b61013c4848 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -4662,7 +4662,7 @@ def make_finalizers(): old_interval = sys.getswitchinterval() old_threshold = gc.get_threshold() try: - sys.setswitchinterval(1e-6) + support.setswitchinterval(1e-6) gc.set_threshold(5, 5, 5) threads = [threading.Thread(target=run_finalizers), threading.Thread(target=make_finalizers)] diff --git a/Lib/test/test_concurrent_futures/test_wait.py b/Lib/test/test_concurrent_futures/test_wait.py index ff486202092c81..108cf54bf79e6f 100644 --- a/Lib/test/test_concurrent_futures/test_wait.py +++ b/Lib/test/test_concurrent_futures/test_wait.py @@ -142,7 +142,7 @@ def test_pending_calls_race(self): def future_func(): event.wait() oldswitchinterval = sys.getswitchinterval() - sys.setswitchinterval(1e-6) + support.setswitchinterval(1e-6) try: fs = {self.executor.submit(future_func) for i in range(100)} event.set() diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 3bf5c9ed41ee44..d73cdd1e3ecbdc 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -1,5 +1,6 @@ import unittest import unittest.mock +from test import support from test.support import (verbose, refcount_test, cpython_only, requires_subprocess, Py_GIL_DISABLED) from test.support.import_helper import import_module @@ -470,7 +471,7 @@ def run_thread(): make_nested() old_switchinterval = sys.getswitchinterval() - sys.setswitchinterval(1e-5) + support.setswitchinterval(1e-5) try: exit = [] threads = [] diff --git a/Lib/test/test_importlib/test_threaded_import.py b/Lib/test/test_importlib/test_threaded_import.py index 5072be86cfd112..9af1e4d505c66e 100644 --- a/Lib/test/test_importlib/test_threaded_import.py +++ b/Lib/test/test_importlib/test_threaded_import.py @@ -13,6 +13,7 @@ import shutil import threading import unittest +from test import support from test.support import verbose from test.support.import_helper import forget, mock_register_at_fork from test.support.os_helper import (TESTFN, unlink, rmtree) @@ -260,7 +261,7 @@ def setUpModule(): try: old_switchinterval = sys.getswitchinterval() unittest.addModuleCleanup(sys.setswitchinterval, old_switchinterval) - sys.setswitchinterval(1e-5) + support.setswitchinterval(1e-5) except AttributeError: pass diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 4414d2bb9cdb59..a5a39055018a61 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -515,7 +515,7 @@ def test_enumerate_after_join(self): old_interval = sys.getswitchinterval() try: for i in range(1, 100): - sys.setswitchinterval(i * 0.0002) + support.setswitchinterval(i * 0.0002) t = threading.Thread(target=lambda: None) t.start() t.join() From 384f7e18f64f401a84e1cad06510700b1d323d58 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Mon, 25 Mar 2024 13:41:32 +0000 Subject: [PATCH 3/5] Skip test_fma_zero_result on Android x86_64 --- Lib/test/test_math.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index aaa3b16d33fb7d..0e4dbc0b64a439 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -2691,12 +2691,12 @@ def test_fma_infinities(self): self.assertEqual(math.fma(-b, -math.inf, c), math.inf) self.assertEqual(math.fma(-b, math.inf, c), -math.inf) - # gh-73468: On WASI and FreeBSD, libc fma() doesn't implement IEE 754-2008 + # gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008 # properly: it doesn't use the right sign when the result is zero. - @unittest.skipIf(support.is_wasi, - "WASI fma() doesn't implement IEE 754-2008 properly") - @unittest.skipIf(sys.platform.startswith('freebsd'), - "FreeBSD fma() doesn't implement IEE 754-2008 properly") + @unittest.skipIf( + sys.platform.startswith(("freebsd", "wasi")) + or (sys.platform == "android" and platform.machine() == "x86_64"), + f"this platform doesn't implement IEE 754-2008 properly") def test_fma_zero_result(self): nonnegative_finites = [0.0, 1e-300, 2.3, 1e300] From 236e9d03d6f8b35d42c4672ae384f0db22c43d2e Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Mon, 25 Mar 2024 17:43:20 +0000 Subject: [PATCH 4/5] Accept EACCES when calling os.get_terminal_size on Android --- Lib/test/test_os.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 4bf158247fa2ec..ee55d7e5ab4826 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -3931,7 +3931,12 @@ def test_does_not_crash(self): try: size = os.get_terminal_size() except OSError as e: - if sys.platform == "win32" or e.errno in (errno.EINVAL, errno.ENOTTY): + known_errnos = [errno.EINVAL, errno.ENOTTY] + if sys.platform == "android": + # The Android testbed redirects the native stdout to a pipe, + # which returns a different error code. + known_errnos.append(errno.EACCES) + if (sys.platform == "win32") or (e.errno in known_errnos): # Under win32 a generic OSError can be thrown if the # handle cannot be retrieved self.skipTest("failed to query terminal size") From 69ac1f691bd3f96c2788ada891c942ba54271302 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Fri, 5 Apr 2024 21:27:50 +0100 Subject: [PATCH 5/5] Remove unnecessary parentheses --- Lib/test/test_os.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index ee55d7e5ab4826..64cae0c83ef808 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -3936,7 +3936,7 @@ def test_does_not_crash(self): # The Android testbed redirects the native stdout to a pipe, # which returns a different error code. known_errnos.append(errno.EACCES) - if (sys.platform == "win32") or (e.errno in known_errnos): + if sys.platform == "win32" or e.errno in known_errnos: # Under win32 a generic OSError can be thrown if the # handle cannot be retrieved self.skipTest("failed to query terminal size")