summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rwxr-xr-xcheck.py7
-rw-r--r--scripts/fuzz_opt.py14
-rw-r--r--scripts/test/shared.py41
-rw-r--r--scripts/validation_shell.js28
-rw-r--r--test/badvartype.wasmbin698 -> 0 bytes
-rw-r--r--test/badvartype.wasm.fromBinary344
7 files changed, 74 insertions, 362 deletions
diff --git a/.travis.yml b/.travis.yml
index bf46930a9..3328c0071 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -55,7 +55,7 @@ jobs:
# get jsvu in order to get more js engines
- npm install jsvu -g
- export PATH="${HOME}/.jsvu:${PATH}"
- - jsvu --os=linux64 --engines=spidermonkey
+ - jsvu --os=linux64 --engines=spidermonkey,v8
script:
- set -o errexit
- flake8
diff --git a/check.py b/check.py
index 2eec850cf..7f0e07787 100755
--- a/check.py
+++ b/check.py
@@ -27,7 +27,8 @@ from scripts.test.shared import (
binary_format_check, delete_from_orbit, fail, fail_with_error,
fail_if_not_identical, fail_if_not_contained, has_vanilla_emcc,
has_vanilla_llvm, minify_check, options, tests, requested, warnings,
- has_shell_timeout, fail_if_not_identical_to_file, with_pass_debug
+ has_shell_timeout, fail_if_not_identical_to_file, with_pass_debug,
+ validate_binary
)
# For shared.num_failures. Cannot import directly because modifications made in
@@ -189,6 +190,8 @@ def run_wasm_dis_tests():
with_pass_debug(check)
+ validate_binary(t)
+
def run_crash_tests():
print "\n[ checking we don't crash on tricky inputs... ]\n"
@@ -380,7 +383,7 @@ def run_spec_tests():
o.write(module + '\n' + '\n'.join(asserts))
run_spec_test('split.wast') # before binary stuff - just check it's still ok split out
run_opt_test('split.wast') # also that our optimizer doesn't break on it
- result_wast = binary_format_check('split.wast', verify_final_result=False)
+ result_wast = binary_format_check('split.wast', verify_final_result=False, original_wast=wast)
# add the asserts, and verify that the test still passes
open(result_wast, 'a').write('\n' + '\n'.join(asserts))
actual += run_spec_test(result_wast)
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index bea4635ac..ead591317 100644
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -21,7 +21,7 @@ import re
import shutil
import time
-from test.shared import options, NODEJS
+from test.shared import options, NODEJS, V8_OPTS
# parameters
@@ -32,18 +32,6 @@ FEATURE_OPTS = [] # '--all-features' etc
FUZZ_OPTS = []
-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'
-]
-
INPUT_SIZE_LIMIT = 150 * 1024
LOG_LIMIT = 125
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'):
diff --git a/scripts/validation_shell.js b/scripts/validation_shell.js
new file mode 100644
index 000000000..3d1f76846
--- /dev/null
+++ b/scripts/validation_shell.js
@@ -0,0 +1,28 @@
+// Test a file is valid, by just loading it.
+
+// Shell integration.
+if (typeof console === 'undefined') {
+ console = { log: print };
+}
+var binary;
+if (typeof process === 'object' && typeof require === 'function' /* node.js detection */) {
+ var args = process.argv.slice(2);
+ binary = require('fs').readFileSync(args[0]);
+ if (!binary.buffer) binary = new Uint8Array(binary);
+} else {
+ var args;
+ if (typeof scriptArgs != 'undefined') {
+ args = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ args = arguments;
+ }
+ if (typeof readbuffer === 'function') {
+ binary = new Uint8Array(readbuffer(args[0]));
+ } else {
+ binary = read(args[0], 'binary');
+ }
+}
+
+// Test the wasm for validity by compiling it.
+new WebAssembly.Module(binary);
+
diff --git a/test/badvartype.wasm b/test/badvartype.wasm
deleted file mode 100644
index 05637e5f6..000000000
--- a/test/badvartype.wasm
+++ /dev/null
Binary files differ
diff --git a/test/badvartype.wasm.fromBinary b/test/badvartype.wasm.fromBinary
deleted file mode 100644
index 6f96744a5..000000000
--- a/test/badvartype.wasm.fromBinary
+++ /dev/null
@@ -1,344 +0,0 @@
-(module
- (type $0 (func (param i32) (result f32)))
- (type $1 (func))
- (type $2 (func (param i64) (result f64)))
- (type $3 (func (param f32 i32 i32 i64 i64 i32 i32) (result f64)))
- (type $4 (func (param f32 f32) (result i64)))
- (type $5 (func (result i64)))
- (type $6 (func (param i32 i32)))
- (type $7 (func (param f32) (result f32)))
- (type $8 (func (param f64) (result f64)))
- (memory $0 (shared 1 1))
- (data (i32.const 0) "\00\00\00\00\00\00\00\00X\00\00\00U\00\00\0b\00\00\00\00\00\00\00k\00\00")
- (table $0 2 funcref)
- (elem (i32.const 0) $1 $5)
- (global $global$0 (mut i32) (i32.const 255))
- (global $global$1 (mut i32) (i32.const -7045592))
- (global $global$2 (mut i64) (i64.const -9223372036854775808))
- (global $global$3 (mut f32) (f32.const -268435456))
- (global $global$4 (mut f64) (f64.const -2251799813685248))
- (global $global$5 (mut i32) (i32.const 10))
- (export "func_0" (func $0))
- (export "func_2_invoker" (func $3))
- (export "hangLimitInitializer" (func $7))
- (func $0 (; 0 ;) (type $0) (param $0 i32) (result f32)
- (block $label$1
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return
- (f32.const -nan:0x1d717c)
- )
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (block $label$3 (result f32)
- (nop)
- (return
- (f32.const 137438953472)
- )
- )
- )
- (func $1 (; 1 ;) (type $2) (param $0 i64) (result f64)
- (block $label$1
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return
- (f64.const 128)
- )
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (block $label$3 (result f64)
- (nop)
- (return
- (f64.const 1)
- )
- )
- )
- (func $2 (; 2 ;) (type $3) (param $0 f32) (param $1 i32) (param $2 i32) (param $3 i64) (param $4 i64) (param $5 i32) (param $6 i32) (result f64)
- (local $7 i32)
- (local $8 i32)
- (local $9 i64)
- (local $10 f32)
- (local $11 f32)
- (local $12 f32)
- (local $13 f64)
- (local $14 f64)
- (local $15 f64)
- (block $label$1
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return
- (local.get $13)
- )
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (f64.const 65489)
- )
- (func $3 (; 3 ;) (type $1)
- (drop
- (call $2
- (f32.const 2199023255552)
- (i32.const 50)
- (i32.const 0)
- (i64.const 32767)
- (i64.const -65535)
- (i32.const -2147483648)
- (i32.const -84)
- )
- )
- (drop
- (f32.const 70368744177664)
- )
- (drop
- (i32.const -53)
- )
- (drop
- (i32.const -46)
- )
- (drop
- (i64.const -12216)
- )
- (drop
- (i64.const 0)
- )
- (unreachable)
- )
- (func $4 (; 4 ;) (type $4) (param $0 f32) (param $1 f32) (result i64)
- (local $2 i32)
- (local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (local $6 i32)
- (local $7 i64)
- (local $8 i64)
- (local $9 f32)
- (local $10 f32)
- (local $11 f32)
- (local $12 f64)
- (block $label$1
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return
- (local.get $8)
- )
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (unreachable)
- )
- (func $5 (; 5 ;) (type $5) (result i64)
- (local $0 i64)
- (block $label$1
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return
- (block (result i64)
- (local.set $0
- (i64.const 0)
- )
- (nop)
- (local.get $0)
- )
- )
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (i64.const 3832563226)
- )
- (func $6 (; 6 ;) (type $6) (param $0 i32) (param $1 i32)
- (local $2 i64)
- (block $label$1
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return)
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (block $label$3
- (br_if $label$3
- (local.get $1)
- )
- (if
- (i32.eqz
- (local.get $1)
- )
- (block $label$5
- (nop)
- (br_if $label$3
- (local.tee $1
- (local.tee $1
- (local.tee $1
- (if (result i32)
- (i32.eqz
- (local.get $1)
- )
- (block $label$7 (result i32)
- (local.set $2
- (block $label$8 (result i64)
- (loop $label$9
- (block $label$10
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return)
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (block $label$12
- (block $label$13
- (local.set $1
- (br_if $label$7
- (local.get $0)
- (i32.eqz
- (local.get $1)
- )
- )
- )
- (if
- (i32.eqz
- (local.get $1)
- )
- (br_if $label$5
- (i32.eqz
- (br_if $label$7
- (i32.const -125)
- (loop $label$15 (result i32)
- (block $label$16
- (if
- (i32.eqz
- (global.get $global$5)
- )
- (return)
- )
- (global.set $global$5
- (i32.sub
- (global.get $global$5)
- (i32.const 1)
- )
- )
- )
- (block $label$18 (result i32)
- (nop)
- (br_if $label$15
- (i32.eqz
- (local.tee $1
- (i32.const 32767)
- )
- )
- )
- (i32.const -2147483648)
- )
- )
- )
- )
- )
- (block
- (drop
- (i64.add
- (local.get $2)
- (local.get $2)
- )
- )
- (nop)
- )
- )
- )
- (br_if $label$9
- (local.get $1)
- )
- (nop)
- )
- )
- (local.get $2)
- )
- )
- (local.get $1)
- )
- (i32.const -7059178)
- )
- )
- )
- )
- )
- )
- (nop)
- )
- )
- )
- (func $7 (; 7 ;) (type $1)
- (global.set $global$5
- (i32.const 10)
- )
- )
- (func $8 (; 8 ;) (type $7) (param $0 f32) (result f32)
- (if (result f32)
- (f32.eq
- (local.get $0)
- (local.get $0)
- )
- (local.get $0)
- (f32.const 0)
- )
- )
- (func $9 (; 9 ;) (type $8) (param $0 f64) (result f64)
- (if (result f64)
- (f64.eq
- (local.get $0)
- (local.get $0)
- )
- (local.get $0)
- (f64.const 0)
- )
- )
-)
-