From c7eabee42207adc614324441fa2b0d8309bf8e47 Mon Sep 17 00:00:00 2001 From: eholk Date: Tue, 14 Feb 2017 10:25:32 -0800 Subject: [PATCH] [wasm] include JS conformance tests in Wasm mjsunit tests BUG= https://bugs.chromium.org/p/v8/issues/detail?id=5507 Review-Url: https://codereview.chromium.org/2660903003 Cr-Original-Commit-Position: refs/heads/master@{#42821} Committed: https://chromium.googlesource.com/v8/v8/+/eb9b5edffb8c5acb0abdff0729901f95dbd3ccac Review-Url: https://codereview.chromium.org/2660903003 Cr-Commit-Position: refs/heads/master@{#43201} --- .gitignore | 1 + DEPS | 2 + test/mjsunit/mjsunit.isolate | 7 ++- test/mjsunit/wasm/jsapi-harness.js | 78 ++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 test/mjsunit/wasm/jsapi-harness.js diff --git a/.gitignore b/.gitignore index da907efbf8..1a58587a56 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,4 @@ v8.ignition_dispatches_table.json /test/fuzzer/wasm_asmjs.tar.gz /src/inspector/build/closure-compiler.tar.gz /src/inspector/build/closure-compiler +/test/wasm-js diff --git a/DEPS b/DEPS index d73d7edbca..3849d1b121 100644 --- a/DEPS +++ b/DEPS @@ -39,6 +39,8 @@ deps = { Var("chromium_url") + "/external/github.com/test262-utils/test262-harness-py.git" + "@" + "0f2acdd882c84cff43b9d60df7574a1901e2cdcd", "v8/tools/clang": Var("chromium_url") + "/chromium/src/tools/clang.git" + "@" + "404d5421df201261afb240fd562872841d3850e0", + "v8/test/wasm-js": + Var("chromium_url") + "/external/github.com/WebAssembly/spec.git" + "@" + "ab1673f1e47b90471ab9352866b7682269c5b8ab", } deps_os = { diff --git a/test/mjsunit/mjsunit.isolate b/test/mjsunit/mjsunit.isolate index 6ebd801eac..2474d65060 100644 --- a/test/mjsunit/mjsunit.isolate +++ b/test/mjsunit/mjsunit.isolate @@ -14,11 +14,14 @@ '../../tools/profviz/composer.js', '../../tools/splaytree.js', '../../tools/tickprocessor.js', - '../../tools/dumpcpp.js' + '../../tools/dumpcpp.js', + '../wasm-js/test/harness/wasm-constants.js', + '../wasm-js/test/harness/wasm-module-builder.js', + '../wasm-js/test/js-api/jsapi.js', ], }, 'includes': [ '../../src/d8.isolate', '../../tools/testrunner/testrunner.isolate', ], -} \ No newline at end of file +} diff --git a/test/mjsunit/wasm/jsapi-harness.js b/test/mjsunit/wasm/jsapi-harness.js new file mode 100644 index 0000000000..c6ff427530 --- /dev/null +++ b/test/mjsunit/wasm/jsapi-harness.js @@ -0,0 +1,78 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TODO(eholk): Once we have stable test IDs, use those as the key instead. +// See https://github.com/WebAssembly/spec/issues/415 +const known_failures = { + "'WebAssembly.Module.customSections' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5815', + "'WebAssembly.Table.prototype.get' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', + "'WebAssembly.Table.prototype.set' method": + 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', +}; + +let failures = []; + +let last_promise = new Promise((resolve, reject) => { resolve(); }); + +function test(func, description) { + let maybeErr; + try { func(); } + catch(e) { maybeErr = e; } + if (typeof maybeErr !== 'undefined') { + print(`${description}: FAIL. ${maybeErr}`); + failures.push(description); + } else { + print(`${description}: PASS.`); + } +} + +function promise_test(func, description) { + last_promise = last_promise.then(func) + .then(_ => { print(`${description}: PASS.`); }) + .catch(err => { + print(`${description}: FAIL. ${err}`); + failures.push(description); + }); +} + +let assert_equals = assertEquals; +let assert_true = assertEquals.bind(null, true); +let assert_false = assertEquals.bind(null, false); + +function assert_unreached(description) { + throw new Error(`unreachable:\n${description}`); +} + +function assertErrorMessage(f, ctor, test) { + try { f(); } + catch (e) { + assert_true(e instanceof ctor, "expected exception " + ctor.name + ", got " + e); + return; + } + assert_true(false, "expected exception " + ctor.name + ", no exception thrown"); +}; + +load("test/wasm-js/test/harness/wasm-constants.js"); +load("test/wasm-js/test/harness/wasm-module-builder.js"); +load("test/wasm-js/test/js-api/jsapi.js"); + +last_promise.then(_ => { + if (failures.length > 0) { + let unexpected = false; + print("Some tests FAILED:"); + for (let i in failures) { + if (known_failures[failures[i]]) { + print(` ${failures[i]} [KNOWN: ${known_failures[failures[i]]}]`); + } else { + print(` ${failures[i]}`); + unexpected = true; + } + } + if (unexpected) { + quit(1); + } + } +});