]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90473: Skip and document more failing tests on WASI (GH-93436)
authorChristian Heimes <christian@python.org>
Thu, 2 Jun 2022 22:44:48 +0000 (00:44 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Jun 2022 22:44:48 +0000 (00:44 +0200)
- Mark more ``umask()`` cases
- ``dup()`` is not supported
- ``/dev/null`` is not available
- document missing features
- mark more modules as not available

Lib/test/test_compileall.py
Lib/test/test_import/__init__.py
Lib/test/test_os.py
Lib/test/test_pathlib.py
Lib/test/test_shutil.py
Tools/wasm/README.md
Tools/wasm/config.site-wasm32-wasi
configure
configure.ac

index 1a9fc973c3aa121ccdb06a34f6f352e7416a21a5..73c83c9bf1efee97713adc03cca94e9ba93847b7 100644 (file)
@@ -434,6 +434,9 @@ class CompileallTestsWithoutSourceEpoch(CompileallTestsBase,
     pass
 
 
+# WASI does not have a temp directory and uses cwd instead. The cwd contains
+# non-ASCII chars, so _walk_dir() fails to encode self.directory.
+@unittest.skipIf(support.is_wasi, "tempdir is not encodable on WASI")
 class EncodingTest(unittest.TestCase):
     """Issue 6716: compileall should escape source code when printing errors
     to stdout."""
index be88677dc697ee4fd4f5f500d10d9a2713cd2c4c..35c260bd634fc6008ed552d0e668ba51916f0fe6 100644 (file)
@@ -20,7 +20,8 @@ from unittest import mock
 
 from test.support import os_helper
 from test.support import (
-    STDLIB_DIR, is_jython, swap_attr, swap_item, cpython_only, is_emscripten)
+    STDLIB_DIR, is_jython, swap_attr, swap_item, cpython_only, is_emscripten,
+    is_wasi)
 from test.support.import_helper import (
     forget, make_legacy_pyc, unlink, unload, DirsOnSysPath, CleanImport)
 from test.support.os_helper import (
@@ -535,7 +536,10 @@ class FilePermissionTests(unittest.TestCase):
 
     @unittest.skipUnless(os.name == 'posix',
                          "test meaningful only on posix systems")
-    @unittest.skipIf(is_emscripten, "Emscripten's umask is a stub.")
+    @unittest.skipIf(
+        is_emscripten or is_wasi,
+        "Emscripten's/WASI's umask is a stub."
+    )
     def test_creation_mode(self):
         mask = 0o022
         with temp_umask(mask), _ready_to_import() as (name, path):
index 009bb5aec35a4b9c56d33d16f6394efdabbdfd80..f304c5e01e5fa1a13919ef9f001936f6c954b7ef 100644 (file)
@@ -186,6 +186,9 @@ class FileTests(unittest.TestCase):
     @unittest.skipIf(
         support.is_emscripten, "Test is unstable under Emscripten."
     )
+    @unittest.skipIf(
+        support.is_wasi, "WASI does not support dup."
+    )
     def test_closerange(self):
         first = os.open(os_helper.TESTFN, os.O_CREAT|os.O_RDWR)
         # We must allocate two consecutive file descriptors, otherwise
@@ -1588,7 +1591,10 @@ class MakedirTests(unittest.TestCase):
                             'dir5', 'dir6')
         os.makedirs(path)
 
-    @unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
+    @unittest.skipIf(
+        support.is_emscripten or support.is_wasi,
+        "Emscripten's/WASI's umask is a stub."
+    )
     def test_mode(self):
         with os_helper.temp_umask(0o002):
             base = os_helper.TESTFN
index 642dfebdcd1cbe3bc72366b623f6278c0617049e..6694f1bfc1cd436f4fa8519e397b0ed15ec58d02 100644 (file)
@@ -2353,6 +2353,9 @@ class _BasePathTest(object):
     @unittest.skipIf(
         is_emscripten, "Unix sockets are not implemented on Emscripten."
     )
+    @unittest.skipIf(
+        is_wasi, "Cannot create socket on WASI."
+    )
     def test_is_socket_true(self):
         P = self.cls(BASE, 'mysock')
         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
index a61bb126e4e73f845f5e06893622e96e1fa54ea9..c94390589af3ed00680eb6f4348b2edc1a9a1453 100644 (file)
@@ -2652,6 +2652,7 @@ class TestGetTerminalSize(unittest.TestCase):
 
         self.assertEqual(expected, actual)
 
+    @unittest.skipIf(support.is_wasi, "WASI has no /dev/null")
     def test_fallback(self):
         with os_helper.EnvironmentVarGuard() as env:
             del env['LINES']
index 239eb90d0743c2497457410e8e1d9cb9a0b198f9..6bb9bd9978402b0de45df5238013df1f1b97c7f3 100644 (file)
@@ -237,13 +237,25 @@ are:
   ``socket.gethostbyname()`` are not implemented and always fail.
 - ``chmod(2)`` is not available. It's not possible to modify file permissions,
   yet. A future version of WASI may provide a limited ``set_permissions`` API.
+- User/group related features like ``os.chown()``, ``os.getuid``, etc. are
+  stubs or fail with ``ENOTSUP``.
 - File locking (``fcntl``) is not available.
 - ``os.pipe()``, ``os.mkfifo()``, and ``os.mknod()`` are not supported.
 - ``process_time`` does not work as expected because it's implemented using
   wall clock.
-- ``os.umask`` is a stub.
+- ``os.umask()`` is a stub.
 - ``sys.executable`` is empty.
 - ``/dev/null`` / ``os.devnull`` may not be available.
+- ``os.utime*()`` is buggy in WASM SDK 15.0, see
+  [utimensat() with timespec=NULL sets wrong time](https://github.com/bytecodealliance/wasmtime/issues/4184)
+- ``os.symlink()`` fails with ``PermissionError`` when attempting to create a
+  symlink with an absolute path with wasmtime 0.36.0. The wasmtime runtime
+  uses ``openat2(2)`` syscall with flag ``RESOLVE_BENEATH`` to open files.
+  The flag causes the syscall to reject symlinks with absolute paths.
+- ``os.curdir`` (aka ``.``) seems to behave differently, which breaks some
+  ``importlib`` tests that add ``.`` to ``sys.path`` and indirectly
+  ``sys.path_importer_cache``.
+- WASI runtime environments may not provide a dedicated temp directory.
 
 
 # Detect WebAssembly builds
index ee3fc830e3d8a3dace158cb59c31d8afbbc42077..a6fcbed48fa8110b8553c9fe1707fd8af5aec3e1 100644 (file)
@@ -26,6 +26,7 @@ ac_cv_func_mkfifo=no
 ac_cv_func_mkfifoat=no
 ac_cv_func_mknod=no
 ac_cv_func_mknodat=no
+ac_cv_func_makedev=no
 
 # fdopendir() fails on SDK 15.0,
 # OSError: [Errno 28] Invalid argument: '.'
index de2983aee7c08fb7db9f4675862d061ff919d1f1..74972842a41d9034e4fad61c64db8377f01710aa 100755 (executable)
--- a/configure
+++ b/configure
@@ -22472,6 +22472,9 @@ case $ac_sys_system in #(
 
     py_cv_module__ctypes_test=n/a
     py_cv_module_fcntl=n/a
+    py_cv_module_mmap=n/a
+    py_cv_module_resource=n/a
+    py_cv_module_termios=n/a
     py_cv_module_=n/a
 
 
index e925bc0c8df1a63d63ccb143c8c5e4e53fa47147..269f9201d783391e30573bd22f532782fe5e3461 100644 (file)
@@ -6606,10 +6606,13 @@ AS_CASE([$ac_sys_system],
       ],
       [Emscripten/node*], [],
       [WASI/*], [
-        dnl WASI SDK 15.0 does not support file locking.
+        dnl WASI SDK 15.0 does not support file locking, mmap, and more.
         PY_STDLIB_MOD_SET_NA(
           [_ctypes_test],
-         [fcntl],
+          [fcntl],
+          [mmap],
+          [resource],
+          [termios],
         )
       ]
     )