66from 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+
921class 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
2941class 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