11import WasmKit
2+ import WasmKitFuzzing
23import XCTest
34
45final class FuzzTranslatorRegressionTests : XCTestCase {
5- func testRunAll( ) async throws {
6+ func testRunAll( ) throws {
67 let sourceRoot = URL ( fileURLWithPath: #filePath)
78 . deletingLastPathComponent ( ) . deletingLastPathComponent ( ) . deletingLastPathComponent ( )
89 let failCasesDir =
@@ -12,33 +13,11 @@ final class FuzzTranslatorRegressionTests: XCTestCase {
1213 for file in try FileManager . default. contentsOfDirectory ( atPath: failCasesDir. path) {
1314 let path = failCasesDir. appendingPathComponent ( file) . path
1415 print ( " Fuzz regression test: \( path. dropFirst ( sourceRoot. path. count + 1 ) ) " )
15-
1616 let data = try Data ( contentsOf: URL ( fileURLWithPath: path) )
1717 do {
18- let module = try WasmKit . parseWasm ( bytes: Array ( data) )
19- let engine = Engine ( configuration: EngineConfiguration ( compilationMode: . eager) )
20- let store = Store ( engine: engine)
21- var imports = Imports ( )
22- for importEntry in module. imports {
23- let value : ExternalValueConvertible
24- switch importEntry. descriptor {
25- case . function( let typeIndex) :
26- let type = module. types [ Int ( typeIndex) ]
27- value = Function ( store: store, type: type) { _, _ in
28- fatalError ( " unreachable " )
29- }
30- case . global( let globalType) :
31- value = try Global ( store: store, type: globalType, value: . i32( 0 ) )
32- case . memory( let memoryType) :
33- value = try Memory ( store: store, type: memoryType)
34- case . table( let tableType) :
35- value = try Table ( store: store, type: tableType)
36- }
37- imports. define ( module: importEntry. module, name: importEntry. name, value. externalValue)
38- }
39- _ = try module. instantiate ( store: store, imports: imports)
18+ try WasmKitFuzzing . fuzzInstantiation ( bytes: Array ( data) )
4019 } catch {
41- // Explicit errors are ok
20+ // Skip exceptions without crash
4221 }
4322 }
4423 }
0 commit comments