From: Omar Sandoval <osandov@xxxxxx>
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 <bsd@xxxxxx>
Signed-off-by: Omar Sandoval <osandov@xxxxxx>
---
libbtrfsutil/python/subvolume.c | 2 +-
libbtrfsutil/python/tests/test_subvolume.py | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
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')
--
2.19.1