Skip to content

Commit 1d3225a

Browse files
authored
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
1 parent 6150bb2 commit 1d3225a

File tree

8 files changed

+21
-14
lines changed

8 files changed

+21
-14
lines changed

Lib/test/_test_multiprocessing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4662,7 +4662,7 @@ def make_finalizers():
46624662
old_interval = sys.getswitchinterval()
46634663
old_threshold = gc.get_threshold()
46644664
try:
4665-
sys.setswitchinterval(1e-6)
4665+
support.setswitchinterval(1e-6)
46664666
gc.set_threshold(5, 5, 5)
46674667
threads = [threading.Thread(target=run_finalizers),
46684668
threading.Thread(target=make_finalizers)]

Lib/test/test_concurrent_futures/test_wait.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_pending_calls_race(self):
142142
def future_func():
143143
event.wait()
144144
oldswitchinterval = sys.getswitchinterval()
145-
sys.setswitchinterval(1e-6)
145+
support.setswitchinterval(1e-6)
146146
try:
147147
fs = {self.executor.submit(future_func) for i in range(100)}
148148
event.set()

Lib/test/test_fcntl.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def test_fcntl_bad_file_overflow(self):
131131
fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK)
132132

133133
@unittest.skipIf(
134-
platform.machine().startswith(("arm", "aarch"))
135-
and platform.system() in ("Linux", "Android"),
136-
"ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT")
134+
(platform.machine().startswith("arm") and platform.system() == "Linux")
135+
or platform.system() == "Android",
136+
"this platform returns EINVAL for F_NOTIFY DN_MULTISHOT")
137137
def test_fcntl_64_bit(self):
138138
# Issue #1309352: fcntl shouldn't fail when the third arg fits in a
139139
# C 'long' but not in a C 'int'.

Lib/test/test_gc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
22
import unittest.mock
3+
from test import support
34
from test.support import (verbose, refcount_test,
45
cpython_only, requires_subprocess,
56
requires_gil_enabled)
@@ -470,7 +471,7 @@ def run_thread():
470471
make_nested()
471472

472473
old_switchinterval = sys.getswitchinterval()
473-
sys.setswitchinterval(1e-5)
474+
support.setswitchinterval(1e-5)
474475
try:
475476
exit = []
476477
threads = []

Lib/test/test_importlib/test_threaded_import.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import shutil
1414
import threading
1515
import unittest
16+
from test import support
1617
from test.support import verbose
1718
from test.support.import_helper import forget, mock_register_at_fork
1819
from test.support.os_helper import (TESTFN, unlink, rmtree)
@@ -260,7 +261,7 @@ def setUpModule():
260261
try:
261262
old_switchinterval = sys.getswitchinterval()
262263
unittest.addModuleCleanup(sys.setswitchinterval, old_switchinterval)
263-
sys.setswitchinterval(1e-5)
264+
support.setswitchinterval(1e-5)
264265
except AttributeError:
265266
pass
266267

Lib/test/test_math.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2691,12 +2691,12 @@ def test_fma_infinities(self):
26912691
self.assertEqual(math.fma(-b, -math.inf, c), math.inf)
26922692
self.assertEqual(math.fma(-b, math.inf, c), -math.inf)
26932693

2694-
# gh-73468: On WASI and FreeBSD, libc fma() doesn't implement IEE 754-2008
2694+
# gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008
26952695
# properly: it doesn't use the right sign when the result is zero.
2696-
@unittest.skipIf(support.is_wasi,
2697-
"WASI fma() doesn't implement IEE 754-2008 properly")
2698-
@unittest.skipIf(sys.platform.startswith('freebsd'),
2699-
"FreeBSD fma() doesn't implement IEE 754-2008 properly")
2696+
@unittest.skipIf(
2697+
sys.platform.startswith(("freebsd", "wasi"))
2698+
or (sys.platform == "android" and platform.machine() == "x86_64"),
2699+
f"this platform doesn't implement IEE 754-2008 properly")
27002700
def test_fma_zero_result(self):
27012701
nonnegative_finites = [0.0, 1e-300, 2.3, 1e300]
27022702

Lib/test/test_os.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3934,7 +3934,12 @@ def test_does_not_crash(self):
39343934
try:
39353935
size = os.get_terminal_size()
39363936
except OSError as e:
3937-
if sys.platform == "win32" or e.errno in (errno.EINVAL, errno.ENOTTY):
3937+
known_errnos = [errno.EINVAL, errno.ENOTTY]
3938+
if sys.platform == "android":
3939+
# The Android testbed redirects the native stdout to a pipe,
3940+
# which returns a different error code.
3941+
known_errnos.append(errno.EACCES)
3942+
if sys.platform == "win32" or e.errno in known_errnos:
39383943
# Under win32 a generic OSError can be thrown if the
39393944
# handle cannot be retrieved
39403945
self.skipTest("failed to query terminal size")

Lib/test/test_threading.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def test_enumerate_after_join(self):
515515
old_interval = sys.getswitchinterval()
516516
try:
517517
for i in range(1, 100):
518-
sys.setswitchinterval(i * 0.0002)
518+
support.setswitchinterval(i * 0.0002)
519519
t = threading.Thread(target=lambda: None)
520520
t.start()
521521
t.join()

0 commit comments

Comments
 (0)