Skip to content

Commit 1d22d0e

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
Make all tests pass on node.js trunk
Make sure that we stringify all BigInts as well as all arrays before passing them to "output" as node.js and d8 print them differently. Also test both result.output as well as result.error as node.js prints errors on stderr and not on stdout. Change-Id: I91ee2c1033cd01cca8c46729f488b438a30af539 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8457616 Reviewed-by: Pawel Krawczyk <[email protected]> Commit-Queue: Matthias Liedtke <[email protected]>
1 parent fb46c8c commit 1d22d0e

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4033,6 +4033,15 @@ public class ProgramBuilder {
40334033
emit(WasmResolveForwardReference(), withInputs: [forwardReference, to])
40344034
}
40354035

4036+
// Converts an array to a string separating elements by comma. This is used for testing only.
4037+
func arrayToStringForTesting(_ array: Variable) -> Variable {
4038+
let stringified = callMethod("map", on: array,
4039+
withArgs: [buildArrowFunction(with: .parameters(n: 1)) { args in
4040+
doReturn(callMethod("toString", on: args[0]))
4041+
}])
4042+
return callMethod("join", on: stringified, withArgs: [loadString(",")])
4043+
}
4044+
40364045
/// Returns the next free variable.
40374046
func nextVariable() -> Variable {
40384047
assert(numVariables < Code.maxNumberOfVariables, "Too many variables")

Tests/FuzzilliTests/LiveTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class LiveTests: XCTestCase {
217217
if result.isFailure {
218218
var signature: String? = nil
219219

220-
for line in result.output.split(separator: "\n") {
220+
for line in (result.output + result.error).split(separator: "\n") {
221221
if line.contains("Error:") {
222222
// Remove anything after a potential 2nd ":", which is usually testcase dependent content, e.g. "SyntaxError: Invalid regular expression: /ep{}[]Z7/: Incomplete quantifier"
223223
signature = line.split(separator: ":")[0...1].joined(separator: ":")

Tests/FuzzilliTests/WasmAtomicsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class WasmAtomicsTests: XCTestCase {
6363
for (i, result) in expectedResults.enumerated() {
6464
let w = b.getProperty("w\(i)", of: exports)
6565
let r = b.callFunction(w)
66-
b.callFunction(outputFunc, withArgs: [r])
66+
b.callFunction(outputFunc, withArgs: [b.callMethod("toString", on: r)])
6767
expectedOutput += result + "\n"
6868
}
6969

@@ -121,7 +121,7 @@ class WasmAtomicsTests: XCTestCase {
121121
for (i, result) in expectedResults.enumerated() {
122122
let w = b.getProperty("w\(i)", of: exports)
123123
let r = b.callFunction(w)
124-
b.callFunction(outputFunc, withArgs: [r])
124+
b.callFunction(outputFunc, withArgs: [b.callMethod("toString", on: r)])
125125
expectedOutput += result + "\n"
126126
}
127127

Tests/FuzzilliTests/WasmTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func testForOutputRegex(program: String, runner: JavaScriptExecutor, outputPatte
3939

4040
func testForErrorOutput(program: String, runner: JavaScriptExecutor, errorMessageContains errormsg: String) {
4141
let result = testExecuteScript(program: program, runner: runner)
42-
XCTAssert(result.output.contains(errormsg), "Error messages don't match, got:\n" + result.output)
42+
XCTAssert(result.output.contains(errormsg) || result.error.contains(errormsg), "Error messages don't match, got stdout:\n\(result.output)\nstderr:\n\(result.error)")
4343
}
4444

4545
class WasmSignatureConversionTests: XCTestCase {
@@ -487,7 +487,7 @@ class WasmFoundationTests: XCTestCase {
487487
}
488488

489489
func testGlobalExnRef() throws {
490-
let runner = try GetJavaScriptExecutorOrSkipTest(type: .user, withArguments: ["--experimental-wasm-exnref"])
490+
let runner = try GetJavaScriptExecutorOrSkipTest(type: .any, withArguments: ["--experimental-wasm-exnref"])
491491
let liveTestConfig = Configuration(logLevel: .error, enableInspection: true)
492492

493493
let fuzzer = makeMockFuzzer(config: liveTestConfig, environment: JavaScriptEnvironment())
@@ -1021,7 +1021,7 @@ class WasmFoundationTests: XCTestCase {
10211021
let wasmFunction = b.getProperty(module.getExportedMethod(at: 1), of: exports)
10221022
let result = b.callFunction(wasmFunction, withArgs: [b.loadInt(42)])
10231023
let outputFunc = b.createNamedVariable(forBuiltin: "output")
1024-
b.callFunction(outputFunc, withArgs: [result])
1024+
b.callFunction(outputFunc, withArgs: [b.arrayToStringForTesting(result)])
10251025

10261026
let prog = b.finalize()
10271027
let jsProg = fuzzer.lifter.lift(prog)
@@ -2418,7 +2418,7 @@ class WasmFoundationTests: XCTestCase {
24182418
}
24192419

24202420
for (i, _) in testCases.enumerated() {
2421-
let print = b.createNamedVariable(forBuiltin: "print")
2421+
let print = b.createNamedVariable(forBuiltin: "output")
24222422
let number = b.createNamedVariable(forBuiltin: "Number")
24232423

24242424
let setFormat = b.buildArrowFunction(with: .parameters(n: 1)) { args in
@@ -3468,7 +3468,7 @@ class WasmFoundationTests: XCTestCase {
34683468
}
34693469

34703470
func testTryTableNoCatch() throws {
3471-
let runner = try GetJavaScriptExecutorOrSkipTest(type: .user, withArguments: ["--experimental-wasm-exnref"])
3471+
let runner = try GetJavaScriptExecutorOrSkipTest(type: .any, withArguments: ["--experimental-wasm-exnref"])
34723472
let liveTestConfig = Configuration(logLevel: .error, enableInspection: true)
34733473
let fuzzer = makeMockFuzzer(config: liveTestConfig, environment: JavaScriptEnvironment())
34743474
let b = fuzzer.makeBuilder()
@@ -4263,7 +4263,7 @@ class WasmGCTests: XCTestCase {
42634263
}
42644264

42654265
func testRefNullAbstractTypes() throws {
4266-
let runner = try GetJavaScriptExecutorOrSkipTest()
4266+
let runner = try GetJavaScriptExecutorOrSkipTest(type: .any, withArguments: ["--experimental-wasm-exnref"])
42674267
let liveTestConfig = Configuration(logLevel: .error, enableInspection: true)
42684268
let fuzzer = makeMockFuzzer(config: liveTestConfig, environment: JavaScriptEnvironment())
42694269
let b = fuzzer.makeBuilder()
@@ -4326,8 +4326,8 @@ class WasmGCTests: XCTestCase {
43264326

43274327
let positiveResults = b.callMethod(module.getExportedMethod(at: 1), on: exports, withArgs: [positiveI31])
43284328
let negativeResults = b.callMethod(module.getExportedMethod(at: 1), on: exports, withArgs: [negativeI31])
4329-
b.callFunction(outputFunc, withArgs: [positiveResults])
4330-
b.callFunction(outputFunc, withArgs: [negativeResults])
4329+
b.callFunction(outputFunc, withArgs: [b.arrayToStringForTesting(positiveResults)])
4330+
b.callFunction(outputFunc, withArgs: [b.arrayToStringForTesting(negativeResults)])
43314331

43324332
let prog = b.finalize()
43334333
let jsProg = fuzzer.lifter.lift(prog)

0 commit comments

Comments
 (0)