Skip to content

Commit 57cf47b

Browse files
committed
mountpoints are cleaned up and DELETED after tests
1 parent 33d52f8 commit 57cf47b

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

tests/lib/base.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3131

3232
import os
33+
import shutil
3334
import time
3435

3536
from .const import (
@@ -125,13 +126,13 @@ def init_c_parentfs(self):
125126
self.__mk_dir__(self.mount_parent_abs_path)
126127
if not self.travis:
127128
self.__mount_parent_fs__()
128-
self.__mk_dir__(self.mount_child_abs_path, in_fs_root = True)
129129
self.__mk_dir__(self.logs_abs_path)
130130

131131

132132
def init_d_childfs(self):
133133

134134
open(self.loggedfs_log_abs_path, 'a').close() # HACK create empty loggedfs log file
135+
self.__mk_dir__(self.mount_child_abs_path, in_fs_root = True)
135136
if self.fs_type == TEST_FS_LOGGEDFS:
136137
self.__mount_child_fs__()
137138
open(self.fstest_log_abs_path, 'a').close() # HACK create empty fstest log file
@@ -155,26 +156,27 @@ def destroy_a_childfs(self):
155156
if not self.fs_type == TEST_FS_LOGGEDFS:
156157
return
157158

158-
if not is_path_mountpoint(self.mount_child_abs_path):
159-
return
159+
if is_path_mountpoint(self.mount_child_abs_path):
160+
umount_child_status = umount_fuse(self.mount_child_abs_path, sudo = self.with_sudo)
161+
assert umount_child_status
162+
assert not is_path_mountpoint(self.mount_child_abs_path)
160163

161-
umount_child_status = umount_fuse(self.mount_child_abs_path, sudo = self.with_sudo)
162-
assert umount_child_status
163-
assert not is_path_mountpoint(self.mount_child_abs_path)
164+
self.__rm_tree__(self.mount_child_abs_path, in_fs_root = True)
164165

165166
time.sleep(0.1) # HACK ... otherwise parent will be busy
166167

167168

168169
def destroy_b_parentfs(self):
169170

170-
if self.travis:
171-
return
171+
if not self.travis:
172+
umount_parent_status = umount(self.mount_parent_abs_path, sudo = True)
173+
assert umount_parent_status
174+
assert not is_path_mountpoint(self.mount_parent_abs_path)
172175

173-
# TODO mountpoint checks ...
176+
self.__rm_tree__(self.mount_parent_abs_path)
174177

175-
umount_parent_status = umount(self.mount_parent_abs_path, sudo = True)
176-
assert umount_parent_status
177-
assert not is_path_mountpoint(self.mount_parent_abs_path)
178+
if self.travis:
179+
return
178180

179181
loop_device_list = find_loop_devices(self.image_abs_path)
180182
assert isinstance(loop_device_list, list)
@@ -295,3 +297,14 @@ def __mount_parent_fs__(self):
295297
mount_status = mount(self.mount_parent_abs_path, self.loop_device_path)
296298
assert mount_status
297299
assert is_path_mountpoint(self.mount_parent_abs_path)
300+
301+
302+
def __rm_tree__(self, in_path, in_fs_root = False):
303+
304+
if not in_fs_root:
305+
shutil.rmtree(in_path)
306+
else:
307+
rmdir_status = run_command(['rm', '-r', in_path], sudo = True)
308+
assert rmdir_status
309+
310+
assert not os.path.exists(in_path)

0 commit comments

Comments
 (0)