Fix failing build on MacOS (#2313)

# Motivation
Currently, the main branch fails to build for me since the `testSimpleMPTCP()` can't compile. This is due to the fact that the `getMPTCPInfo()` method is only available on Linux.

# Modification
Add `#if os(Linux)` around the `testSimpleMPTCP()`.

# Result
Main builds on MacOS again.
This commit is contained in:
Franz Busch 2022-11-15 09:25:35 +00:00 committed by GitHub
parent 0243bb4c8e
commit edced031e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 29 deletions

View File

@ -906,43 +906,48 @@ public final class SocketChannelTest : XCTestCase {
XCTAssertNoThrow(try serverSocket.close())
}
func testSimpleMPTCP() throws {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { XCTAssertNoThrow(try group.syncShutdownGracefully()) }
#if os(Linux)
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { XCTAssertNoThrow(try group.syncShutdownGracefully()) }
let serverChannel: Channel
let serverChannel: Channel
do {
serverChannel = try ServerBootstrap(group: group)
.enableMPTCP(true)
.bind(host: "127.0.0.1", port: 0)
.wait()
} catch let error as IOError {
// Older Linux kernel versions don't support MPTCP, which is fine.
if error.errnoCode != EINVAL && error.errnoCode != EPROTONOSUPPORT {
XCTFail("Unexpected error: \(error)")
do {
serverChannel = try ServerBootstrap(group: group)
.enableMPTCP(true)
.bind(host: "127.0.0.1", port: 0)
.wait()
} catch let error as IOError {
// Older Linux kernel versions don't support MPTCP, which is fine.
if error.errnoCode != EINVAL && error.errnoCode != EPROTONOSUPPORT {
XCTFail("Unexpected error: \(error)")
}
return
}
return
}
let clientChannel = try assertNoThrowWithValue(ClientBootstrap(group: group)
.enableMPTCP(true)
.connect(to: serverChannel.localAddress!)
.wait())
let clientChannel = try assertNoThrowWithValue(ClientBootstrap(group: group)
.enableMPTCP(true)
.connect(to: serverChannel.localAddress!)
.wait())
do {
let serverInfo = try (serverChannel as? SocketOptionProvider)?.getMPTCPInfo().wait()
let clientInfo = try (clientChannel as? SocketOptionProvider)?.getMPTCPInfo().wait()
do {
let serverInfo = try (serverChannel as? SocketOptionProvider)?.getMPTCPInfo().wait()
let clientInfo = try (clientChannel as? SocketOptionProvider)?.getMPTCPInfo().wait()
XCTAssertNotNil(serverInfo)
XCTAssertNotNil(clientInfo)
} catch let error as IOError {
// Some Linux kernel versions do support MPTCP but don't support the MPTCP_INFO
// option.
XCTAssertEqual(error.errnoCode, EOPNOTSUPP, "Unexpected error: \(error)")
return
}
XCTAssertNotNil(serverInfo)
XCTAssertNotNil(clientInfo)
} catch let error as IOError {
// Some Linux kernel versions do support MPTCP but don't support the MPTCP_INFO
// option.
XCTAssertEqual(error.errnoCode, EOPNOTSUPP, "Unexpected error: \(error)")
return
}
#endif
}
}
class DropAllReadsOnTheFloorHandler: ChannelDuplexHandler {