Support remounting in fuse tests.

Signed-off-by: Justin Husted <sigstop@gmail.com>
This commit is contained in:
Justin Husted 2019-11-18 15:36:36 -08:00
parent 049dd7b79e
commit 780de81b36
2 changed files with 20 additions and 6 deletions

View File

@ -14,6 +14,13 @@ def test_mount(bfuse):
bfuse.unmount()
bfuse.verify()
def test_remount(bfuse):
bfuse.mount()
bfuse.unmount()
bfuse.mount()
bfuse.unmount()
bfuse.verify()
def test_lostfound(bfuse):
bfuse.mount()

View File

@ -127,7 +127,7 @@ class FuseError(Exception):
def __init__(self, msg):
self.msg = msg
class BFuse(threading.Thread):
class BFuse:
'''bcachefs fuse runner.
This class runs bcachefs in fusemount mode, and waits until the mount has
@ -137,7 +137,7 @@ class BFuse(threading.Thread):
'''
def __init__(self, dev, mnt):
threading.Thread.__init__(self)
self.thread = None
self.dev = dev
self.mnt = mnt
self.ready = threading.Event()
@ -197,7 +197,11 @@ class BFuse(threading.Thread):
def mount(self):
print("Starting fuse thread.")
self.start()
assert not self.thread
self.thread = threading.Thread(target=self.run)
self.thread.start()
self.ready.wait()
print("Fuse is mounted.")
@ -206,10 +210,13 @@ class BFuse(threading.Thread):
run("fusermount3", "-zu", self.mnt)
print("Waiting for thread to exit.")
self.join(timeout)
if self.isAlive():
self.thread.join(timeout)
if self.thread.is_alive():
self.proc.kill()
self.join()
self.thread.join()
self.thread = None
self.ready.clear()
if self.vout:
check_valgrind(self.vout)