summaryrefslogtreecommitdiff
path: root/tests/util.py
diff options
context:
space:
mode:
authorJustin Husted <sigstop@gmail.com>2019-11-18 13:51:31 -0800
committerJustin Husted <sigstop@gmail.com>2019-11-18 13:51:31 -0800
commit049dd7b79e94c0d4a9a290ff6c435401a22b5549 (patch)
treeac647e363cb1a0c39734f3c5aba5d43610624b4f /tests/util.py
parenta00998c4cdf834ebce00bedabd2804fe5376a63c (diff)
Make valgrind optional in tests.
Add an option to disable valgrind in the test suite, via the variable: BCACHEFS_TEST_USE_VALGRIND=no Additionally, note how to run tests in parallel in the INSTALL documentation. Signed-off-by: Justin Husted <sigstop@gmail.com>
Diffstat (limited to 'tests/util.py')
-rw-r--r--tests/util.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/util.py b/tests/util.py
index b6e05e3a..d8376158 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -16,6 +16,8 @@ BCH_PATH = DIR / 'bcachefs'
VPAT = re.compile(r'ERROR SUMMARY: (\d+) errors from (\d+) contexts')
+ENABLE_VALGRIND = os.getenv('BCACHEFS_TEST_USE_VALGRIND', 'yes') == 'yes'
+
class ValgrindFailedError(Exception):
def __init__(self, log):
self.log = log
@@ -37,6 +39,7 @@ def run(cmd, *args, valgrind=False, check=False):
ValgrindFailedError if there's a problem.
"""
cmds = [cmd] + list(args)
+ valgrind = valgrind and ENABLE_VALGRIND
if valgrind:
vout = tempfile.NamedTemporaryFile()
@@ -147,12 +150,17 @@ class BFuse(threading.Thread):
def run(self):
"""Background thread which runs "bcachefs fusemount" under valgrind"""
- vout = tempfile.NamedTemporaryFile()
- cmd = [ 'valgrind',
- '--leak-check=full',
- '--log-file={}'.format(vout.name),
- BCH_PATH,
- 'fusemount', '-f', self.dev, self.mnt]
+ vout = None
+ cmd = []
+
+ if ENABLE_VALGRIND:
+ vout = tempfile.NamedTemporaryFile()
+ cmd += [ 'valgrind',
+ '--leak-check=full',
+ '--log-file={}'.format(vout.name) ]
+
+ cmd += [ BCH_PATH,
+ 'fusemount', '-f', self.dev, self.mnt]
print("Running {}".format(cmd))
@@ -203,7 +211,8 @@ class BFuse(threading.Thread):
self.proc.kill()
self.join()
- check_valgrind(self.vout)
+ if self.vout:
+ check_valgrind(self.vout)
def verify(self):
assert self.returncode == 0