]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40280: Skip more tests/features that don't apply to Emscripten (GH-31791)
authorChristian Heimes <christian@python.org>
Thu, 10 Mar 2022 12:43:40 +0000 (14:43 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Mar 2022 12:43:40 +0000 (13:43 +0100)
- fd inheritance can't be modified because Emscripten doesn't support subprocesses anyway.
- setpriority always fails
- geteuid no longer causes problems with latest emsdk
- umask is a stub
- geteuid / getuid always return 0, but process cannot chown to random uid.

Lib/test/support/__init__.py
Lib/test/test_os.py
Lib/test/test_pathlib.py
Lib/test/test_posix.py
Lib/test/test_tarfile.py
Tools/wasm/config.site-wasm32-emscripten

index d80472d8776f6c33953a995d81088293052aba61..865fb976f532e6b6f9c497b7feb2c2906921e54a 100644 (file)
@@ -517,7 +517,7 @@ def requires_fork():
 has_subprocess_support = not is_emscripten and not is_wasi
 
 def requires_subprocess():
-    """Used for subprocess, os.spawn calls"""
+    """Used for subprocess, os.spawn calls, fd inheritance"""
     return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
 
 
index 48002910232339e7659732e545d3385ecf84aa85..ae8d930a95253ae0d91ea051721e81bc5b1fc867 100644 (file)
@@ -2192,6 +2192,7 @@ class TestInvalidFD(unittest.TestCase):
     def test_writev(self):
         self.check(os.writev, [b'abc'])
 
+    @support.requires_subprocess()
     def test_inheritable(self):
         self.check(os.get_inheritable)
         self.check(os.set_inheritable, True)
@@ -3866,6 +3867,8 @@ class CPUCountTests(unittest.TestCase):
             self.skipTest("Could not determine the number of CPUs")
 
 
+# FD inheritance check is only useful for systems with process support.
+@support.requires_subprocess()
 class FDInheritanceTests(unittest.TestCase):
     def test_get_set_inheritable(self):
         fd = os.open(__file__, os.O_RDONLY)
index 713d27908e7561e7007da1177bf0e192b7731cb0..66e44479239cfca73a567be9e74af29ebac3960b 100644 (file)
@@ -13,6 +13,7 @@ import unittest
 from unittest import mock
 
 from test.support import import_helper
+from test.support import is_emscripten
 from test.support import os_helper
 from test.support.os_helper import TESTFN, FakePath
 
@@ -2158,6 +2159,7 @@ class _BasePathTest(object):
         self.assertTrue(p.exists())
         self.assertEqual(p.stat().st_ctime, st_ctime_first)
 
+    @unittest.skipIf(is_emscripten, "FS root cannot be modified on Emscripten.")
     def test_mkdir_exist_ok_root(self):
         # Issue #25803: A drive root could raise PermissionError on Windows.
         self.cls('/').resolve().mkdir(exist_ok=True)
@@ -2342,6 +2344,9 @@ class _BasePathTest(object):
         self.assertIs((P / 'fileA\x00').is_socket(), False)
 
     @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
+    @unittest.skipIf(
+        is_emscripten, "Unix sockets are not implemented on Emscripten."
+    )
     def test_is_socket_true(self):
         P = self.cls(BASE, 'mysock')
         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -2497,6 +2502,9 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
         with self.assertRaises(RuntimeError):
             print(path.resolve(strict))
 
+    @unittest.skipIf(
+        is_emscripten, "umask is not implemented on Emscripten."
+    )
     def test_open_mode(self):
         old_mask = os.umask(0)
         self.addCleanup(os.umask, old_mask)
@@ -2520,6 +2528,9 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
         finally:
             os.chdir(current_directory)
 
+    @unittest.skipIf(
+        is_emscripten, "umask is not implemented on Emscripten."
+    )
     def test_touch_mode(self):
         old_mask = os.umask(0)
         self.addCleanup(os.umask, old_mask)
index 395f065234519663a6b96f3af2721f377d515df1..c10039b17f7f8d3b15b963fcdf8f3f9c3bcb7571 100644 (file)
@@ -30,8 +30,11 @@ except ImportError:
 _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
                               os_helper.TESTFN + '-dummy-symlink')
 
-requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
-        'test is only meaningful on 32-bit builds')
+requires_32b = unittest.skipUnless(
+    # Emscripten has 32 bits pointers, but support 64 bits syscall args.
+    sys.maxsize < 2**32 and not support.is_emscripten,
+    'test is only meaningful on 32-bit builds'
+)
 
 def _supports_sched():
     if not hasattr(posix, 'sched_getscheduler'):
@@ -578,6 +581,7 @@ class PosixTester(unittest.TestCase):
 
     @unittest.skipUnless(hasattr(os, 'O_CLOEXEC'), "needs os.O_CLOEXEC")
     @support.requires_linux_version(2, 6, 23)
+    @support.requires_subprocess()
     def test_oscloexec(self):
         fd = os.open(os_helper.TESTFN, os.O_RDONLY|os.O_CLOEXEC)
         self.addCleanup(os.close, fd)
@@ -737,7 +741,11 @@ class PosixTester(unittest.TestCase):
             is_root = (uid in (0, 1))
         else:
             is_root = (uid == 0)
-        if is_root:
+        if support.is_emscripten:
+            # Emscripten getuid() / geteuid() always return 0 (root), but
+            # cannot chown uid/gid to random value.
+            pass
+        elif is_root:
             # Try an amusingly large uid/gid to make sure we handle
             # large unsigned values.  (chown lets you use any
             # uid/gid you like, even if they aren't defined.)
index 0a67bcb0b09d7e54a1bc19ec767be4f37f7f9c6e..12850cd635e995d35a59fd53844082f6339ea8c1 100644 (file)
@@ -1498,6 +1498,7 @@ class StreamWriteTest(WriteTestBase, unittest.TestCase):
 
     @unittest.skipUnless(sys.platform != "win32" and hasattr(os, "umask"),
                          "Missing umask implementation")
+    @unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
     def test_file_mode(self):
         # Test for issue #8464: Create files with correct
         # permissions.
index f85024e21720f28dedfad479edd502f1443c0ee9..5eaa7933776a8d1841aee57a838958d67f1228e0 100644 (file)
@@ -62,6 +62,7 @@ ac_cv_func_pwritev2=no
 ac_cv_func_pwritev=no
 ac_cv_func_pipe2=no
 ac_cv_func_nice=no
+ac_cv_func_setpriority=no
 ac_cv_func_setitimer=no
 # unsupported syscall: __syscall_prlimit64
 ac_cv_func_prlimit=no
@@ -92,11 +93,6 @@ ac_cv_func_setgroups=no
 ac_cv_func_setresuid=no
 ac_cv_func_setresgid=no
 
-# Emscripten geteuid() / getegid() always return 0 (root), which breaks
-# assumption in tarfile module and some tests.
-ac_cv_func_getegid=no
-ac_cv_func_geteuid=no
-
 # Emscripten does not support hard links, always fails with errno 34
 # "Too many links". See emscripten_syscall_stubs.c
 ac_cv_func_link=no