Skip to content

Commit e5b8264

Browse files
Accept .wat files in FuzzDifferential
1 parent 6c8284c commit e5b8264

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

FuzzTesting/Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let package = Package(
2121
]),
2222
.executableTarget(name: "FuzzDifferential", dependencies: [
2323
.product(name: "WasmKit", package: "WasmKit"),
24+
.product(name: "WAT", package: "WasmKit"),
2425
"WasmCAPI",
2526
]),
2627
.target(name: "WasmCAPI"),

FuzzTesting/Sources/FuzzDifferential/FuzzDifferential.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import WasmCAPI
22
import WasmKit
3+
import WAT
34
import SystemPackage
45
import Foundation
56

@@ -257,8 +258,13 @@ struct ReferenceEngine: Engine {
257258
WasmKitEngine(),
258259
ReferenceEngine()
259260
]
260-
let moduleBytes = try Data(contentsOf: URL(fileURLWithPath: moduleFile))
261-
let results = try engines.map { try $0.run(moduleBytes: Array(moduleBytes)) }
261+
let moduleBytes: [UInt8]
262+
if moduleFile.hasSuffix(".wat") {
263+
moduleBytes = try wat2wasm(String(contentsOf: URL(fileURLWithPath: moduleFile)))
264+
} else {
265+
moduleBytes = try Array(Data(contentsOf: URL(fileURLWithPath: moduleFile)))
266+
}
267+
let results = try engines.map { try $0.run(moduleBytes: moduleBytes) }
262268
guard results.count > 1 else {
263269
throw ExecError("Expected at least two engines")
264270
}

0 commit comments

Comments
 (0)