mirror of
https://github.com/python/cpython.git
synced 2024-11-24 17:47:13 +01:00
gh-116622: Test updates for Android (#117299)
- re-enable test_fcntl_64_bit on Linux aarch64, but disable it on all Android ABIs - use support.setswitchinterval in all relevant tests - skip test_fma_zero_result on Android x86_64 - accept EACCES when calling os.get_terminal_size on Android
This commit is contained in:
parent
6150bb2412
commit
1d3225ae05
@ -4662,7 +4662,7 @@ class _TestFinalize(BaseTestCase):
|
|||||||
old_interval = sys.getswitchinterval()
|
old_interval = sys.getswitchinterval()
|
||||||
old_threshold = gc.get_threshold()
|
old_threshold = gc.get_threshold()
|
||||||
try:
|
try:
|
||||||
sys.setswitchinterval(1e-6)
|
support.setswitchinterval(1e-6)
|
||||||
gc.set_threshold(5, 5, 5)
|
gc.set_threshold(5, 5, 5)
|
||||||
threads = [threading.Thread(target=run_finalizers),
|
threads = [threading.Thread(target=run_finalizers),
|
||||||
threading.Thread(target=make_finalizers)]
|
threading.Thread(target=make_finalizers)]
|
||||||
|
@ -142,7 +142,7 @@ class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests, BaseTestCase):
|
|||||||
def future_func():
|
def future_func():
|
||||||
event.wait()
|
event.wait()
|
||||||
oldswitchinterval = sys.getswitchinterval()
|
oldswitchinterval = sys.getswitchinterval()
|
||||||
sys.setswitchinterval(1e-6)
|
support.setswitchinterval(1e-6)
|
||||||
try:
|
try:
|
||||||
fs = {self.executor.submit(future_func) for i in range(100)}
|
fs = {self.executor.submit(future_func) for i in range(100)}
|
||||||
event.set()
|
event.set()
|
||||||
|
@ -131,9 +131,9 @@ class TestFcntl(unittest.TestCase):
|
|||||||
fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK)
|
fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK)
|
||||||
|
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
platform.machine().startswith(("arm", "aarch"))
|
(platform.machine().startswith("arm") and platform.system() == "Linux")
|
||||||
and platform.system() in ("Linux", "Android"),
|
or platform.system() == "Android",
|
||||||
"ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT")
|
"this platform returns EINVAL for F_NOTIFY DN_MULTISHOT")
|
||||||
def test_fcntl_64_bit(self):
|
def test_fcntl_64_bit(self):
|
||||||
# Issue #1309352: fcntl shouldn't fail when the third arg fits in a
|
# Issue #1309352: fcntl shouldn't fail when the third arg fits in a
|
||||||
# C 'long' but not in a C 'int'.
|
# C 'long' but not in a C 'int'.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import unittest.mock
|
import unittest.mock
|
||||||
|
from test import support
|
||||||
from test.support import (verbose, refcount_test,
|
from test.support import (verbose, refcount_test,
|
||||||
cpython_only, requires_subprocess,
|
cpython_only, requires_subprocess,
|
||||||
requires_gil_enabled)
|
requires_gil_enabled)
|
||||||
@ -470,7 +471,7 @@ class GCTests(unittest.TestCase):
|
|||||||
make_nested()
|
make_nested()
|
||||||
|
|
||||||
old_switchinterval = sys.getswitchinterval()
|
old_switchinterval = sys.getswitchinterval()
|
||||||
sys.setswitchinterval(1e-5)
|
support.setswitchinterval(1e-5)
|
||||||
try:
|
try:
|
||||||
exit = []
|
exit = []
|
||||||
threads = []
|
threads = []
|
||||||
|
@ -13,6 +13,7 @@ import time
|
|||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import unittest
|
import unittest
|
||||||
|
from test import support
|
||||||
from test.support import verbose
|
from test.support import verbose
|
||||||
from test.support.import_helper import forget, mock_register_at_fork
|
from test.support.import_helper import forget, mock_register_at_fork
|
||||||
from test.support.os_helper import (TESTFN, unlink, rmtree)
|
from test.support.os_helper import (TESTFN, unlink, rmtree)
|
||||||
@ -260,7 +261,7 @@ def setUpModule():
|
|||||||
try:
|
try:
|
||||||
old_switchinterval = sys.getswitchinterval()
|
old_switchinterval = sys.getswitchinterval()
|
||||||
unittest.addModuleCleanup(sys.setswitchinterval, old_switchinterval)
|
unittest.addModuleCleanup(sys.setswitchinterval, old_switchinterval)
|
||||||
sys.setswitchinterval(1e-5)
|
support.setswitchinterval(1e-5)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -2691,12 +2691,12 @@ class FMATests(unittest.TestCase):
|
|||||||
self.assertEqual(math.fma(-b, -math.inf, c), math.inf)
|
self.assertEqual(math.fma(-b, -math.inf, c), math.inf)
|
||||||
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.
|
# properly: it doesn't use the right sign when the result is zero.
|
||||||
@unittest.skipIf(support.is_wasi,
|
@unittest.skipIf(
|
||||||
"WASI fma() doesn't implement IEE 754-2008 properly")
|
sys.platform.startswith(("freebsd", "wasi"))
|
||||||
@unittest.skipIf(sys.platform.startswith('freebsd'),
|
or (sys.platform == "android" and platform.machine() == "x86_64"),
|
||||||
"FreeBSD fma() doesn't implement IEE 754-2008 properly")
|
f"this platform doesn't implement IEE 754-2008 properly")
|
||||||
def test_fma_zero_result(self):
|
def test_fma_zero_result(self):
|
||||||
nonnegative_finites = [0.0, 1e-300, 2.3, 1e300]
|
nonnegative_finites = [0.0, 1e-300, 2.3, 1e300]
|
||||||
|
|
||||||
|
@ -3934,7 +3934,12 @@ class TermsizeTests(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
size = os.get_terminal_size()
|
size = os.get_terminal_size()
|
||||||
except OSError as e:
|
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
|
# Under win32 a generic OSError can be thrown if the
|
||||||
# handle cannot be retrieved
|
# handle cannot be retrieved
|
||||||
self.skipTest("failed to query terminal size")
|
self.skipTest("failed to query terminal size")
|
||||||
|
@ -515,7 +515,7 @@ class ThreadTests(BaseTestCase):
|
|||||||
old_interval = sys.getswitchinterval()
|
old_interval = sys.getswitchinterval()
|
||||||
try:
|
try:
|
||||||
for i in range(1, 100):
|
for i in range(1, 100):
|
||||||
sys.setswitchinterval(i * 0.0002)
|
support.setswitchinterval(i * 0.0002)
|
||||||
t = threading.Thread(target=lambda: None)
|
t = threading.Thread(target=lambda: None)
|
||||||
t.start()
|
t.start()
|
||||||
t.join()
|
t.join()
|
||||||
|
Loading…
Reference in New Issue
Block a user