MCPcopy Index your code
hub / github.com/RustPython/RustPython / in_systemd_nspawn_sync_suppressed

Function in_systemd_nspawn_sync_suppressed

Lib/test/support/__init__.py:3070–3100  ·  view source on GitHub ↗

Test whether the test suite is runing in systemd-nspawn with ``--suppress-sync=true``. This can be used to skip tests that rely on ``fsync()`` calls and similar not being intercepted.

()

Source from the content-addressed store, hash-verified

3068
3069
3070def in_systemd_nspawn_sync_suppressed() -> bool:
3071 """
3072 Test whether the test suite is runing in systemd-nspawn
3073 with ``--suppress-sync=true``.
3074
3075 This can be used to skip tests that rely on ``fsync()`` calls
3076 and similar not being intercepted.
3077 """
3078
3079 if not hasattr(os, "O_SYNC"):
3080 return False
3081
3082 try:
3083 with open("/run/systemd/container", "rb") as fp:
3084 if fp.read().rstrip() != b"systemd-nspawn":
3085 return False
3086 except FileNotFoundError:
3087 return False
3088
3089 # If systemd-nspawn is used, O_SYNC flag will immediately
3090 # trigger EINVAL. Otherwise, ENOENT will be given instead.
3091 import errno
3092 try:
3093 fd = os.open(__file__, os.O_RDONLY | os.O_SYNC)
3094 except OSError as err:
3095 if err.errno == errno.EINVAL:
3096 return True
3097 else:
3098 os.close(fd)
3099
3100 return False
3101
3102def run_no_yield_async_fn(async_fn, /, *args, **kwargs):
3103 coro = async_fn(*args, **kwargs)

Callers

nothing calls this directly

Calls 6

hasattrFunction · 0.85
openFunction · 0.50
rstripMethod · 0.45
readMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected