bpo-40280: Skip more tests/features that don't apply to Emscripten (GH-31791)

- fd inheritance can't be modified because Emscripten doesn't support subprocesses anyway.
- setpriority always fails
- geteuid no longer causes problems with latest emsdk
- umask is a stub
- geteuid / getuid always return 0, but process cannot chown to random uid.
This commit is contained in:
Christian Heimes 2022-03-10 14:43:40 +02:00 committed by GitHub
parent 8714b6fa27
commit de554d6e02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 9 deletions

View file

@ -30,8 +30,11 @@ except ImportError:
_DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
os_helper.TESTFN + '-dummy-symlink')
requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
'test is only meaningful on 32-bit builds')
requires_32b = unittest.skipUnless(
# Emscripten has 32 bits pointers, but support 64 bits syscall args.
sys.maxsize < 2**32 and not support.is_emscripten,
'test is only meaningful on 32-bit builds'
)
def _supports_sched():
if not hasattr(posix, 'sched_getscheduler'):
@ -578,6 +581,7 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(os, 'O_CLOEXEC'), "needs os.O_CLOEXEC")
@support.requires_linux_version(2, 6, 23)
@support.requires_subprocess()
def test_oscloexec(self):
fd = os.open(os_helper.TESTFN, os.O_RDONLY|os.O_CLOEXEC)
self.addCleanup(os.close, fd)
@ -737,7 +741,11 @@ class PosixTester(unittest.TestCase):
is_root = (uid in (0, 1))
else:
is_root = (uid == 0)
if is_root:
if support.is_emscripten:
# Emscripten getuid() / geteuid() always return 0 (root), but
# cannot chown uid/gid to random value.
pass
elif is_root:
# Try an amusingly large uid/gid to make sure we handle
# large unsigned values. (chown lets you use any
# uid/gid you like, even if they aren't defined.)