Skip to content

Commit eb9b5ed

Browse files
eholkCommit bot
authored andcommitted
[wasm] include JS conformance tests in Wasm mjsunit tests
BUG= Review-Url: https://codereview.chromium.org/2660903003 Cr-Commit-Position: refs/heads/master@{#42821}
1 parent e791ded commit eb9b5ed

4 files changed

Lines changed: 86 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@ v8.ignition_dispatches_table.json
9898
/test/fuzzer/wasm_asmjs.tar.gz
9999
/src/inspector/build/closure-compiler.tar.gz
100100
/src/inspector/build/closure-compiler
101+
/test/wasm-js

DEPS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ deps = {
4040
Var("chromium_url") + "/external/github.com/test262-utils/test262-harness-py.git" + "@" + "0f2acdd882c84cff43b9d60df7574a1901e2cdcd",
4141
"v8/tools/clang":
4242
Var("chromium_url") + "/chromium/src/tools/clang.git" + "@" + "960cc3ec8c679adad9b6f9019f737c8cd9ad0a75",
43+
# TODO(eholk): once the Wasm JS API Conformance Suite is finalized, mirror it in
44+
# a chromium repo like the other deps.
45+
"v8/test/wasm-js":
46+
"https://github.com/bnjbvr/wasm-spec.git" + "@" + "190bd270e148a532082f6eb1b97dea5302800485",
4347
}
4448

4549
deps_os = {

test/mjsunit/mjsunit.isolate

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
'../../tools/profviz/composer.js',
1515
'../../tools/splaytree.js',
1616
'../../tools/tickprocessor.js',
17-
'../../tools/dumpcpp.js'
17+
'../../tools/dumpcpp.js',
18+
'../wasm-js/',
1819
],
1920
},
2021
'includes': [
2122
'../../src/d8.isolate',
2223
'../../tools/testrunner/testrunner.isolate',
2324
],
24-
}
25+
}

test/mjsunit/wasm/jsapi-harness.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright 2017 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// TODO(eholk): Once we have stable test IDs, use those as the key instead.
6+
// See https://github.com/WebAssembly/spec/issues/415
7+
const known_failures = {
8+
"'WebAssembly.Module.customSections' method":
9+
'https://bugs.chromium.org/p/v8/issues/detail?id=5815',
10+
"'WebAssembly.Table.prototype.get' method":
11+
'https://bugs.chromium.org/p/v8/issues/detail?id=5507',
12+
"'WebAssembly.Table.prototype.set' method":
13+
'https://bugs.chromium.org/p/v8/issues/detail?id=5507',
14+
};
15+
16+
let failures = [];
17+
18+
let last_promise = new Promise((resolve, reject) => { resolve(); });
19+
20+
function test(func, description) {
21+
let maybeErr;
22+
try { func(); }
23+
catch(e) { maybeErr = e; }
24+
if (typeof maybeErr !== 'undefined') {
25+
print(`${description}: FAIL. ${maybeErr}`);
26+
failures.push(description);
27+
} else {
28+
print(`${description}: PASS.`);
29+
}
30+
}
31+
32+
function promise_test(func, description) {
33+
last_promise = last_promise.then(func)
34+
.then(_ => { print(`${description}: PASS.`); })
35+
.catch(err => {
36+
print(`${description}: FAIL. ${err}`);
37+
failures.push(description);
38+
});
39+
}
40+
41+
let assert_equals = assertEquals;
42+
let assert_true = assertEquals.bind(null, true);
43+
let assert_false = assertEquals.bind(null, false);
44+
45+
function assert_unreached(description) {
46+
throw new Error(`unreachable:\n${description}`);
47+
}
48+
49+
function assertErrorMessage(f, ctor, test) {
50+
try { f(); }
51+
catch (e) {
52+
assert_true(e instanceof ctor, "expected exception " + ctor.name + ", got " + e);
53+
return;
54+
}
55+
assert_true(false, "expected exception " + ctor.name + ", no exception thrown");
56+
};
57+
58+
load("test/wasm-js/test/lib/wasm-constants.js");
59+
load("test/wasm-js/test/lib/wasm-module-builder.js");
60+
load("test/wasm-js/test/js-api/jsapi.js");
61+
62+
last_promise.then(_ => {
63+
if (failures.length > 0) {
64+
let unexpected = false;
65+
print("Some tests FAILED:");
66+
for (let i in failures) {
67+
if (known_failures[failures[i]]) {
68+
print(` ${failures[i]} [KNOWN: ${known_failures[failures[i]]}]`);
69+
} else {
70+
print(` ${failures[i]}`);
71+
unexpected = true;
72+
}
73+
}
74+
if (unexpected) {
75+
quit(1);
76+
}
77+
}
78+
});

0 commit comments

Comments
 (0)