Linux-BTRFS Archive on lore.kernel.org
 help / Atom feed
* [PATCH] libbtrfsutil: fix unprivileged tests if kernel lacks support
@ 2018-12-07  0:29 Omar Sandoval
  2018-12-07 19:14 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Omar Sandoval @ 2018-12-07  0:29 UTC (permalink / raw)
  To: linux-btrfs; +Cc: kernel-team

From: Omar Sandoval <osandov@fb.com>

I apparently didn't test this on a pre-4.18 kernel.
test_subvolume_info_unprivileged() checks for an ENOTTY, but this
doesn't seem to work correctly with subTest().
test_subvolume_iterator_unprivileged() doesn't have a check at all. Add
an explicit check to both before doing the actual test.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
Based on the devel branch.

 libbtrfsutil/python/tests/test_subvolume.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libbtrfsutil/python/tests/test_subvolume.py b/libbtrfsutil/python/tests/test_subvolume.py
index 99ec97bc..b06a1d3d 100644
--- a/libbtrfsutil/python/tests/test_subvolume.py
+++ b/libbtrfsutil/python/tests/test_subvolume.py
@@ -168,12 +168,13 @@ class TestSubvolume(BtrfsTestCase):
 
         with drop_privs():
             try:
-                self._test_subvolume_info(subvol, snapshot)
+                btrfsutil.subvolume_info(self.mountpoint)
             except OSError as e:
                 if e.errno == errno.ENOTTY:
                     self.skipTest('BTRFS_IOC_GET_SUBVOL_INFO is not available')
                 else:
                     raise
+            self._test_subvolume_info(subvol, snapshot)
 
     def test_read_only(self):
         for arg in self.path_or_fd(self.mountpoint):
@@ -487,6 +488,13 @@ class TestSubvolume(BtrfsTestCase):
         try:
             os.chdir(self.mountpoint)
             with drop_privs():
+                try:
+                    list(btrfsutil.SubvolumeIterator('.'))
+                except OSError as e:
+                    if e.errno == errno.ENOTTY:
+                        self.skipTest('BTRFS_IOC_GET_SUBVOL_ROOTREF is not available')
+                    else:
+                        raise
                 self._test_subvolume_iterator()
         finally:
             os.chdir(pwd)
-- 
2.19.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libbtrfsutil: fix unprivileged tests if kernel lacks support
  2018-12-07  0:29 [PATCH] libbtrfsutil: fix unprivileged tests if kernel lacks support Omar Sandoval
@ 2018-12-07 19:14 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-12-07 19:14 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-btrfs, kernel-team

On Thu, Dec 06, 2018 at 04:29:32PM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> I apparently didn't test this on a pre-4.18 kernel.
> test_subvolume_info_unprivileged() checks for an ENOTTY, but this
> doesn't seem to work correctly with subTest().
> test_subvolume_iterator_unprivileged() doesn't have a check at all. Add
> an explicit check to both before doing the actual test.
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07  0:29 [PATCH] libbtrfsutil: fix unprivileged tests if kernel lacks support Omar Sandoval
2018-12-07 19:14 ` David Sterba

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox