From 563affcd42d4575d477e0f7fe067e1259dfb3687 Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Tue, 13 Nov 2018 23:46:56 -0800 Subject: libbtrfsutil: use top=0 as default for SubvolumeIterator() Right now, we're defaulting to top=5 (i.e, all subvolumes). The documented default is top=0 (i.e, only beneath the given path). This is the expected behavior. Fix it and make the test cases cover it. Reported-by: Jonathan Lemon Signed-off-by: Omar Sandoval Signed-off-by: David Sterba --- libbtrfsutil/python/subvolume.c | 2 +- libbtrfsutil/python/tests/test_subvolume.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'libbtrfsutil') diff --git a/libbtrfsutil/python/subvolume.c b/libbtrfsutil/python/subvolume.c index 069e606b..6ecde1f6 100644 --- a/libbtrfsutil/python/subvolume.c +++ b/libbtrfsutil/python/subvolume.c @@ -525,7 +525,7 @@ static int SubvolumeIterator_init(SubvolumeIterator *self, PyObject *args, static char *keywords[] = {"path", "top", "info", "post_order", NULL}; struct path_arg path = {.allow_fd = true}; enum btrfs_util_error err; - unsigned long long top = 5; + unsigned long long top = 0; int info = 0; int post_order = 0; int flags = 0; diff --git a/libbtrfsutil/python/tests/test_subvolume.py b/libbtrfsutil/python/tests/test_subvolume.py index 93396cba..0788a564 100644 --- a/libbtrfsutil/python/tests/test_subvolume.py +++ b/libbtrfsutil/python/tests/test_subvolume.py @@ -353,6 +353,7 @@ class TestSubvolume(BtrfsTestCase): with self.subTest(type=type(arg)): self.assertEqual(list(btrfsutil.SubvolumeIterator(arg)), subvols) self.assertEqual(list(btrfsutil.SubvolumeIterator('.', top=0)), subvols) + self.assertEqual(list(btrfsutil.SubvolumeIterator('foo', top=5)), subvols) self.assertEqual(list(btrfsutil.SubvolumeIterator('.', post_order=True)), [('foo/bar/baz', 258), @@ -365,6 +366,7 @@ class TestSubvolume(BtrfsTestCase): ] self.assertEqual(list(btrfsutil.SubvolumeIterator('.', top=256)), subvols) + self.assertEqual(list(btrfsutil.SubvolumeIterator('foo')), subvols) self.assertEqual(list(btrfsutil.SubvolumeIterator('foo', top=0)), subvols) os.rename('foo/bar/baz', 'baz') -- cgit v1.2.3