@@ -136,9 +136,10 @@ def do_other_test(self, dirname, emcc_args=[], run_args=[]):
136136 seen = run_js ('a.out.js' , args = run_args , stderr = PIPE , full_output = True ) + '\n '
137137 self .assertContained (expected , seen )
138138
139- def do_smart_test (self , source , literals = [], regexes = [], emcc_args = [], run_args = [], assert_returncode = 0 ):
140- shutil .copyfile (source , 'test.cpp' )
141- run_process ([PYTHON , EMCC , 'test.cpp' ] + emcc_args )
139+ def do_smart_test (self , source , name = 'test.cpp' , literals = [], regexes = [],
140+ emcc_args = [], run_args = [], assert_returncode = 0 ):
141+ shutil .copyfile (source , name )
142+ run_process ([PYTHON , EMCC , name ] + emcc_args )
142143 seen = run_js ('a.out.js' , args = run_args , stderr = PIPE , full_output = True ,
143144 assert_returncode = assert_returncode ) + '\n '
144145
@@ -9249,34 +9250,52 @@ def test(code):
92499250 # both is a little bigger still
92509251 assert both - 100 <= lf <= both - 50
92519252
9253+ @parameterized ({
9254+ 'c' : ['c' ],
9255+ 'cpp' : ['cpp' ],
9256+ })
92529257 @no_fastcomp ('lsan not supported on fastcomp' )
9253- def test_lsan_leaks (self ):
9254- self .do_smart_test (path_from_root ('tests' , 'other' , 'test_lsan_leaks.c' ),
9258+ def test_lsan_leaks (self , ext ):
9259+ self .do_smart_test (path_from_root ('tests' , 'other' , 'test_lsan_leaks.' + ext ),
92559260 emcc_args = ['-fsanitize=leak' , '-s' , 'ALLOW_MEMORY_GROWTH=1' ],
9256- assert_returncode = None , literals = [
9261+ name = 'test.' + ext , assert_returncode = None , literals = [
92579262 'Direct leak of 2048 byte(s) in 1 object(s) allocated from' ,
92589263 'Direct leak of 1337 byte(s) in 1 object(s) allocated from' ,
92599264 'Direct leak of 42 byte(s) in 1 object(s) allocated from' ,
92609265 ])
92619266
9267+ @parameterized ({
9268+ 'c' : ['c' , [
9269+ r'in malloc.*wasm-function' ,
9270+ r'(?m)in f /.*/test\.c:6:21$' ,
9271+ r'(?m)in main /.*/test\.c:10:16$' ,
9272+ r'(?m)in main /.*/test\.c:12:3$' ,
9273+ r'(?m)in main /.*/test\.c:13:3$' ,
9274+ ]],
9275+ 'cpp' : ['cpp' , [
9276+ r'in operator new\[\]\(unsigned long\).*wasm-function' ,
9277+ r'(?m)in f\(\) /.*/test\.cpp:4:21$' ,
9278+ r'(?m)in main /.*/test\.cpp:8:16$' ,
9279+ r'(?m)in main /.*/test\.cpp:10:3$' ,
9280+ r'(?m)in main /.*/test\.cpp:11:3$' ,
9281+ ]],
9282+ })
92629283 @no_fastcomp ('lsan not supported on fastcomp' )
9263- def test_lsan_stack_trace (self ):
9264- self .do_smart_test (path_from_root ('tests' , 'other' , 'test_lsan_leaks.c' ),
9284+ def test_lsan_stack_trace (self , ext , regexes ):
9285+ self .do_smart_test (path_from_root ('tests' , 'other' , 'test_lsan_leaks.' + ext ),
92659286 emcc_args = ['-fsanitize=leak' , '-s' , 'ALLOW_MEMORY_GROWTH=1' , '-g4' ],
9266- assert_returncode = None , literals = [
9287+ name = 'test.' + ext , assert_returncode = None , literals = [
92679288 'Direct leak of 2048 byte(s) in 1 object(s) allocated from' ,
92689289 'Direct leak of 1337 byte(s) in 1 object(s) allocated from' ,
92699290 'Direct leak of 42 byte(s) in 1 object(s) allocated from' ,
9270- ], regexes = [
9271- r'(?m)in malloc.*wasm-function' ,
9272- r'(?m)in f\(\) /.*/test\.cpp:6:21$' ,
9273- r'(?m)in main /.*/test\.cpp:10:16$' ,
9274- r'(?m)in main /.*/test\.cpp:12:3$' ,
9275- r'(?m)in main /.*/test\.cpp:13:3$' ,
9276- ])
9291+ ], regexes = regexes )
92779292
9293+ @parameterized ({
9294+ 'c' : ['c' ],
9295+ 'cpp' : ['cpp' ],
9296+ })
92789297 @no_fastcomp ('lsan not supported on fastcomp' )
9279- def test_lsan_no_leak (self ):
9280- self .do_smart_test (path_from_root ('tests' , 'other' , 'test_lsan_no_leak.c' ),
9298+ def test_lsan_no_leak (self , ext ):
9299+ self .do_smart_test (path_from_root ('tests' , 'other' , 'test_lsan_no_leak.' + ext ),
92819300 emcc_args = ['-fsanitize=leak' , '-s' , 'ALLOW_MEMORY_GROWTH=1' ],
9282- regexes = [r'^\s*$' ])
9301+ name = 'test.' + ext , regexes = [r'^\s*$' ])
0 commit comments