mirror of
https://github.com/apple/swift-system
synced 2026-11-26 04:57:54 +00:00
41 lines
995 B
Swift
41 lines
995 B
Swift
import XCTest
|
|
|
|
#if SYSTEM_PACKAGE
|
|
import SystemPackage
|
|
#else
|
|
import System
|
|
#endif
|
|
|
|
final class AsyncFileDescriptorTests: XCTestCase {
|
|
func testOpen() async throws {
|
|
let ring = try ManagedIORing(queueDepth: 32)
|
|
let file = try await AsyncFileDescriptor.openat(
|
|
path: "/dev/zero",
|
|
.readOnly,
|
|
onRing: ring
|
|
)
|
|
}
|
|
|
|
func testOpenClose() async throws {
|
|
let ring = try ManagedIORing(queueDepth: 32)
|
|
let file = try await AsyncFileDescriptor.openat(
|
|
path: "/dev/zero",
|
|
.readOnly,
|
|
onRing: ring
|
|
)
|
|
await try file.close()
|
|
}
|
|
|
|
func testDevNullEmpty() async throws {
|
|
let ring = try ManagedIORing(queueDepth: 32)
|
|
let file = try await AsyncFileDescriptor.openat(
|
|
path: "/dev/null",
|
|
.readOnly,
|
|
onRing: ring
|
|
)
|
|
for try await _ in file {
|
|
XCTFail("/dev/null should be empty")
|
|
}
|
|
}
|
|
}
|