Skip to content

Commit 1d2b766

Browse files
gh-90473: Skip and document more failing tests on WASI (GH-93436)
- Mark more ``umask()`` cases - ``dup()`` is not supported - ``/dev/null`` is not available - document missing features - mark more modules as not available (cherry picked from commit 069c96f) Co-authored-by: Christian Heimes <[email protected]>
1 parent e798f69 commit 1d2b766

File tree

9 files changed

+42
-6
lines changed

9 files changed

+42
-6
lines changed

Lib/test/test_compileall.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ class CompileallTestsWithoutSourceEpoch(CompileallTestsBase,
434434
pass
435435

436436

437+
# WASI does not have a temp directory and uses cwd instead. The cwd contains
438+
# non-ASCII chars, so _walk_dir() fails to encode self.directory.
439+
@unittest.skipIf(support.is_wasi, "tempdir is not encodable on WASI")
437440
class EncodingTest(unittest.TestCase):
438441
"""Issue 6716: compileall should escape source code when printing errors
439442
to stdout."""

Lib/test/test_import/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
from test.support import os_helper
2222
from test.support import (
23-
STDLIB_DIR, is_jython, swap_attr, swap_item, cpython_only, is_emscripten)
23+
STDLIB_DIR, is_jython, swap_attr, swap_item, cpython_only, is_emscripten,
24+
is_wasi)
2425
from test.support.import_helper import (
2526
forget, make_legacy_pyc, unlink, unload, DirsOnSysPath, CleanImport)
2627
from test.support.os_helper import (
@@ -535,7 +536,10 @@ class FilePermissionTests(unittest.TestCase):
535536

536537
@unittest.skipUnless(os.name == 'posix',
537538
"test meaningful only on posix systems")
538-
@unittest.skipIf(is_emscripten, "Emscripten's umask is a stub.")
539+
@unittest.skipIf(
540+
is_emscripten or is_wasi,
541+
"Emscripten's/WASI's umask is a stub."
542+
)
539543
def test_creation_mode(self):
540544
mask = 0o022
541545
with temp_umask(mask), _ready_to_import() as (name, path):

Lib/test/test_os.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ def test_access(self):
186186
@unittest.skipIf(
187187
support.is_emscripten, "Test is unstable under Emscripten."
188188
)
189+
@unittest.skipIf(
190+
support.is_wasi, "WASI does not support dup."
191+
)
189192
def test_closerange(self):
190193
first = os.open(os_helper.TESTFN, os.O_CREAT|os.O_RDWR)
191194
# We must allocate two consecutive file descriptors, otherwise
@@ -1588,7 +1591,10 @@ def test_makedir(self):
15881591
'dir5', 'dir6')
15891592
os.makedirs(path)
15901593

1591-
@unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
1594+
@unittest.skipIf(
1595+
support.is_emscripten or support.is_wasi,
1596+
"Emscripten's/WASI's umask is a stub."
1597+
)
15921598
def test_mode(self):
15931599
with os_helper.temp_umask(0o002):
15941600
base = os_helper.TESTFN

Lib/test/test_pathlib.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,9 @@ def test_is_socket_false(self):
23752375
@unittest.skipIf(
23762376
is_emscripten, "Unix sockets are not implemented on Emscripten."
23772377
)
2378+
@unittest.skipIf(
2379+
is_wasi, "Cannot create socket on WASI."
2380+
)
23782381
def test_is_socket_true(self):
23792382
P = self.cls(BASE, 'mysock')
23802383
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

Lib/test/test_shutil.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,6 +2652,7 @@ def test_stty_match(self):
26522652

26532653
self.assertEqual(expected, actual)
26542654

2655+
@unittest.skipIf(support.is_wasi, "WASI has no /dev/null")
26552656
def test_fallback(self):
26562657
with os_helper.EnvironmentVarGuard() as env:
26572658
del env['LINES']

Tools/wasm/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,25 @@ are:
237237
``socket.gethostbyname()`` are not implemented and always fail.
238238
- ``chmod(2)`` is not available. It's not possible to modify file permissions,
239239
yet. A future version of WASI may provide a limited ``set_permissions`` API.
240+
- User/group related features like ``os.chown()``, ``os.getuid``, etc. are
241+
stubs or fail with ``ENOTSUP``.
240242
- File locking (``fcntl``) is not available.
241243
- ``os.pipe()``, ``os.mkfifo()``, and ``os.mknod()`` are not supported.
242244
- ``process_time`` does not work as expected because it's implemented using
243245
wall clock.
244-
- ``os.umask`` is a stub.
246+
- ``os.umask()`` is a stub.
245247
- ``sys.executable`` is empty.
246248
- ``/dev/null`` / ``os.devnull`` may not be available.
249+
- ``os.utime*()`` is buggy in WASM SDK 15.0, see
250+
[utimensat() with timespec=NULL sets wrong time](https://github.com/bytecodealliance/wasmtime/issues/4184)
251+
- ``os.symlink()`` fails with ``PermissionError`` when attempting to create a
252+
symlink with an absolute path with wasmtime 0.36.0. The wasmtime runtime
253+
uses ``openat2(2)`` syscall with flag ``RESOLVE_BENEATH`` to open files.
254+
The flag causes the syscall to reject symlinks with absolute paths.
255+
- ``os.curdir`` (aka ``.``) seems to behave differently, which breaks some
256+
``importlib`` tests that add ``.`` to ``sys.path`` and indirectly
257+
``sys.path_importer_cache``.
258+
- WASI runtime environments may not provide a dedicated temp directory.
247259

248260

249261
# Detect WebAssembly builds

Tools/wasm/config.site-wasm32-wasi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ac_cv_func_mkfifo=no
2626
ac_cv_func_mkfifoat=no
2727
ac_cv_func_mknod=no
2828
ac_cv_func_mknodat=no
29+
ac_cv_func_makedev=no
2930

3031
# fdopendir() fails on SDK 15.0,
3132
# OSError: [Errno 28] Invalid argument: '.'

configure

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6673,10 +6673,13 @@ AS_CASE([$ac_sys_system],
66736673
],
66746674
[Emscripten/node*], [],
66756675
[WASI/*], [
6676-
dnl WASI SDK 15.0 does not support file locking.
6676+
dnl WASI SDK 15.0 does not support file locking, mmap, and more.
66776677
PY_STDLIB_MOD_SET_NA(
66786678
[_ctypes_test],
6679-
[fcntl],
6679+
[fcntl],
6680+
[mmap],
6681+
[resource],
6682+
[termios],
66806683
)
66816684
]
66826685
)

0 commit comments

Comments
 (0)