diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-08-17 01:27:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-08-17 01:27:09 (GMT) |
commit | 052a02be4a472e554233e39b61f6de7f0b7e165d (patch) | |
tree | fb2f56c6f4d533a2f48594e29cf53793e161ae92 /Lib | |
parent | 82c4885210955cc45c5388b95e8366acf15c41a7 (diff) | |
download | cpython-052a02be4a472e554233e39b61f6de7f0b7e165d.zip cpython-052a02be4a472e554233e39b61f6de7f0b7e165d.tar.gz cpython-052a02be4a472e554233e39b61f6de7f0b7e165d.tar.bz2 |
add tests for mknod() and mkfifo() #9569
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_posix.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index a22ebdf..b0d7fce 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -11,6 +11,7 @@ import time import os import pwd import shutil +import stat import unittest import warnings @@ -199,6 +200,28 @@ class PosixTester(unittest.TestCase): if hasattr(posix, 'stat'): self.assertTrue(posix.stat(support.TESTFN)) + @unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()") + def test_mkfifo(self): + support.unlink(support.TESTFN) + posix.mkfifo(support.TESTFN, stat.S_IRUSR | stat.S_IWUSR) + self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode)) + + @unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'), + "don't have mknod()/S_IFIFO") + def test_mknod(self): + # Test using mknod() to create a FIFO (the only use specified + # by POSIX). + support.unlink(support.TESTFN) + mode = stat.S_IFIFO | stat.S_IRUSR | stat.S_IWUSR + try: + posix.mknod(support.TESTFN, mode, 0) + except OSError as e: + # Some old systems don't allow unprivileged users to use + # mknod(), or only support creating device nodes. + self.assertIn(e.errno, (errno.EPERM, errno.EINVAL)) + else: + self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode)) + def _test_all_chown_common(self, chown_func, first_param): """Common code for chown, fchown and lchown tests.""" if os.getuid() == 0: |