Issue #15747: skip chflags UF_IMMUTABLE tests if EOPNOTSUPP is raised.

This is necessary for ZFS systems, which don't support UF_IMMUTABLE.
This commit is contained in:
Trent Nelson 2012-08-21 23:41:43 +00:00
parent 1b47bf43a6
commit ee253ebf62
2 changed files with 24 additions and 3 deletions

View File

@ -334,7 +334,16 @@ class PosixTester(unittest.TestCase):
def _test_chflags_regular_file(self, chflags_func, target_file): def _test_chflags_regular_file(self, chflags_func, target_file):
st = os.stat(target_file) st = os.stat(target_file)
self.assertTrue(hasattr(st, 'st_flags')) self.assertTrue(hasattr(st, 'st_flags'))
# ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE.
try:
chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE) chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE)
except OSError as err:
if err.errno != errno.EOPNOTSUPP:
raise
msg = 'chflag UF_IMMUTABLE not supported by underlying fs'
self.skipTest(msg)
try: try:
new_st = os.stat(target_file) new_st = os.stat(target_file)
self.assertEqual(st.st_flags | stat.UF_IMMUTABLE, new_st.st_flags) self.assertEqual(st.st_flags | stat.UF_IMMUTABLE, new_st.st_flags)
@ -363,8 +372,16 @@ class PosixTester(unittest.TestCase):
self.teardown_files.append(_DUMMY_SYMLINK) self.teardown_files.append(_DUMMY_SYMLINK)
dummy_symlink_st = os.lstat(_DUMMY_SYMLINK) dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
# ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE.
try:
posix.lchflags(_DUMMY_SYMLINK, posix.lchflags(_DUMMY_SYMLINK,
dummy_symlink_st.st_flags | stat.UF_IMMUTABLE) dummy_symlink_st.st_flags | stat.UF_IMMUTABLE)
except OSError as err:
if err.errno != errno.EOPNOTSUPP:
raise
msg = 'chflag UF_IMMUTABLE not supported by underlying fs'
self.skipTest(msg)
try: try:
new_testfn_st = os.stat(support.TESTFN) new_testfn_st = os.stat(support.TESTFN)
new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK) new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)

View File

@ -436,6 +436,10 @@ Extension Modules
Tests Tests
----- -----
- Issue #15747: ZFS always returns EOPNOTSUPP when attempting to set the
UF_IMMUTABLE flag (via either chflags or lchflags); refactor affected
tests in test_posix.py to account for this.
- Issue #15285: Refactor the approach for testing connect timeouts using - Issue #15285: Refactor the approach for testing connect timeouts using
two external hosts that have been configured specifically for this type two external hosts that have been configured specifically for this type
of test. of test.