Skip to content

Commit 05f486b

Browse files
committed
Testsuite: add a mode to run tests under Valgrind
TN: W112-021
1 parent 49fb5ee commit 05f486b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

testsuite/testsuite.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
from e3.testsuite.driver.diff import DiffTestDriver
77

88

9+
def valgrind_wrap(driver, argv):
10+
"""
11+
When running the testsuite in valgrind mode, wrap the given command line
12+
arguments so that the program is run under Valgrind. Return them unchanged
13+
otherwise.
14+
"""
15+
result = list(argv)
16+
if driver.env.options.valgrind:
17+
result = ["valgrind", "-q", "--leak-check=full"] + result
18+
return result
19+
20+
921
class CompileAndRunDriver(DiffTestDriver):
1022
"""Driver"""
1123
def run(self):
@@ -23,7 +35,7 @@ def run(self):
2335
if exec_args:
2436
self.output += "[" + " ".join(exec_args) + "]\n"
2537
run_command = ["./" + executable] + exec_args
26-
self.shell(run_command, analyze_output=True)
38+
self.shell(valgrind_wrap(self, run_command), analyze_output=True)
2739

2840

2941
class AdaSATTestsuite(Testsuite):
@@ -36,6 +48,10 @@ def add_options(self, parser):
3648
"--rewrite", action="store_true",
3749
help="Rewrite test baselines according to current outputs"
3850
)
51+
parser.add_argument(
52+
"--valgrind", action="store_true",
53+
help="Run tests within Valgrind to check memory issues."
54+
)
3955

4056
def set_up(self):
4157
super(AdaSATTestsuite, self).set_up()

0 commit comments

Comments
 (0)