summaryrefslogtreecommitdiff
path: root/scripts/test
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@users.noreply.github.com>2018-02-07 14:36:56 -0800
committerGitHub <noreply@github.com>2018-02-07 14:36:56 -0800
commit7c4fe0bc095e067c8605f60a66664bd58bac3ac5 (patch)
treef61db693f26815c2766d957721b051974154a59d /scripts/test
parenta3232460dd4dc63b0ed39a68f0bebecc805572d4 (diff)
downloadbinaryen-7c4fe0bc095e067c8605f60a66664bd58bac3ac5.tar.gz
binaryen-7c4fe0bc095e067c8605f60a66664bd58bac3ac5.tar.bz2
binaryen-7c4fe0bc095e067c8605f60a66664bd58bac3ac5.zip
Emscripten addFunction support for Wasm backend (#1395)
This adds necessary command line options for addFunction support, and generates required jsCall imports and generates jsCall thunk functions.
Diffstat (limited to 'scripts/test')
-rwxr-xr-xscripts/test/lld.py55
-rwxr-xr-xscripts/test/s2wasm.py1
2 files changed, 37 insertions, 19 deletions
diff --git a/scripts/test/lld.py b/scripts/test/lld.py
index 793031ca6..85159ba3a 100755
--- a/scripts/test/lld.py
+++ b/scripts/test/lld.py
@@ -25,36 +25,53 @@ from shared import (
def test_wasm_link_metadata():
print '\n[ checking wasm-link-metadata testcases... ]\n'
+ extension_arg_map = {
+ '.json': [],
+ '.jscall.json': ['--emscripten-reserved-function-pointers=3'],
+ }
+
for obj_path in files_with_pattern(options.binaryen_test, 'lld', '*.o'):
print '..', obj_path
- expected_file = obj_path.replace('.o', '.json')
+ for ext, ext_args in extension_arg_map.items():
+ expected_file = obj_path.replace('.o', ext)
+ if ext != '.json' and not os.path.exists(expected_file):
+ continue
- cmd = WASM_LINK_METADATA + [obj_path]
- actual = run_command(cmd)
+ cmd = WASM_LINK_METADATA + [obj_path] + ext_args
+ actual = run_command(cmd)
- 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)
+ 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)
def test_wasm_emscripten_finalize():
print '\n[ checking wasm-emscripten-finalize testcases... ]\n'
+ extension_arg_map = {
+ '.out': [],
+ '.jscall.out': ['--emscripten-reserved-function-pointers=3'],
+ }
+
for wast_path in files_with_pattern(options.binaryen_test, 'lld', '*.wast'):
print '..', wast_path
- expected_file = wast_path + '.out'
- cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S']
- actual = run_command(cmd)
-
- 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)
+ for ext, ext_args in extension_arg_map.items():
+ expected_file = wast_path + ext
+ if ext != '.out' and not os.path.exists(expected_file):
+ continue
+
+ cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + ext_args
+ actual = run_command(cmd)
+
+ 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)
if __name__ == '__main__':
diff --git a/scripts/test/s2wasm.py b/scripts/test/s2wasm.py
index 405ed5fdf..a3345f87b 100755
--- a/scripts/test/s2wasm.py
+++ b/scripts/test/s2wasm.py
@@ -36,6 +36,7 @@ def test_s2wasm():
'.wast': [],
'.clamp.wast': ['--trap-mode=clamp'],
'.js.wast': ['--trap-mode=js'],
+ '.jscall.wast': ['--emscripten-reserved-function-pointers=3'],
}
for dot_s_dir in ['dot_s', 'llvm_autogenerated']:
dot_s_path = os.path.join(options.binaryen_test, dot_s_dir)