Skip to content

Commit 3c89f3f

Browse files
Update wasi-testsuite to the latest
1 parent 827056b commit 3c89f3f

File tree

2 files changed

+120
-25
lines changed

2 files changed

+120
-25
lines changed

Tests/WASITests/IntegrationTests.swift

Lines changed: 119 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,135 @@ final class IntegrationTests: XCTestCase {
1212
let testDir = URL(fileURLWithPath: #filePath)
1313
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
1414
.appendingPathComponent("Vendor/wasi-testsuite")
15+
var failedTests = [FailedTest]()
1516
for testSuitePath in ["tests/assemblyscript/testsuite", "tests/c/testsuite", "tests/rust/testsuite"] {
1617
let suitePath = testDir.appendingPathComponent(testSuitePath)
17-
try runTestSuite(path: suitePath)
18+
failedTests.append(contentsOf: try runTestSuite(path: suitePath))
19+
}
20+
21+
if !failedTests.isEmpty {
22+
XCTFail("Failed tests: \(failedTests.map { "\($0.suite)/\($0.name)" }.joined(separator: ", "))")
23+
24+
if ProcessInfo.processInfo.environment["WASMKIT_WASI_DUMP_SKIPS"] != nil {
25+
var itemsToSkip = [String: [String: String]]()
26+
for test in failedTests {
27+
itemsToSkip[test.suite, default: [:]][test.name] = "Not implemented"
28+
}
29+
let encoder = JSONEncoder()
30+
encoder.outputFormatting = .prettyPrinted
31+
print(String(data: try encoder.encode(itemsToSkip), encoding: .utf8)!)
32+
}
1833
}
1934
}
2035

36+
struct FailedTest {
37+
let suite: String
38+
let name: String
39+
let path: URL
40+
let reason: String
41+
}
2142
struct SuiteManifest: Codable {
2243
let name: String
2344
}
2445

25-
static var skipTests: [String: [String: String]] {
46+
static var skipTests: [String: Set<String>] {
2647
#if os(Windows)
2748
return [
28-
"WASI Assemblyscript tests": [:],
49+
"WASI Assemblyscript tests": [],
2950
"WASI C tests": [
30-
"fdopendir-with-access": "Not implemented",
31-
"fopen-with-access": "Not implemented",
32-
"lseek": "Not implemented",
33-
"pread-with-access": "Not implemented",
34-
"pwrite-with-access": "Not implemented",
35-
"stat-dev-ino": "Not implemented",
51+
"fdopendir-with-access",
52+
"fopen-with-access",
53+
"lseek",
54+
"pread-with-access",
55+
"pwrite-with-access",
56+
"pwrite-with-append",
57+
"sock_shutdown-invalid_fd",
58+
"sock_shutdown-not_sock",
59+
"stat-dev-ino",
3660
],
3761
"WASI Rust tests": [
38-
"close_preopen": "Not implemented",
39-
"dangling_fd": "Not implemented",
40-
"dangling_symlink": "Not implemented",
41-
"directory_seek": "Not implemented",
42-
"fd_advise": "Not implemented",
43-
"fd_filestat_set": "Not implemented",
44-
"fd_flags_set": "Not implemented",
45-
"fd_readdir": "Not implemented",
46-
"interesting_paths": "Not implemented",
62+
"close_preopen",
63+
"dangling_fd",
64+
"dangling_symlink",
65+
"dir_fd_op_failures",
66+
"directory_seek",
67+
"fd_advise",
68+
"fd_fdstat_set_rights",
69+
"fd_filestat_set",
70+
"fd_flags_set",
71+
"fd_readdir",
72+
"file_allocate",
73+
"file_pread_pwrite",
74+
"file_seek_tell",
75+
"file_truncation",
76+
"file_unbuffered_write",
77+
"fstflags_validate",
78+
"interesting_paths",
79+
"isatty",
80+
"nofollow_errors",
81+
"overwrite_preopen",
82+
"path_exists",
83+
"path_filestat",
84+
"path_link",
85+
"path_open_create_existing",
86+
"path_open_dirfd_not_dir",
87+
"path_open_missing",
88+
"path_open_nonblock",
89+
"path_open_preopen",
90+
"path_open_read_write",
91+
"path_rename",
92+
"path_rename_dir_trailing_slashes",
93+
"path_symlink_trailing_slashes",
94+
"poll_oneoff_stdio",
95+
"readlink",
96+
"remove_directory_trailing_slashes",
97+
"remove_nonempty_directory",
98+
"renumber",
99+
"sched_yield",
100+
"stdio",
101+
"symlink_create",
102+
"symlink_filestat",
103+
"symlink_loop",
104+
"truncation_rights",
105+
"unlink_file_trailing_slashes",
47106
],
48107
]
49108
#else
50-
return [:]
109+
var tests: [String: Set<String>] = [
110+
"WASI Rust tests": [
111+
"path_link",
112+
"dir_fd_op_failures",
113+
"path_rename_dir_trailing_slashes",
114+
"path_rename",
115+
"pwrite-with-append",
116+
"poll_oneoff_stdio",
117+
"overwrite_preopen",
118+
"path_filestat",
119+
"renumber",
120+
"symlink_filestat",
121+
"path_open_read_write",
122+
"path_open_preopen",
123+
"fd_fdstat_set_rights",
124+
"file_allocate",
125+
"stdio",
126+
"remove_directory_trailing_slashes",
127+
"symlink_create",
128+
"readlink",
129+
"sched_yield",
130+
],
131+
"WASI C tests": [
132+
"sock_shutdown-invalid_fd",
133+
"sock_shutdown-not_sock",
134+
],
135+
]
136+
#if os(Linux)
137+
tests["WASI C tests"]?.insert("pwrite-with-append")
138+
#endif
139+
return tests
51140
#endif
52141
}
53142

54-
func runTestSuite(path: URL) throws {
143+
func runTestSuite(path: URL) throws -> [FailedTest] {
55144
let manifestPath = path.appendingPathComponent("manifest.json")
56145
let manifest = try JSONDecoder().decode(SuiteManifest.self, from: Data(contentsOf: manifestPath))
57146

@@ -68,17 +157,23 @@ final class IntegrationTests: XCTestCase {
68157
print("Running test suite: \(manifest.name)")
69158
let tests = try FileManager.default.contentsOfDirectory(at: path, includingPropertiesForKeys: nil, options: [])
70159

71-
let skipTests = Self.skipTests[manifest.name] ?? [:]
160+
let skipTests = Self.skipTests[manifest.name] ?? []
72161

162+
var failedTests = [FailedTest]()
73163
for test in tests {
74164
guard test.pathExtension == "wasm" else { continue }
75165
let testName = test.deletingPathExtension().lastPathComponent
76-
if let reason = skipTests[testName] {
77-
print("Skipping test \(testName): \(reason)")
166+
if skipTests.contains(testName) {
167+
print("Skipping test \(testName)")
78168
continue
79169
}
80-
try runTest(path: test)
170+
do {
171+
try runTest(path: test)
172+
} catch {
173+
failedTests.append(FailedTest(suite: manifest.name, name: testName, path: test, reason: String(describing: error)))
174+
}
81175
}
176+
return failedTests
82177
}
83178

84179
struct CaseManifest: Codable {

Vendor/dependencies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"wasi-testsuite": {
88
"repository": "https://github.com/WebAssembly/wasi-testsuite.git",
9-
"revision": "c9c751586fd86b321d595bbef13f2c7403cfdbc5",
9+
"revision": "f442fae1a214263aeeddb5395c0c50dc9403b7f8",
1010
"categories": ["default"]
1111
},
1212
"wasm-c-api": {

0 commit comments

Comments
 (0)