Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import types
import unittest
import warnings
from pathlib import Path


__all__ = [
Expand Down Expand Up @@ -61,6 +62,7 @@
"without_optimizer",
"force_not_colorized",
"BrokenIter",
"in_systemd_nspawn",
]


Expand Down Expand Up @@ -2873,3 +2875,11 @@ def __iter__(self):
if self.iter_raises:
1/0
return self


def in_systemd_nspawn() -> bool:
try:
return (Path("/run/systemd/container").read_bytes().rstrip() ==
b"systemd-nspawn")
except FileNotFoundError:
return False
3 changes: 2 additions & 1 deletion Lib/test/test_mmap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from test.support import (
requires, _2G, _4G, gc_collect, cpython_only, is_emscripten, is_apple,
in_systemd_nspawn,
)
from test.support.import_helper import import_module
from test.support.os_helper import TESTFN, unlink
Expand Down Expand Up @@ -839,7 +840,7 @@ def test_flush_return_value(self):
mm.write(b'python')
result = mm.flush()
self.assertIsNone(result)
if sys.platform.startswith(('linux', 'android')):
if sys.platform.startswith(('linux', 'android')) and not in_systemd_nspawn():
# 'offset' must be a multiple of mmap.PAGESIZE on Linux.
# See bpo-34754 for details.
self.assertRaises(OSError, mm.flush, 1, len(b'python'))
Expand Down
10 changes: 7 additions & 3 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2351,9 +2351,13 @@ def test_chmod(self):

@unittest.skipIf(support.is_wasi, "Cannot create invalid FD on WASI.")
class TestInvalidFD(unittest.TestCase):
singles = ["fchdir", "dup", "fdatasync", "fstat",
"fstatvfs", "fsync", "tcgetpgrp", "ttyname"]
singles_fildes = {"fchdir", "fdatasync", "fsync"}
singles = ["fchdir", "dup", "fstat", "fstatvfs", "tcgetpgrp", "ttyname"]
singles_fildes = {"fchdir"}
# systemd-nspawn --suppress-sync=true does not verify fd passed
# fdatasync() and fsync(), and always returns success
if not support.in_systemd_nspawn():
singles += ["fdatasync", "fsync"]
singles_fildes |= {"fdatasync", "fsync"}
#singles.append("close")
#We omit close because it doesn't raise an exception on some platforms
def get_single(f):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Skip tests failing with ``--suppress-sync=true`` when running inside
systemd-nspawn container.
Loading