Skip to content

Commit 9f8bf1f

Browse files
committed
bypass bash script in jsvu
Change-Id: I3ebb6c0019c523b3e3cfaa664e00aa0aa8ce6a35
1 parent 997f418 commit 9f8bf1f

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

.github/workflows/swift.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
- name: Install d8
3434
run: jsvu --os=default --engines=v8
3535
- name: Run tests with d8
36-
run: FUZZILLI_TEST_SHELL=~/.jsvu/bin/v8 swift test -v
36+
run: FUZZILLI_TEST_SHELL=~/.jsvu/engines/v8/v8 swift test -v

Tests/FuzzilliTests/LiveTests.swift

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ 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+
print(results.failureMessages)
48+
}
49+
2750
func testValueGeneration() throws {
2851
let runner = try GetJavaScriptExecutorOrSkipTest()
2952

@@ -142,7 +165,7 @@ class LiveTests: XCTestCase {
142165
// The closure can use the ProgramBuilder to emit a program of a specific
143166
// shape that is then executed with the given runner. We then check that
144167
// 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]) {
168+
static func runLiveTest(iterations n: Int = 250, withRunner runner: JavaScriptExecutor, timeoutInSeconds: Int = 5, body: (ProgramBuilder) -> Void) throws -> (failureRate: Double, failureMessages: [String: Int]) {
146169
let liveTestConfig = Configuration(logLevel: .error, enableInspection: true)
147170

148171
// We have to use the proper JavaScriptEnvironment here.
@@ -178,7 +201,7 @@ class LiveTests: XCTestCase {
178201
}
179202

180203
DispatchQueue.concurrentPerform(iterations: n) { i in
181-
let result = executeAndParseResults(program: programs[i], runner: runner)
204+
let result = executeAndParseResults(program: programs[i], runner: runner, timeoutInSeconds: timeoutInSeconds)
182205
results[i] = result
183206
}
184207

@@ -214,10 +237,11 @@ class LiveTests: XCTestCase {
214237
}
215238
}
216239

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

219242
do {
220-
let result = try runner.executeScript(program.jsProgram, withTimeout: 5 * Seconds)
243+
let result = try runner.executeScript(program.jsProgram,
244+
withTimeout: Double(timeoutInSeconds) * Seconds)
221245
if result.isFailure {
222246
var signature: String? = nil
223247

0 commit comments

Comments
 (0)