diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-08-11 10:53:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-11 10:53:21 -0700 |
commit | 4216894b22e5891e83851d2af42080293e6089e4 (patch) | |
tree | e4fdcdd5becaf80dcaf924bd20e01f107b05b388 /test/passes/emit-js-wrapper=a.js.wast.js | |
parent | 5295929fd239ea8a760cd2c3f65510da9972c33c (diff) | |
download | binaryen-4216894b22e5891e83851d2af42080293e6089e4.tar.gz binaryen-4216894b22e5891e83851d2af42080293e6089e4.tar.bz2 binaryen-4216894b22e5891e83851d2af42080293e6089e4.zip |
New fuzzer (#1126)
This adds a new method of fuzzing, "translate to fuzz" which means we consider the input to be a stream of data that we translate into a valid wasm module. It's sort of like a random seed for a process that creates a random wasm module. By using the input that way, we can explore the space of valid wasm modules quickly, and it makes afl-fuzz integration easy.
Also adds a "fuzz binary" option which is similar to "fuzz execution". It makes wasm-opt not only execute the code before and after opts, but also write to binary and read from it, helping to fuzz the binary format.
Diffstat (limited to 'test/passes/emit-js-wrapper=a.js.wast.js')
-rw-r--r-- | test/passes/emit-js-wrapper=a.js.wast.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/passes/emit-js-wrapper=a.js.wast.js b/test/passes/emit-js-wrapper=a.js.wast.js new file mode 100644 index 000000000..778f43827 --- /dev/null +++ b/test/passes/emit-js-wrapper=a.js.wast.js @@ -0,0 +1,44 @@ +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'); + } +} +var instance = new WebAssembly.Instance(new WebAssembly.Module(binary), {}); +if (instance.exports.hangLimitInitializer) instance.exports.hangLimitInitializer(); +try { + console.log('calling: add'); + console.log(' result: ' + instance.exports.add(0, 0)); +} catch (e) { + console.log(' exception: ' + e); +} +if (instance.exports.hangLimitInitializer) instance.exports.hangLimitInitializer(); +try { + console.log('calling: no_return'); +instance.exports.no_return(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); +} +console.log('done.') |