tests: fix cleanup after reflink tests

First make the directory accessible again, otherwise os.path.ismount may
not detect it (so umount would not be called) and then rmdir will fail.
This commit is contained in:
Marek Marczykowski-Górecki 2019-03-16 03:21:16 +01:00
parent aa7c0b71a7
commit 4234fe5112
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -130,6 +130,8 @@ def mkdir_fs(directory, fs_type,
cleanup_via(rmtree_fs, directory)
def rmtree_fs(directory):
cmd('sudo', 'chattr', '-i', directory)
cmd('sudo', 'chmod', '777', directory)
if os.path.ismount(directory):
try:
cmd('sudo', 'umount', directory)
@ -137,8 +139,6 @@ def rmtree_fs(directory):
cmd('sudo', 'fuser', '-vm', directory)
raise
# loop device and backing file are garbage collected automatically
cmd('sudo', 'chattr', '-i', directory)
cmd('sudo', 'chmod', '777', directory)
shutil.rmtree(directory)
def get_blockdev_size(dev):