summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fuzz_opt.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index cd4912475..fb777d235 100644
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -28,7 +28,9 @@ from test.shared import options, NODEJS
NANS = True
-FUZZ_OPTS = [] # '--all-features' etc
+FEATURE_OPTS = [] # '--all-features' etc
+
+FUZZ_OPTS = []
V8_OPTS = [
'--experimental-wasm-eh',
@@ -138,19 +140,23 @@ def run_vm(cmd):
def run_bynterp(wasm):
- return fix_output(run_vm([in_bin('wasm-opt'), wasm, '--fuzz-exec-before'] + FUZZ_OPTS))
+ return fix_output(run_vm([in_bin('wasm-opt'), wasm, '--fuzz-exec-before'] + FEATURE_OPTS))
def run_wasm2js(wasm):
- wrapper = run([in_bin('wasm-opt'), wasm, '--emit-js-wrapper=/dev/stdout'] + FUZZ_OPTS)
- main = run([in_bin('wasm2js'), wasm, '--emscripten'] + FUZZ_OPTS)
+ wrapper = run([in_bin('wasm-opt'), wasm, '--emit-js-wrapper=/dev/stdout'] + FEATURE_OPTS)
+ main = run([in_bin('wasm2js'), wasm, '--emscripten'] + FEATURE_OPTS)
with open(os.path.join(options.binaryen_root, 'scripts', 'wasm2js.js')) as f:
glue = f.read()
with open('js.js', 'w') as f:
f.write(glue)
f.write(main)
f.write(wrapper)
- return fix_output(run_vm([NODEJS, 'js.js', 'a.wasm']))
+ out = fix_output(run_vm([NODEJS, 'js.js', 'a.wasm']))
+ if 'exception' in out:
+ # exception, so ignoring - wasm2js does not have normal wasm trapping, so opts can eliminate a trap
+ out = IGNORE
+ return out
def run_vms(prefix):
@@ -186,14 +192,14 @@ def test_one(infile, opts):
# fuzz vms
# gather VM outputs on input file
- run([in_bin('wasm-opt'), infile, '-ttf', '--emit-js-wrapper=a.js', '--emit-spec-wrapper=a.wat', '-o', 'a.wasm'] + FUZZ_OPTS)
+ run([in_bin('wasm-opt'), infile, '-ttf', '--emit-js-wrapper=a.js', '--emit-spec-wrapper=a.wat', '-o', 'a.wasm'] + FUZZ_OPTS + FEATURE_OPTS)
wasm_size = os.stat('a.wasm').st_size
bytes += wasm_size
print('pre js size :', os.stat('a.js').st_size, ' wasm size:', wasm_size)
before = run_vms('a.')
print('----------------')
# gather VM outputs on processed file
- run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm'] + opts + FUZZ_OPTS)
+ run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm'] + opts + FUZZ_OPTS + FEATURE_OPTS)
wasm_size = os.stat('b.wasm').st_size
bytes += wasm_size
print('post js size:', os.stat('a.js').st_size, ' wasm size:', wasm_size)
@@ -205,10 +211,10 @@ def test_one(infile, opts):
if NANS:
break
# fuzz binaryen interpreter itself. separate invocation so result is easily fuzzable
- run([in_bin('wasm-opt'), 'a.wasm', '--fuzz-exec', '--fuzz-binary'] + opts + FUZZ_OPTS)
+ run([in_bin('wasm-opt'), 'a.wasm', '--fuzz-exec', '--fuzz-binary'] + opts + FUZZ_OPTS + FEATURE_OPTS)
# check for determinism
- run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm'] + opts + FUZZ_OPTS)
- run([in_bin('wasm-opt'), 'a.wasm', '-o', 'c.wasm'] + opts + FUZZ_OPTS)
+ run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm'] + opts + FUZZ_OPTS + FEATURE_OPTS)
+ run([in_bin('wasm-opt'), 'a.wasm', '-o', 'c.wasm'] + opts + FUZZ_OPTS + FEATURE_OPTS)
assert open('b.wasm').read() == open('c.wasm').read(), 'output must be deterministic'
return bytes