summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Husted <sigstop@gmail.com>2019-12-28 16:56:24 -0800
committerJustin Husted <sigstop@gmail.com>2019-12-28 16:57:15 -0800
commit1b74a2bba1486be1dd44f5955744ea58e056f259 (patch)
tree6c547903f5178e898fe770d8716b9d4b04491024
parentff2b85e039b2dc164477c1ac57844a6f456526aa (diff)
bcachefs-tools: fix test bug in valgrind handling.
Signed-off-by: Justin Husted <sigstop@gmail.com>
-rw-r--r--tests/util.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/util.py b/tests/util.py
index c96f2eeb..c4d74310 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -22,10 +22,14 @@ class ValgrindFailedError(Exception):
def __init__(self, log):
self.log = log
-def check_valgrind(logfile):
- log = logfile.read().decode('utf-8')
+def check_valgrind(log):
m = VPAT.search(log)
- assert m is not None, 'Internal error: valgrind log did not match.'
+ if m is None:
+ print('Internal error: valgrind log did not match.')
+ print('-- valgrind log:')
+ print(log)
+ print('-- end log --')
+ assert False
errors = int(m.group(1))
if errors > 0:
@@ -53,7 +57,7 @@ def run(cmd, *args, valgrind=False, check=False):
encoding='utf-8', check=check)
if valgrind:
- check_valgrind(vout)
+ check_valgrind(vout.read().decode('utf-8'))
return res
@@ -150,14 +154,14 @@ class BFuse:
def run(self):
"""Background thread which runs "bcachefs fusemount" under valgrind"""
- vout = None
+ vlog = None
cmd = []
if ENABLE_VALGRIND:
- vout = tempfile.NamedTemporaryFile()
+ vlog = tempfile.NamedTemporaryFile()
cmd += [ 'valgrind',
'--leak-check=full',
- '--log-file={}'.format(vout.name) ]
+ '--log-file={}'.format(vlog.name) ]
cmd += [ BCH_PATH,
'fusemount', '-f', self.dev, self.mnt]
@@ -178,7 +182,7 @@ class BFuse:
self.stdout = out1 + out2
self.stderr = err.read()
self.returncode = self.proc.returncode
- self.vout = vout
+ self.vout = vlog.read().decode('utf-8')
def expect(self, pipe, regex):
"""Wait for the child process to mount."""
@@ -208,13 +212,15 @@ class BFuse:
def unmount(self, timeout=None):
print("Unmounting fuse.")
run("fusermount3", "-zu", self.mnt)
- print("Waiting for thread to exit.")
if self.thread:
+ print("Waiting for thread to exit.")
self.thread.join(timeout)
if self.thread.is_alive():
self.proc.kill()
self.thread.join()
+ else:
+ print("Thread was already done.")
self.thread = None
self.ready.clear()