gh-90473: wasmtime does not support absolute symlinks (GH-93490)

(cherry picked from commit 6f8367d348)

Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
Miss Islington (bot) 2022-06-05 01:26:38 -07:00 committed by GitHub
parent c21f2bdaf1
commit a8bd502e57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 23 deletions

View file

@ -171,9 +171,13 @@ def can_symlink():
global _can_symlink global _can_symlink
if _can_symlink is not None: if _can_symlink is not None:
return _can_symlink return _can_symlink
symlink_path = TESTFN + "can_symlink" # WASI / wasmtime prevents symlinks with absolute paths, see man
# openat2(2) RESOLVE_BENEATH. Almost all symlink tests use absolute
# paths. Skip symlink tests on WASI for now.
src = os.path.abspath(TESTFN)
symlink_path = src + "can_symlink"
try: try:
os.symlink(TESTFN, symlink_path) os.symlink(src, symlink_path)
can = True can = True
except (OSError, NotImplementedError, AttributeError): except (OSError, NotImplementedError, AttributeError):
can = False can = False

View file

@ -387,8 +387,7 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(realpath(b'../..'), dirname(dirname(os.getcwdb()))) self.assertEqual(realpath(b'../..'), dirname(dirname(os.getcwdb())))
self.assertEqual(realpath(b'/'.join([b'..'] * 100)), b'/') self.assertEqual(realpath(b'/'.join([b'..'] * 100)), b'/')
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_basic(self): def test_realpath_basic(self):
# Basic operation. # Basic operation.
@ -398,8 +397,7 @@ class PosixPathTest(unittest.TestCase):
finally: finally:
os_helper.unlink(ABSTFN) os_helper.unlink(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_strict(self): def test_realpath_strict(self):
# Bug #43757: raise FileNotFoundError in strict mode if we encounter # Bug #43757: raise FileNotFoundError in strict mode if we encounter
@ -411,8 +409,7 @@ class PosixPathTest(unittest.TestCase):
finally: finally:
os_helper.unlink(ABSTFN) os_helper.unlink(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_relative(self): def test_realpath_relative(self):
try: try:
@ -421,8 +418,7 @@ class PosixPathTest(unittest.TestCase):
finally: finally:
os_helper.unlink(ABSTFN) os_helper.unlink(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_symlink_loops(self): def test_realpath_symlink_loops(self):
# Bug #930024, return the path unchanged if we get into an infinite # Bug #930024, return the path unchanged if we get into an infinite
@ -463,8 +459,7 @@ class PosixPathTest(unittest.TestCase):
os_helper.unlink(ABSTFN+"c") os_helper.unlink(ABSTFN+"c")
os_helper.unlink(ABSTFN+"a") os_helper.unlink(ABSTFN+"a")
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_symlink_loops_strict(self): def test_realpath_symlink_loops_strict(self):
# Bug #43757, raise OSError if we get into an infinite symlink loop in # Bug #43757, raise OSError if we get into an infinite symlink loop in
@ -505,8 +500,7 @@ class PosixPathTest(unittest.TestCase):
os_helper.unlink(ABSTFN+"c") os_helper.unlink(ABSTFN+"c")
os_helper.unlink(ABSTFN+"a") os_helper.unlink(ABSTFN+"a")
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_repeated_indirect_symlinks(self): def test_realpath_repeated_indirect_symlinks(self):
# Issue #6975. # Issue #6975.
@ -520,8 +514,7 @@ class PosixPathTest(unittest.TestCase):
os_helper.unlink(ABSTFN + '/link') os_helper.unlink(ABSTFN + '/link')
safe_rmdir(ABSTFN) safe_rmdir(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_deep_recursion(self): def test_realpath_deep_recursion(self):
depth = 10 depth = 10
@ -540,8 +533,7 @@ class PosixPathTest(unittest.TestCase):
os_helper.unlink(ABSTFN + '/%d' % i) os_helper.unlink(ABSTFN + '/%d' % i)
safe_rmdir(ABSTFN) safe_rmdir(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_resolve_parents(self): def test_realpath_resolve_parents(self):
# We also need to resolve any symlinks in the parents of a relative # We also need to resolve any symlinks in the parents of a relative
@ -560,8 +552,7 @@ class PosixPathTest(unittest.TestCase):
safe_rmdir(ABSTFN + "/y") safe_rmdir(ABSTFN + "/y")
safe_rmdir(ABSTFN) safe_rmdir(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_resolve_before_normalizing(self): def test_realpath_resolve_before_normalizing(self):
# Bug #990669: Symbolic links should be resolved before we # Bug #990669: Symbolic links should be resolved before we
@ -589,8 +580,7 @@ class PosixPathTest(unittest.TestCase):
safe_rmdir(ABSTFN + "/k") safe_rmdir(ABSTFN + "/k")
safe_rmdir(ABSTFN) safe_rmdir(ABSTFN)
@unittest.skipUnless(hasattr(os, "symlink"), @os_helper.skip_unless_symlink
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash @skip_if_ABSTFN_contains_backslash
def test_realpath_resolve_first(self): def test_realpath_resolve_first(self):
# Bug #1213894: The first component of the path, if not absolute, # Bug #1213894: The first component of the path, if not absolute,

View file

@ -161,7 +161,7 @@ class TestFilemode:
else: else:
self.assertEqual(modestr[0], 'd') self.assertEqual(modestr[0], 'd')
@unittest.skipUnless(hasattr(os, 'symlink'), 'os.symlink not available') @os_helper.skip_unless_symlink
def test_link(self): def test_link(self):
try: try:
os.symlink(os.getcwd(), TESTFN) os.symlink(os.getcwd(), TESTFN)

View file

@ -0,0 +1,2 @@
Skip symlink tests on WASI. wasmtime uses ``openat2(2)`` with
``RESOLVE_BENEATH`` flag, which prevents symlinks with absolute paths.

View file

@ -0,0 +1 @@
Skip tests on WASI that require symlinks with absolute paths.