]> granicus.if.org Git - python/commitdiff
Issue #15747: skip chflags UF_IMMUTABLE tests if EOPNOTSUPP is raised.
authorTrent Nelson <trent@trent.me>
Tue, 21 Aug 2012 23:41:43 +0000 (23:41 +0000)
committerTrent Nelson <trent@trent.me>
Tue, 21 Aug 2012 23:41:43 +0000 (23:41 +0000)
This is necessary for ZFS systems, which don't support UF_IMMUTABLE.

Lib/test/test_posix.py
Misc/NEWS

index c04c67921052b7aa977629108a4c2f1d433b7623..b936dda44bc4b51c5d0a2ba89bbfe5c53c67c7cb 100644 (file)
@@ -334,7 +334,16 @@ class PosixTester(unittest.TestCase):
     def _test_chflags_regular_file(self, chflags_func, target_file):
         st = os.stat(target_file)
         self.assertTrue(hasattr(st, 'st_flags'))
-        chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE)
+
+        # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE.
+        try:
+            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:
             new_st = os.stat(target_file)
             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)
         dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
 
-        posix.lchflags(_DUMMY_SYMLINK,
-                       dummy_symlink_st.st_flags | stat.UF_IMMUTABLE)
+        # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE.
+        try:
+            posix.lchflags(_DUMMY_SYMLINK,
+                           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:
             new_testfn_st = os.stat(support.TESTFN)
             new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
index 02e3ef7585c7714b49a8eba1b1292779fb1c9498..87a89fbbc1d242cc6f609d8af0e4bf69a013590b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -436,6 +436,10 @@ Extension Modules
 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
   two external hosts that have been configured specifically for this type
   of test.