summaryrefslogtreecommitdiff
path: root/check.py
diff options
context:
space:
mode:
Diffstat (limited to 'check.py')
-rwxr-xr-xcheck.py56
1 files changed, 45 insertions, 11 deletions
diff --git a/check.py b/check.py
index 744042393..a8bd65bb4 100755
--- a/check.py
+++ b/check.py
@@ -146,7 +146,7 @@ if not interpreter:
if not has_node:
warn('no node found (did not check proper js form)')
if not has_mozjs:
- warn('no mozjs found (did not check asm.js validation)')
+ warn('no mozjs found (did not check native wasm support nor asm.js validation)')
if not has_emcc:
warn('no emcc found (did not check non-vanilla emscripten/binaryen integration)')
if not has_vanilla_emcc:
@@ -566,9 +566,27 @@ if actual != expected:
if has_emcc:
+ if has_mozjs:
+
+ print '\n[ checking native wasm support ]\n'
+
+ command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN=1', os.path.join('test', 'hello_world.c'), '-s', 'BINARYEN_METHOD="native-wasm"', '-s', 'BINARYEN_SCRIPTS="spidermonkify.py"']
+ print ' '.join(command)
+ subprocess.check_call(command)
+
+ proc = subprocess.Popen(['mozjs', 'a.wasm.js'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = proc.communicate()
+ assert proc.returncode == 0, err
+ assert 'hello, world!' in out, out
+
+ proc = subprocess.Popen([has_node, 'a.wasm.js'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = proc.communicate()
+ assert proc.returncode != 0, 'should fail on no wasm support'
+ assert 'no native wasm support detected' in err, err
+
print '\n[ checking wasm.js methods... ]\n'
- for method_init in [None, 'asm2wasm', 'wasm-s-parser', 'just-asm']:
+ for method_init in [None, 'asm2wasm', 'wasm-s-parser', 'just-asm', 'wasm-binary']:
for success in [1, 0]:
method = method_init
command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN=1', os.path.join('test', 'hello_world.c') ]
@@ -580,7 +598,7 @@ if has_emcc:
subprocess.check_call(command)
see_polyfill = 'var WasmJS = ' in open('a.wasm.js').read()
- if method and 'asm2wasm' not in method and 'wasm-s-parser' not in method:
+ if method and 'asm2wasm' not in method and 'wasm-s-parser' not in method and 'wasm-binary' not in method:
assert not see_polyfill, 'verify polyfill was not added - we specified a method, and it does not need it'
else:
assert see_polyfill, 'we need the polyfill'
@@ -603,6 +621,11 @@ if has_emcc:
break_cashew() # we don't use cashew, so ok to break it
if not success:
os.unlink('a.wasm.js')
+ elif method == 'wasm-binary':
+ os.unlink('a.wasm.wast') # we should not need the .wast
+ os.unlink('a.wasm.asm.js') # we should not need the .asm.js
+ if not success:
+ os.unlink('a.wasm.wasm')
else:
1/0
if has_node:
@@ -633,11 +656,11 @@ if has_emcc:
extra = json.loads(open(emcc).read())
if os.path.exists('a.normal.js'): os.unlink('a.normal.js')
for opts in [[], ['-O1'], ['-O2'], ['-O3'], ['-Oz']]:
- for method in ['asm2wasm', 'wasm-s-parser', 'just-asm']:
+ for method in ['asm2wasm', 'wasm-s-parser', 'just-asm', 'wasm-binary']:
command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN=1', os.path.join('test', c)] + opts + extra
command += ['-s', 'BINARYEN_METHOD="' + method + '"']
- subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print '....' + ' '.join(command)
+ subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if post:
open('a.wasm.js', 'a').write(post)
else:
@@ -649,12 +672,23 @@ if has_emcc:
except:
args = []
print ' (no args)'
- if has_node:
- proc = subprocess.Popen([has_node, 'a.' + which + '.js'] + args, stdout=subprocess.PIPE)
- out, err = proc.communicate()
- assert proc.returncode == 0
- if out.strip() != expected.strip():
- fail(out, expected)
+
+ def execute():
+ if has_node:
+ proc = subprocess.Popen([has_node, 'a.' + which + '.js'] + args, stdout=subprocess.PIPE)
+ out, err = proc.communicate()
+ assert proc.returncode == 0
+ if out.strip() != expected.strip():
+ fail(out, expected)
+
+ execute()
+
+ if method in ['asm2wasm', 'wasm-s-parser']:
+ # binary and back
+ shutil.copyfile('a.wasm.wast', 'a.wasm.original.wast')
+ recreated = binary_format_check('a.wasm.wast', verify_final_result=False)
+ shutil.copyfile(recreated, 'a.wasm.wast')
+ execute()
print '\n[ success! ]'