libbtrfsutil: fix unprivileged tests if kernel lacks support
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> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0de2e22ad2
commit
41e19f703d
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue