-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import XCTest | ||
import NIOCore | ||
@testable import NIOPosix | ||
import Atomics | ||
|
||
final class SALBootstrapTest: XCTestCase { //, SALTest { | ||
/* var group: MultiThreadedEventLoopGroup! | ||
var kernelToUserBox: LockedBox<KernelToUser>! | ||
var userToKernelBox: LockedBox<UserToKernel>! | ||
var wakeups: LockedBox<()>! | ||
override func setUp() { | ||
self.setUpSAL() | ||
} | ||
override func tearDown() { | ||
self.tearDownSAL() | ||
} | ||
func testPipeInvalidHandle() throws { | ||
let sock = socket(AF_LOCAL, SOCK_STREAM, 0) | ||
// close(sock) | ||
// There is only one loop in this group | ||
let eventLoop = self.group.next() | ||
let bootstrap = NIOPipeBootstrap(group: self.group) | ||
try eventLoop.runSAL(syscallAssertions: { | ||
try self.assertRegister { selectable, event, Registration in | ||
//XCTAssertEqual([.reset], event) | ||
//print("{sele}") | ||
return true | ||
} | ||
try self.assertDeregister { selectable in | ||
return true | ||
} | ||
try self.assertRegister { selectable, event, Registration in | ||
//XCTAssertEqual([.reset], event) | ||
//print("{sele}") | ||
return true | ||
} | ||
try self.assertDeregister { selectable in | ||
return true | ||
} | ||
try self.assertRegister { selectable, event, Registration in | ||
//XCTAssertEqual([.reset], event) | ||
//print("{sele}") | ||
return true | ||
} | ||
try self.assertDeregister { selectable in | ||
return true | ||
} | ||
}) { | ||
let channelFuture = bootstrap.takingOwnershipOfDescriptor(inputOutput: sock) | ||
let channel = try channelFuture.wait() | ||
} | ||
} */ | ||
|
||
func testReleaseFileHandleOnOwningFailure() { | ||
let sock = socket(AF_LOCAL, SOCK_STREAM, 0) | ||
defer { | ||
close(sock) | ||
} | ||
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 1) | ||
defer { | ||
try! elg.syncShutdownGracefully() | ||
} | ||
|
||
let bootstrap = NIOPipeBootstrap(validatingGroup: elg, hooks: NIOPipeBootstrapHooksChannelFail()) | ||
XCTAssertNotNil(bootstrap) | ||
|
||
let channelFuture = bootstrap?.takingOwnershipOfDescriptor(inputOutput: sock) | ||
XCTAssertThrowsError(try channelFuture?.wait()) | ||
} | ||
} | ||
|
||
|
||
struct NIOPipeBootstrapHooksChannelFail: NIOPipeBootstrapHooks { | ||
func makePipeChannel(eventLoop: NIOPosix.SelectableEventLoop, inputPipe: NIOCore.NIOFileHandle?, outputPipe: NIOCore.NIOFileHandle?) throws -> NIOPosix.PipeChannel { | ||
throw IOError(errnoCode: EBADF, reason: "testing") | ||
} | ||
} |