From 256187c823ab6a04b3b55c3d9d3497ae2004d165 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 3 Jul 2019 15:29:31 -0700 Subject: Use v8 to test wasm binaries are valid in test suite binary checks (#2206) --- scripts/validation_shell.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/validation_shell.js (limited to 'scripts/validation_shell.js') 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); + -- cgit v1.2.3