summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-13 09:00:01 (GMT)
committerXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-13 09:00:01 (GMT)
commit3a4e989324cc1f75c9f749c9e1c20de2f43df6e3 (patch)
tree909f3c636598c4ec5a76916801cb91861ded71ce /Lib/test/test_posix.py
parentfb24eead481a00c9bb86c436461971790fce7937 (diff)
downloadcpython-3a4e989324cc1f75c9f749c9e1c20de2f43df6e3.zip
cpython-3a4e989324cc1f75c9f749c9e1c20de2f43df6e3.tar.gz
cpython-3a4e989324cc1f75c9f749c9e1c20de2f43df6e3.tar.bz2
Issue #28759: Fix the tests that fail with PermissionError when run as
a non-root user on Android where access rights are controled by SELinux MAC.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 63c74cd..029d081 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1,6 +1,7 @@
"Test posix functions"
from test import support
+android_not_root = support.android_not_root
# Skip these tests if there is no posix module.
posix = support.import_module('posix')
@@ -422,6 +423,7 @@ class PosixTester(unittest.TestCase):
posix.stat, list(os.fsencode(support.TESTFN)))
@unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
+ @unittest.skipIf(android_not_root, "mkfifo not allowed, non root user")
def test_mkfifo(self):
support.unlink(support.TESTFN)
posix.mkfifo(support.TESTFN, stat.S_IRUSR | stat.S_IWUSR)
@@ -429,6 +431,7 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'),
"don't have mknod()/S_IFIFO")
+ @unittest.skipIf(android_not_root, "mknod not allowed, non root user")
def test_mknod(self):
# Test using mknod() to create a FIFO (the only use specified
# by POSIX).
@@ -907,6 +910,7 @@ class PosixTester(unittest.TestCase):
posix.close(f)
@unittest.skipUnless(os.link in os.supports_dir_fd, "test needs dir_fd support in os.link()")
+ @unittest.skipIf(android_not_root, "hard link not allowed, non root user")
def test_link_dir_fd(self):
f = posix.open(posix.getcwd(), posix.O_RDONLY)
try:
@@ -930,6 +934,7 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless((os.mknod in os.supports_dir_fd) and hasattr(stat, 'S_IFIFO'),
"test requires both stat.S_IFIFO and dir_fd support for os.mknod()")
+ @unittest.skipIf(android_not_root, "mknod not allowed, non root user")
def test_mknod_dir_fd(self):
# Test using mknodat() to create a FIFO (the only use specified
# by POSIX).
@@ -1013,6 +1018,7 @@ class PosixTester(unittest.TestCase):
posix.close(f)
@unittest.skipUnless(os.mkfifo in os.supports_dir_fd, "test needs dir_fd support in os.mkfifo()")
+ @unittest.skipIf(android_not_root, "mkfifo not allowed, non root user")
def test_mkfifo_dir_fd(self):
support.unlink(support.TESTFN)
f = posix.open(posix.getcwd(), posix.O_RDONLY)