summaryrefslogtreecommitdiff
path: root/scripts/test/shared.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/test/shared.py')
-rw-r--r--scripts/test/shared.py41
1 files changed, 39 insertions, 2 deletions
diff --git a/scripts/test/shared.py b/scripts/test/shared.py
index 9352f0b9d..37874e61e 100644
--- a/scripts/test/shared.py
+++ b/scripts/test/shared.py
@@ -157,6 +157,7 @@ NATIVEXX = (os.environ.get('CXX') or which('mingw32-g++') or
which('g++') or which('clang++'))
NODEJS = os.getenv('NODE', which('nodejs') or which('node'))
MOZJS = which('mozjs') or which('spidermonkey')
+V8 = which('v8') or which('d8')
EMCC = which('emcc')
BINARYEN_INSTALL_DIR = os.path.dirname(options.binaryen_bin)
@@ -190,7 +191,13 @@ if options.valgrind:
ASM2WASM = wrap_with_valgrind(ASM2WASM)
WASM_SHELL = wrap_with_valgrind(WASM_SHELL)
-os.environ['BINARYEN'] = os.getcwd()
+
+def in_binaryen(*args):
+ __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
+ return os.path.join(__rootpath__, *args)
+
+
+os.environ['BINARYEN'] = in_binaryen()
def get_platform():
@@ -204,6 +211,19 @@ def has_shell_timeout():
return get_platform() != 'windows' and os.system('timeout 1s pwd') == 0
+# Default options to pass to v8. These enable all features.
+V8_OPTS = [
+ '--experimental-wasm-eh',
+ '--experimental-wasm-mv',
+ '--experimental-wasm-sat-f2i-conversions',
+ '--experimental-wasm-se',
+ '--experimental-wasm-threads',
+ '--experimental-wasm-simd',
+ '--experimental-wasm-anyref',
+ '--experimental-wasm-bulk-memory',
+ '--experimental-wasm-return-call'
+]
+
has_vanilla_llvm = False
# external tools
@@ -377,8 +397,18 @@ if not has_vanilla_emcc:
# check utilities
+
+def validate_binary(wasm):
+ if V8:
+ cmd = [V8] + V8_OPTS + [in_binaryen('scripts', 'validation_shell.js'), '--', wasm]
+ print ' ', ' '.join(cmd)
+ subprocess.check_call(cmd, stdout=subprocess.PIPE)
+ else:
+ print '(skipping v8 binary validation)'
+
+
def binary_format_check(wast, verify_final_result=True, wasm_as_args=['-g'],
- binary_suffix='.fromBinary'):
+ binary_suffix='.fromBinary', original_wast=None):
# checks we can convert the wast to binary and back
print ' (binary format check)'
@@ -389,6 +419,13 @@ def binary_format_check(wast, verify_final_result=True, wasm_as_args=['-g'],
subprocess.check_call(cmd, stdout=subprocess.PIPE)
assert os.path.exists('a.wasm')
+ # make sure it is a valid wasm, using a real wasm VM
+ if os.path.basename(original_wast or wast) not in [
+ 'atomics.wast', # https://bugs.chromium.org/p/v8/issues/detail?id=9425
+ 'simd.wast', # https://bugs.chromium.org/p/v8/issues/detail?id=8460
+ ]:
+ validate_binary('a.wasm')
+
cmd = WASM_DIS + ['a.wasm', '-o', 'ab.wast']
print ' ', ' '.join(cmd)
if os.path.exists('ab.wast'):