diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-12-27 15:24:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-27 15:24:57 -0800 |
commit | 3f3fc857ff6204517281ed5caa3209cc8f02d4fc (patch) | |
tree | b64969a33874f29d5f35ea546c69eda90f89edf4 /test/passes/emit-js-wrapper=a.js.wast.js | |
parent | fdd4cb7b11d43c6ff200c9541f8567000a8d4bcd (diff) | |
download | binaryen-3f3fc857ff6204517281ed5caa3209cc8f02d4fc.tar.gz binaryen-3f3fc857ff6204517281ed5caa3209cc8f02d4fc.tar.bz2 binaryen-3f3fc857ff6204517281ed5caa3209cc8f02d4fc.zip |
Fix fuzzing JS glue code (#1843)
After we added logging to the fuzzer, we forgot to add to the JS glue code the necessary imports so it can be run there too.
Also adds legalization for the JS glue code imports and exports.
Also adds a missing validator check on imports having a function type (the fuzzing code was missing one).
Fixes #1842
Diffstat (limited to 'test/passes/emit-js-wrapper=a.js.wast.js')
-rw-r--r-- | test/passes/emit-js-wrapper=a.js.wast.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/passes/emit-js-wrapper=a.js.wast.js b/test/passes/emit-js-wrapper=a.js.wast.js index 778f43827..f2e828c2b 100644 --- a/test/passes/emit-js-wrapper=a.js.wast.js +++ b/test/passes/emit-js-wrapper=a.js.wast.js @@ -1,6 +1,7 @@ if (typeof console === 'undefined') { console = { log: print }; } +var tempRet0; var binary; if (typeof process === 'object' && typeof require === 'function' /* node.js detection */) { var args = process.argv.slice(2); @@ -19,7 +20,18 @@ if (typeof process === 'object' && typeof require === 'function' /* node.js dete binary = read(args[0], 'binary'); } } -var instance = new WebAssembly.Instance(new WebAssembly.Module(binary), {}); +var instance = new WebAssembly.Instance(new WebAssembly.Module(binary), { + 'fuzzing-support': { + 'log-i32': function(x) { console.log('i32: ' + x) }, + 'log-i64': function(x, y) { console.log('i64: ' + x + ', ' + y) }, + 'log-f32': function(x) { console.log('f32: ' + x) }, + 'log-f64': function(x) { console.log('f64: ' + x) } + }, + 'env': { + 'setTempRet0': function(x) { tempRet0 = x }, + 'getTempRet0': function() { return tempRet0 }, + }, +}); if (instance.exports.hangLimitInitializer) instance.exports.hangLimitInitializer(); try { console.log('calling: add'); @@ -36,9 +48,23 @@ instance.exports.no_return(0); } if (instance.exports.hangLimitInitializer) instance.exports.hangLimitInitializer(); try { + console.log('calling: types'); +instance.exports.types(0, 0, 0, 0, 0); +} catch (e) { + console.log(' exception: ' + e); +} +if (instance.exports.hangLimitInitializer) instance.exports.hangLimitInitializer(); +try { console.log('calling: types2'); instance.exports.types2(0, 0, 0); } catch (e) { console.log(' exception: ' + e); } +if (instance.exports.hangLimitInitializer) instance.exports.hangLimitInitializer(); +try { + console.log('calling: types3'); + console.log(' result: ' + instance.exports.types3(0, 0, 0)); +} catch (e) { + console.log(' exception: ' + e); +} console.log('done.') |