summaryrefslogtreecommitdiff
path: root/libbtrfsutil/python/tests
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-01-18 13:39:57 -0800
committerDavid Sterba <dsterba@suse.com>2018-03-06 11:28:36 +0100
commit172c0d1a1218187f20460988a3c3d6212748f825 (patch)
tree31c30ae8f17850224bcdff37c85ec0198d033f02 /libbtrfsutil/python/tests
parent0d36261bd54a93b1b1b616bdd32d33b3f4278f09 (diff)
libbtrfsutil: add btrfs_util_[gs]et_read_only()
In the future, btrfs_util_[gs]et_subvolume_flags() might be useful, but since these are the only subvolume flags we've defined in all this time, this will do for now. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'libbtrfsutil/python/tests')
-rw-r--r--libbtrfsutil/python/tests/test_subvolume.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/libbtrfsutil/python/tests/test_subvolume.py b/libbtrfsutil/python/tests/test_subvolume.py
index ecb0d7ae..23871de9 100644
--- a/libbtrfsutil/python/tests/test_subvolume.py
+++ b/libbtrfsutil/python/tests/test_subvolume.py
@@ -137,6 +137,23 @@ class TestSubvolume(BtrfsTestCase):
# BTRFS_EXTENT_TREE_OBJECTID
btrfsutil.subvolume_info(arg, 2)
+ def test_read_only(self):
+ for arg in self.path_or_fd(self.mountpoint):
+ with self.subTest(type=type(arg)):
+ btrfsutil.set_subvolume_read_only(arg)
+ self.assertTrue(btrfsutil.get_subvolume_read_only(arg))
+ self.assertTrue(btrfsutil.subvolume_info(arg).flags & 1)
+
+ btrfsutil.set_subvolume_read_only(arg, False)
+ self.assertFalse(btrfsutil.get_subvolume_read_only(arg))
+ self.assertFalse(btrfsutil.subvolume_info(arg).flags & 1)
+
+ btrfsutil.set_subvolume_read_only(arg, True)
+ self.assertTrue(btrfsutil.get_subvolume_read_only(arg))
+ self.assertTrue(btrfsutil.subvolume_info(arg).flags & 1)
+
+ btrfsutil.set_subvolume_read_only(arg, False)
+
def test_create_subvolume(self):
subvol = os.path.join(self.mountpoint, 'subvol')