summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Husted <sigstop@gmail.com>2019-11-18 15:36:36 -0800
committerJustin Husted <sigstop@gmail.com>2019-11-18 15:36:36 -0800
commit780de81b36188b141e35519d80755a83bfe5ea0b (patch)
tree9276b6e66bcf38b9f705fd741cf88aa5855ef9ca
parent049dd7b79e94c0d4a9a290ff6c435401a22b5549 (diff)
Support remounting in fuse tests.
Signed-off-by: Justin Husted <sigstop@gmail.com>
-rw-r--r--tests/test_fuse.py7
-rw-r--r--tests/util.py19
2 files changed, 20 insertions, 6 deletions
diff --git a/tests/test_fuse.py b/tests/test_fuse.py
index da0a7a4..c7608f4 100644
--- a/tests/test_fuse.py
+++ b/tests/test_fuse.py
@@ -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()
diff --git a/tests/util.py b/tests/util.py
index d837615..fd8efd4 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -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)