From 780de81b36188b141e35519d80755a83bfe5ea0b Mon Sep 17 00:00:00 2001 From: Justin Husted Date: Mon, 18 Nov 2019 15:36:36 -0800 Subject: [PATCH] Support remounting in fuse tests. Signed-off-by: Justin Husted --- tests/test_fuse.py | 7 +++++++ tests/util.py | 19 +++++++++++++------ 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) -- 2.39.2