aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar ionite34 <[email protected]>2022-11-24 15:03:28 +0800
committerGravatar ionite34 <[email protected]>2022-11-24 15:03:28 +0800
commitb528af673dcf3dd1b06a467b3b147a75d52d6181 (patch)
tree6ade0f4a8b98eb7baf4322bc7668375170e6ba31 /tests
parentAdd concurrency tests to libmount (diff)
Add tests for unmount flags
Diffstat (limited to 'tests')
-rw-r--r--tests/test_libmount.py20
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 = [