diff options
| author | 2022-11-24 15:03:28 +0800 | |
|---|---|---|
| committer | 2022-11-24 15:03:28 +0800 | |
| commit | b528af673dcf3dd1b06a467b3b147a75d52d6181 (patch) | |
| tree | 6ade0f4a8b98eb7baf4322bc7668375170e6ba31 | |
| parent | Add concurrency tests to libmount (diff) | |
Add tests for unmount flags
| -rw-r--r-- | tests/test_libmount.py | 20 | 
1 files changed, 19 insertions, 1 deletions
| diff --git a/tests/test_libmount.py b/tests/test_libmount.py index b9a5c15..8e56970 100644 --- a/tests/test_libmount.py +++ b/tests/test_libmount.py @@ -22,7 +22,8 @@ class LibMountTests(TestCase):              libmount.mount(source="", target=path, fs="tmpfs")              yield path          finally: -            libmount.unmount(target=path) +            with suppress(OSError): +                libmount.unmount(path)      def test_mount(self):          """Test normal mounting.""" @@ -62,6 +63,23 @@ class LibMountTests(TestCase):          finally:              libmount.unmount(target=path) +    def test_unmount_flags(self): +        """Test unmount flags.""" +        flags = [ +            libmount.UnmountFlags.MNT_FORCE, +            libmount.UnmountFlags.MNT_DETACH, +            libmount.UnmountFlags.UMOUNT_NOFOLLOW, +        ] +        for flag in flags: +            with self.subTest(flag=flag), self.get_mount() as path: +                libmount.unmount(path, flag) + +    def test_unmount_flags_expire(self): +        """Test unmount MNT_EXPIRE behavior.""" +        with self.get_mount() as path: +            with self.assertRaises(BlockingIOError): +                libmount.unmount(path, libmount.UnmountFlags.MNT_EXPIRE) +      def test_unmount_errors(self):          """Test invalid unmount errors."""          cases = [ | 
