diff options
Diffstat (limited to 'scripts/test/s2wasm.py')
-rwxr-xr-x | scripts/test/s2wasm.py | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/scripts/test/s2wasm.py b/scripts/test/s2wasm.py index 3f38acbac..fcba17d18 100755 --- a/scripts/test/s2wasm.py +++ b/scripts/test/s2wasm.py @@ -32,38 +32,48 @@ def test_s2wasm(): fail_if_not_contained( output, '(import "env" "memory" (memory $0 1))') + extension_arg_map = { + '.wast': [], + '.clamp.wast': ['--emit-clamped-potential-traps'], + '.js.wast': ['--emit-jsified-potential-traps'], + } for dot_s_dir in ['dot_s', 'llvm_autogenerated']: dot_s_path = os.path.join(options.binaryen_test, dot_s_dir) for s in sorted(os.listdir(dot_s_path)): if not s.endswith('.s'): continue print '..', s - wasm = s.replace('.s', '.wast') - full = os.path.join(options.binaryen_test, dot_s_dir, s) - stack_alloc = (['--allocate-stack=1024'] - if dot_s_dir == 'llvm_autogenerated' - else []) - cmd = S2WASM + [full, '--emscripten-glue'] + stack_alloc - if s.startswith('start_'): - cmd.append('--start') - actual = run_command(cmd) - - # verify output - expected_file = os.path.join(options.binaryen_test, dot_s_dir, wasm) - if not os.path.exists(expected_file): - print actual - fail_with_error('output ' + expected_file + ' does not exist') - expected = open(expected_file, 'rb').read() - if actual != expected: - fail(actual, expected) - - # verify with options - cmd = S2WASM + [full, '--global-base=1024'] + stack_alloc - run_command(cmd) - - # run wasm-shell on the .wast to verify that it parses - cmd = WASM_SHELL + [expected_file] - run_command(cmd) + for ext, ext_args in extension_arg_map.iteritems(): + wasm = s.replace('.s', ext) + expected_file = os.path.join(options.binaryen_test, dot_s_dir, wasm) + expected_exists = os.path.exists(expected_file) + if ext != '.wast' and not expected_exists: + continue + + full = os.path.join(options.binaryen_test, dot_s_dir, s) + stack_alloc = (['--allocate-stack=1024'] + if dot_s_dir == 'llvm_autogenerated' + else []) + cmd = S2WASM + [full, '--emscripten-glue'] + stack_alloc + ext_args + if s.startswith('start_'): + cmd.append('--start') + actual = run_command(cmd) + + # verify output + if not expected_exists: + print actual + fail_with_error('output ' + expected_file + ' does not exist') + expected = open(expected_file, 'rb').read() + if actual != expected: + fail(actual, expected) + + # verify with options + cmd = S2WASM + [full, '--global-base=1024'] + stack_alloc + run_command(cmd) + + # run wasm-shell on the .wast to verify that it parses + cmd = WASM_SHELL + [expected_file] + run_command(cmd) def test_linker(): |