@@ -30,41 +30,43 @@ def args_for_finalize(filename):
3030 return ret
3131
3232
33+ def run_test (input_path ):
34+ print ('..' , input_path )
35+ is_passive = '.passive.' in input_path
36+ mem_file = input_path + '.mem'
37+ extension_arg_map = {
38+ '.out' : [],
39+ }
40+ if not is_passive :
41+ extension_arg_map .update ({
42+ '.mem.out' : ['--separate-data-segments' , mem_file ],
43+ })
44+ for ext , args in extension_arg_map .items ():
45+ expected_file = input_path + ext
46+ if ext != '.out' and not os .path .exists (expected_file ):
47+ continue
48+
49+ cmd = shared .WASM_EMSCRIPTEN_FINALIZE + [input_path , '-S' ] + args
50+ cmd += args_for_finalize (os .path .basename (input_path ))
51+ actual = support .run_command (cmd )
52+
53+ if not os .path .exists (expected_file ):
54+ print (actual )
55+ shared .fail_with_error ('output ' + expected_file +
56+ ' does not exist' )
57+ shared .fail_if_not_identical_to_file (actual , expected_file )
58+ if ext == '.mem.out' :
59+ with open (mem_file ) as mf :
60+ mem = mf .read ()
61+ shared .fail_if_not_identical_to_file (mem , input_path + '.mem.mem' )
62+ os .remove (mem_file )
63+
64+
3365def test_wasm_emscripten_finalize ():
3466 print ('\n [ checking wasm-emscripten-finalize testcases... ]\n ' )
3567
3668 for input_path in shared .get_tests (shared .get_test_dir ('lld' ), ['.wat' , '.wasm' ]):
37- print ('..' , input_path )
38- is_passive = '.passive.' in input_path
39- mem_file = input_path + '.mem'
40- extension_arg_map = {
41- '.out' : [],
42- }
43- if not is_passive :
44- extension_arg_map .update ({
45- '.mem.out' : ['--separate-data-segments' , mem_file ],
46- })
47- for ext , ext_args in extension_arg_map .items ():
48- expected_file = input_path + ext
49- if ext != '.out' and not os .path .exists (expected_file ):
50- continue
51-
52- cmd = shared .WASM_EMSCRIPTEN_FINALIZE + [input_path , '-S' ] + \
53- ext_args
54- cmd += args_for_finalize (os .path .basename (input_path ))
55- actual = support .run_command (cmd )
56-
57- if not os .path .exists (expected_file ):
58- print (actual )
59- shared .fail_with_error ('output ' + expected_file +
60- ' does not exist' )
61- shared .fail_if_not_identical_to_file (actual , expected_file )
62- if ext == '.mem.out' :
63- with open (mem_file ) as mf :
64- mem = mf .read ()
65- shared .fail_if_not_identical_to_file (mem , input_path +
66- '.mem.mem' )
67- os .remove (mem_file )
69+ run_test (input_path )
6870
6971
7072def update_lld_tests ():
0 commit comments