]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Support remounting in fuse tests.
authorJustin Husted <sigstop@gmail.com>
Mon, 18 Nov 2019 23:36:36 +0000 (15:36 -0800)
committerJustin Husted <sigstop@gmail.com>
Mon, 18 Nov 2019 23:36:36 +0000 (15:36 -0800)
Signed-off-by: Justin Husted <sigstop@gmail.com>
tests/test_fuse.py
tests/util.py

index da0a7a42f59bd260a10503d6afdc2c0a7ced8086..c7608f4c85dbb6e098723cc99a078cae6c9af595 100644 (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()
 
index d8376158a038bd4746e77160c42fc0e0c7cf486a..fd8efd4750082e2ffb539068ce53cb889f1bf377 100644 (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)