test: clean up wasm fixtures

PR-URL: https://github.com/nodejs/node/pull/25360
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Gus Caplan 2019-01-05 18:58:16 -06:00
parent 9987f1abb9
commit 0c8dedd103
No known key found for this signature in database
GPG Key ID: F00BD11880E82F0E
13 changed files with 27 additions and 22 deletions

BIN
test/fixtures/shared-memory.wasm vendored Normal file

Binary file not shown.

8
test/fixtures/shared-memory.wat vendored Normal file
View File

@ -0,0 +1,8 @@
;; Compiled using the WebAssembly Tootkit (https://github.com/WebAssembly/wabt)
;; $ wat2wasm --enable-threads shared-memory.wat -o shared-memory.wasm
(module
;; Create shared memory with initial 1 page (64KiB) and max 1 page
(memory $mem 1 1 shared)
(export "memory" (memory $mem))
)

BIN
test/fixtures/simple.wasm vendored Normal file

Binary file not shown.

11
test/fixtures/simple.wat vendored Normal file
View File

@ -0,0 +1,11 @@
;; Compiled using the WebAssembly Tootkit (https://github.com/WebAssembly/wabt)
;; $ wat2wasm simple.wat -o simple.wasm
(module
(func $add (param $a i32) (param $b i32) (result i32)
;; return $a + $b
(i32.add (get_local $a) (get_local $b))
)
(export "add" (func $add))
)

Binary file not shown.

View File

@ -1,10 +0,0 @@
;; Compiled using the WebAssembly Tootkit (https://github.com/WebAssembly/wabt)
;; $ wat2wasm test.wat -o test.wasm
(module
(func $add (export "add") (param $first i32) (param $second i32) (result i32)
get_local $first
get_local $second
(i32.add)
)
(export "addTwo" (func $add))
)

Binary file not shown.

View File

@ -1,4 +0,0 @@
(module
(memory $mem 1 2 shared)
(export "memory" (memory $mem))
)

View File

@ -9,7 +9,7 @@ const { internalBinding } = require('internal/test/binding');
const { JSStream } = internalBinding('js_stream');
const external = (new JSStream())._externalStream;
const wasmBuffer = fixtures.readSync('test.wasm');
const wasmBuffer = fixtures.readSync('simple.wasm');
for (const [ value, _method ] of [
[ external, 'isExternal' ],

View File

@ -12,7 +12,7 @@ const os = require('os');
const circular = {};
circular.circular = circular;
const wasmModule = new WebAssembly.Module(fixtures.readSync('test.wasm'));
const wasmModule = new WebAssembly.Module(fixtures.readSync('simple.wasm'));
const objects = [
{ foo: 'bar' },
@ -238,5 +238,5 @@ const deserializerTypeError =
{
const deserializedWasmModule = v8.deserialize(v8.serialize(wasmModule));
const instance = new WebAssembly.Instance(deserializedWasmModule);
assert.strictEqual(instance.exports.addTwo(10, 20), 30);
assert.strictEqual(instance.exports.add(10, 20), 30);
}

View File

@ -4,14 +4,14 @@ require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const buffer = fixtures.readSync('test.wasm');
const buffer = fixtures.readSync('simple.wasm');
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
WebAssembly.instantiate(buffer, {}).then((results) => {
// Exported function should add two numbers.
assert.strictEqual(
results.instance.exports.addTwo(10, 20),
results.instance.exports.add(10, 20),
30
);
});

View File

@ -5,13 +5,13 @@ const assert = require('assert');
const fixtures = require('../common/fixtures');
const { Worker } = require('worker_threads');
const wasmModule = new WebAssembly.Module(fixtures.readSync('test.wasm'));
const wasmModule = new WebAssembly.Module(fixtures.readSync('simple.wasm'));
const worker = new Worker(`
const { parentPort } = require('worker_threads');
parentPort.once('message', ({ wasmModule }) => {
const instance = new WebAssembly.Instance(wasmModule);
parentPort.postMessage(instance.exports.addTwo(10, 20));
parentPort.postMessage(instance.exports.add(10, 20));
});
`, { eval: true });

View File

@ -8,7 +8,7 @@ const { MessageChannel, Worker } = require('worker_threads');
// through MessageChannels (without crashing).
const fixtures = require('../common/fixtures');
const wasmSource = fixtures.readSync('wasm-threads-shared-memory.wasm');
const wasmSource = fixtures.readSync('shared-memory.wasm');
const wasmModule = new WebAssembly.Module(wasmSource);
const instance = new WebAssembly.Instance(wasmModule);