11"Test posix functions"
22
33from test import support
4+ android_not_root = support .android_not_root
45
56# Skip these tests if there is no posix module.
67posix = support .import_module ('posix' )
@@ -422,13 +423,15 @@ def test_stat(self):
422423 posix .stat , list (os .fsencode (support .TESTFN )))
423424
424425 @unittest .skipUnless (hasattr (posix , 'mkfifo' ), "don't have mkfifo()" )
426+ @unittest .skipIf (android_not_root , "mkfifo not allowed, non root user" )
425427 def test_mkfifo (self ):
426428 support .unlink (support .TESTFN )
427429 posix .mkfifo (support .TESTFN , stat .S_IRUSR | stat .S_IWUSR )
428430 self .assertTrue (stat .S_ISFIFO (posix .stat (support .TESTFN ).st_mode ))
429431
430432 @unittest .skipUnless (hasattr (posix , 'mknod' ) and hasattr (stat , 'S_IFIFO' ),
431433 "don't have mknod()/S_IFIFO" )
434+ @unittest .skipIf (android_not_root , "mknod not allowed, non root user" )
432435 def test_mknod (self ):
433436 # Test using mknod() to create a FIFO (the only use specified
434437 # by POSIX).
@@ -907,6 +910,7 @@ def test_utime_dir_fd(self):
907910 posix .close (f )
908911
909912 @unittest .skipUnless (os .link in os .supports_dir_fd , "test needs dir_fd support in os.link()" )
913+ @unittest .skipIf (android_not_root , "hard link not allowed, non root user" )
910914 def test_link_dir_fd (self ):
911915 f = posix .open (posix .getcwd (), posix .O_RDONLY )
912916 try :
@@ -930,6 +934,7 @@ def test_mkdir_dir_fd(self):
930934
931935 @unittest .skipUnless ((os .mknod in os .supports_dir_fd ) and hasattr (stat , 'S_IFIFO' ),
932936 "test requires both stat.S_IFIFO and dir_fd support for os.mknod()" )
937+ @unittest .skipIf (android_not_root , "mknod not allowed, non root user" )
933938 def test_mknod_dir_fd (self ):
934939 # Test using mknodat() to create a FIFO (the only use specified
935940 # by POSIX).
@@ -1013,6 +1018,7 @@ def test_unlink_dir_fd(self):
10131018 posix .close (f )
10141019
10151020 @unittest .skipUnless (os .mkfifo in os .supports_dir_fd , "test needs dir_fd support in os.mkfifo()" )
1021+ @unittest .skipIf (android_not_root , "mkfifo not allowed, non root user" )
10161022 def test_mkfifo_dir_fd (self ):
10171023 support .unlink (support .TESTFN )
10181024 f = posix .open (posix .getcwd (), posix .O_RDONLY )
0 commit comments