diff options
Diffstat (limited to 'scripts/test')
-rwxr-xr-x | scripts/test/generate_lld_tests.py | 13 | ||||
-rwxr-xr-x | scripts/test/lld.py | 21 | ||||
-rwxr-xr-x | scripts/test/wasm2js.py | 46 |
3 files changed, 73 insertions, 7 deletions
diff --git a/scripts/test/generate_lld_tests.py b/scripts/test/generate_lld_tests.py index 4b18107e1..f3905b077 100755 --- a/scripts/test/generate_lld_tests.py +++ b/scripts/test/generate_lld_tests.py @@ -27,7 +27,7 @@ def files_with_extensions(path, extensions): yield file, ext -def generate_wast_files(clang_bin, lld_bin, emscripten_root): +def generate_wast_files(llvm_bin, emscripten_root): print '\n[ building wast files from C sources... ]\n' lld_path = os.path.join(shared.options.binaryen_test, 'lld') @@ -39,7 +39,7 @@ def generate_wast_files(clang_bin, lld_bin, emscripten_root): src_path = os.path.join(lld_path, src_file) obj_path = os.path.join(lld_path, obj_file) run_command([ - clang_bin, src_path, '-o', obj_path, + os.path.join(llvm_bin, 'clang'), src_path, '-o', obj_path, '--target=wasm32-unknown-unknown-wasm', '-c', '-nostdinc', @@ -56,7 +56,7 @@ def generate_wast_files(clang_bin, lld_bin, emscripten_root): wasm_path = os.path.join(lld_path, wasm_file) wast_path = os.path.join(lld_path, wast_file) run_command([ - lld_bin, '-flavor', 'wasm', + os.path.join(llvm_bin, 'wasm-ld'), '-z', '-stack-size=1048576', obj_path, '-o', wasm_path, '--entry=main', @@ -72,8 +72,7 @@ def generate_wast_files(clang_bin, lld_bin, emscripten_root): if __name__ == '__main__': - if len(sys.argv) != 4: - print 'Usage: generate_lld_tests.py [path/to/clang] [path/to/lld] \ -[path/to/emscripten]' + if len(shared.options.positional_args) != 2: + print 'Usage: generate_lld_tests.py [llvm/bin/dir] [path/to/emscripten]' sys.exit(1) - generate_wast_files(*sys.argv[1:]) + generate_wast_files(*shared.options.positional_args) diff --git a/scripts/test/lld.py b/scripts/test/lld.py index 94736f03f..a96062331 100755 --- a/scripts/test/lld.py +++ b/scripts/test/lld.py @@ -51,5 +51,26 @@ def test_wasm_emscripten_finalize(): os.remove(mem_file) +def update_lld_tests(): + print '\n[ updatring wasm-emscripten-finalize testcases... ]\n' + + for wast_path in files_with_pattern(options.binaryen_test, 'lld', '*.wast'): + print '..', wast_path + mem_file = wast_path + '.mem' + extension_arg_map = { + '.out': [], + '.mem.out': ['--separate-data-segments', mem_file + '.mem'], + } + for ext, ext_args in extension_arg_map.items(): + out_path = wast_path + ext + if ext != '.out' and not os.path.exists(out_path): + continue + cmd = (WASM_EMSCRIPTEN_FINALIZE + + [wast_path, '-S', '--global-base=568', '--initial-stack-pointer=16384'] + ext_args) + actual = run_command(cmd) + with open(out_path, 'w') as o: + o.write(actual) + + if __name__ == '__main__': test_wasm_emscripten_finalize() diff --git a/scripts/test/wasm2js.py b/scripts/test/wasm2js.py index 9a72895c1..afa399da2 100755 --- a/scripts/test/wasm2js.py +++ b/scripts/test/wasm2js.py @@ -106,5 +106,51 @@ def test_wasm2js(): test_asserts_output() +def update_wasm2js_tests(): + print '\n[ checking wasm2js ]\n' + + for wasm in tests + spec_tests + extra_wasm2js_tests: + if not wasm.endswith('.wast'): + continue + + if os.path.basename(wasm) in wasm2js_blacklist: + continue + + asm = os.path.basename(wasm).replace('.wast', '.2asm.js') + expected_file = os.path.join(wasm2js_dir, asm) + + # we run wasm2js on tests and spec tests only if the output + # exists - only some work so far. the tests in extra are in + # the test/wasm2js dir and so are specific to wasm2js, and + # we run all of those. + if wasm not in extra_wasm2js_tests and not os.path.exists(expected_file): + continue + + print '..', wasm + + cmd = WASM2JS + [os.path.join('test', wasm)] + out = run_command(cmd) + with open(expected_file, 'w') as o: + o.write(out) + + for wasm in assert_tests: + print '..', wasm + + asserts = os.path.basename(wasm).replace('.wast.asserts', '.asserts.js') + traps = os.path.basename(wasm).replace('.wast.asserts', '.traps.js') + asserts_expected_file = os.path.join('test', asserts) + traps_expected_file = os.path.join('test', traps) + + cmd = WASM2JS + [os.path.join(wasm2js_dir, wasm), '--allow-asserts'] + out = run_command(cmd) + with open(asserts_expected_file, 'w') as o: + o.write(out) + + cmd += ['--pedantic'] + out = run_command(cmd) + with open(traps_expected_file, 'w') as o: + o.write(out) + + if __name__ == "__main__": test_wasm2js() |