Skip to content

Commit 4be4706

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[github] Also run tests with d8 (previously only Node.js)
Change-Id: I89b0829edfb72d72e22b9dc4e41862b76a8db711 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8637337 Commit-Queue: Matthias Liedtke <[email protected]> Reviewed-by: Danylo Mocherniuk <[email protected]> Auto-Submit: Matthias Liedtke <[email protected]>
1 parent cd1ab9e commit 4be4706

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

.github/workflows/swift.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: build_test
22

33
on:
44
push:
@@ -7,7 +7,7 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
build:
10+
build_test:
1111
timeout-minutes: 30
1212
strategy:
1313
matrix:
@@ -27,5 +27,11 @@ jobs:
2727
- uses: actions/checkout@v2
2828
- name: Build
2929
run: swift build -v
30-
- name: Run tests
30+
- name: Run tests with Node.js
3131
run: swift test -v
32+
- name: Install jsvu
33+
run: npm install jsvu -g
34+
- name: Install d8
35+
run: jsvu --os=default --engines=v8
36+
- name: Run tests with d8
37+
run: FUZZILLI_TEST_SHELL=~/.jsvu/engines/v8/v8 swift test -v

Tests/FuzzilliTests/LiveTests.swift

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ class LiveTests: XCTestCase {
2424
// Set to true to log failing programs
2525
static let VERBOSE = false
2626

27+
/// Meta-test ensuring that the test framework can successfully terminate an endless loop.
28+
func testEndlessLoopTermination() throws {
29+
let runner = try GetJavaScriptExecutorOrSkipTest()
30+
31+
let results = try Self.runLiveTest(iterations: 1, withRunner: runner, timeoutInSeconds: 1) { b in
32+
b.loadInt(123) // prefix
33+
34+
let module = b.buildWasmModule() { module in
35+
module.addWasmFunction(with: [] => []) { function, label, args in
36+
function.wasmBuildLoop(with: [] => [], args: []) { label, args in
37+
function.wasmBranch(to: label)
38+
return []
39+
}
40+
return []
41+
}
42+
}
43+
b.callMethod(module.getExportedMethod(at: 0), on: module.loadExports(), withArgs: [])
44+
}
45+
assert(results.failureRate == 1)
46+
assert(results.failureMessages.count == 1)
47+
}
48+
2749
func testValueGeneration() throws {
2850
let runner = try GetJavaScriptExecutorOrSkipTest()
2951

@@ -142,7 +164,7 @@ class LiveTests: XCTestCase {
142164
// The closure can use the ProgramBuilder to emit a program of a specific
143165
// shape that is then executed with the given runner. We then check that
144166
// we stay below the maximum failure rate over the given number of iterations.
145-
static func runLiveTest(iterations n: Int = 250, withRunner runner: JavaScriptExecutor, body: (ProgramBuilder) -> Void) throws -> (failureRate: Double, failureMessages: [String: Int]) {
167+
static func runLiveTest(iterations n: Int = 250, withRunner runner: JavaScriptExecutor, timeoutInSeconds: Int = 5, body: (ProgramBuilder) -> Void) throws -> (failureRate: Double, failureMessages: [String: Int]) {
146168
let liveTestConfig = Configuration(logLevel: .error, enableInspection: true)
147169

148170
// We have to use the proper JavaScriptEnvironment here.
@@ -178,7 +200,7 @@ class LiveTests: XCTestCase {
178200
}
179201

180202
DispatchQueue.concurrentPerform(iterations: n) { i in
181-
let result = executeAndParseResults(program: programs[i], runner: runner)
203+
let result = executeAndParseResults(program: programs[i], runner: runner, timeoutInSeconds: timeoutInSeconds)
182204
results[i] = result
183205
}
184206

@@ -214,10 +236,11 @@ class LiveTests: XCTestCase {
214236
}
215237
}
216238

217-
static func executeAndParseResults(program: (program: Program, jsProgram: String), runner: JavaScriptExecutor) -> ExecutionResult {
239+
static func executeAndParseResults(program: (program: Program, jsProgram: String), runner: JavaScriptExecutor, timeoutInSeconds: Int) -> ExecutionResult {
218240

219241
do {
220-
let result = try runner.executeScript(program.jsProgram, withTimeout: 5 * Seconds)
242+
let result = try runner.executeScript(program.jsProgram,
243+
withTimeout: Double(timeoutInSeconds) * Seconds)
221244
if result.isFailure {
222245
var signature: String? = nil
223246

0 commit comments

Comments
 (0)