Update to latest (8/4) toolchain.

This commit is contained in:
Bill Abt
2016-08-05 21:05:40 -04:00
parent 97781a6469
commit d1d9ea58fa
5 changed files with 167 additions and 29 deletions
+4 -6
View File
@@ -16,7 +16,7 @@
8CC36DF91C4EA1BE00BAA659 /* Socket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C0F4C031C4E8630008B2B0A /* Socket.swift */; };
8CC36DFA1C4EA1BE00BAA659 /* SocketUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C0F4C041C4E8630008B2B0A /* SocketUtils.swift */; };
8CC7217B1D4BCB1D00F5FD19 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 8CC7217A1D4BCB1D00F5FD19 /* LICENSE */; };
8CF04E291D4FCE4A00C27814 /* BasicSocketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CC721761D4BCA9400F5FD19 /* BasicSocketTests.swift */; };
8CF04E291D4FCE4A00C27814 /* SocketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CC721761D4BCA9400F5FD19 /* SocketTests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -30,7 +30,6 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
8C0039F11D4FE0F50064B65F /* XCTestManifests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = XCTestManifests.swift; path = Tests/SocketTests/XCTestManifests.swift; sourceTree = "<group>"; };
8C0F4BF61C4E84CC008B2B0A /* Socket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Socket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8C0F4BF91C4E84CC008B2B0A /* Socket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Socket.h; sourceTree = "<group>"; };
8C0F4BFB1C4E84CC008B2B0A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -41,7 +40,7 @@
8CA9B1631C98A00400E607FB /* SocketTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SocketTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8CC36E021C4EA1BE00BAA659 /* Socket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Socket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8CC36E041C4EA34700BAA659 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
8CC721761D4BCA9400F5FD19 /* BasicSocketTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BasicSocketTests.swift; path = Tests/SocketTests/BasicSocketTests.swift; sourceTree = "<group>"; };
8CC721761D4BCA9400F5FD19 /* SocketTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTests.swift; path = Tests/SocketTests/SocketTests.swift; sourceTree = "<group>"; };
8CC721781D4BCAA600F5FD19 /* LinuxMain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LinuxMain.swift; path = Tests/LinuxMain.swift; sourceTree = "<group>"; };
8CC7217A1D4BCB1D00F5FD19 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
8CF04E231D4BD03D00C27814 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Tests/SocketTests/Info.plist; sourceTree = "<group>"; };
@@ -119,8 +118,7 @@
isa = PBXGroup;
children = (
8CF04E231D4BD03D00C27814 /* Info.plist */,
8CC721761D4BCA9400F5FD19 /* BasicSocketTests.swift */,
8C0039F11D4FE0F50064B65F /* XCTestManifests.swift */,
8CC721761D4BCA9400F5FD19 /* SocketTests.swift */,
);
name = SocketTests;
sourceTree = "<group>";
@@ -289,7 +287,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8CF04E291D4FCE4A00C27814 /* BasicSocketTests.swift in Sources */,
8CF04E291D4FCE4A00C27814 /* SocketTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+2 -2
View File
@@ -1,5 +1,5 @@
![](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)
![](https://img.shields.io/badge/Snapshot-7/29-blue.svg?style=flat)
![](https://img.shields.io/badge/Snapshot-8/4-blue.svg?style=flat)
# BlueSocket
@@ -13,7 +13,7 @@ Socket framework for Swift using the Swift Package Manager. Works on macOS and L
## Prerequisites
### Swift
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-07-29-a` toolchain (**Minimum REQUIRED for latest release**)
* Swift Open Source `swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a` toolchain (**Minimum REQUIRED for latest release**)
### macOS
+14 -14
View File
@@ -282,10 +282,10 @@ public class Socket: SocketReader, SocketWriter {
switch self {
case .ipv4(let addr):
return sizeofValue(addr)
case .ipv6(let addr):
return sizeofValue(addr)
case .ipv4( _):
return MemoryLayout<(sockaddr_in)>.size
case .ipv6( _):
return MemoryLayout<(sockaddr_in6)>.size
}
}
@@ -1026,7 +1026,7 @@ public class Socket: SocketReader, SocketWriter {
case .inet:
var acceptAddr = sockaddr_in()
var addrSize = socklen_t(sizeofValue(acceptAddr))
var addrSize = socklen_t(MemoryLayout<sockaddr_in>.size)
#if os(Linux)
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
@@ -1050,7 +1050,7 @@ public class Socket: SocketReader, SocketWriter {
case .inet6:
var acceptAddr = sockaddr_in6()
var addrSize = socklen_t(sizeofValue(acceptAddr))
var addrSize = socklen_t(MemoryLayout<sockaddr_in6>.size)
#if os(Linux)
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
@@ -1136,7 +1136,7 @@ public class Socket: SocketReader, SocketWriter {
case .inet:
var acceptAddr = sockaddr_in()
var addrSize = socklen_t(sizeofValue(acceptAddr))
var addrSize = socklen_t(MemoryLayout<sockaddr_in>.size)
#if os(Linux)
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
@@ -1160,7 +1160,7 @@ public class Socket: SocketReader, SocketWriter {
case .inet6:
var acceptAddr = sockaddr_in6()
var addrSize = socklen_t(sizeofValue(acceptAddr))
var addrSize = socklen_t(MemoryLayout<sockaddr_in6>.size)
#if os(Linux)
let fd = withUnsafeMutablePointer(to: &acceptAddr) {
@@ -1410,13 +1410,13 @@ public class Socket: SocketReader, SocketWriter {
if info!.pointee.ai_family == Int32(AF_INET6) {
var addr = sockaddr_in6()
memcpy(&addr, info!.pointee.ai_addr, Int(sizeofValue(addr)))
memcpy(&addr, info!.pointee.ai_addr, Int(MemoryLayout<sockaddr_in6>.size))
address = .ipv6(addr)
} else if info!.pointee.ai_family == Int32(AF_INET) {
var addr = sockaddr_in()
memcpy(&addr, info!.pointee.ai_addr, Int(sizeofValue(addr)))
memcpy(&addr, info!.pointee.ai_addr, Int(MemoryLayout<sockaddr_in>.size))
address = .ipv4(addr)
} else {
@@ -1556,7 +1556,7 @@ public class Socket: SocketReader, SocketWriter {
// Set a flag so that this address can be re-used immediately after the connection
// closes. (TCP normally imposes a delay before an address can be re-used.)
var on: Int32 = 1
if setsockopt(self.socketfd, SOL_SOCKET, SO_REUSEADDR, &on, socklen_t(sizeof(Int32.self))) < 0 {
if setsockopt(self.socketfd, SOL_SOCKET, SO_REUSEADDR, &on, socklen_t(MemoryLayout<Int32>.size)) < 0 {
throw Error(code: Socket.SOCKET_ERR_SETSOCKOPT_FAILED, reason: self.lastError())
}
@@ -1565,7 +1565,7 @@ public class Socket: SocketReader, SocketWriter {
// Set the socket to ignore SIGPIPE to avoid dying on interrupted connections...
// Note: Linux does not support the SO_NOSIGPIPE option. Instead, we use the
// MSG_NOSIGNAL flags passed to send. See the writeData() functions below.
if setsockopt(self.socketfd, SOL_SOCKET, SO_NOSIGPIPE, &on, socklen_t(sizeof(Int32.self))) < 0 {
if setsockopt(self.socketfd, SOL_SOCKET, SO_NOSIGPIPE, &on, socklen_t(MemoryLayout<Int32>.size)) < 0 {
throw Error(code: Socket.SOCKET_ERR_SETSOCKOPT_FAILED, reason: self.lastError())
}
@@ -1674,13 +1674,13 @@ public class Socket: SocketReader, SocketWriter {
if info!.pointee.ai_family == Int32(AF_INET6) {
var addr = sockaddr_in6()
memcpy(&addr, info!.pointee.ai_addr, Int(sizeofValue(addr)))
memcpy(&addr, info!.pointee.ai_addr, Int(MemoryLayout<sockaddr_in6>.size))
address = .ipv6(addr)
} else if info!.pointee.ai_family == Int32(AF_INET) {
var addr = sockaddr_in()
memcpy(&addr, info!.pointee.ai_addr, Int(sizeofValue(addr)))
memcpy(&addr, info!.pointee.ai_addr, Int(MemoryLayout<sockaddr_in>.size))
address = .ipv4(addr)
} else {
+5 -7
View File
@@ -1,6 +1,6 @@
//
// LinuxMain.swift
// Socket
// BlueSocket
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,10 +17,8 @@
import XCTest
import SocketTests
@testable import SocketTests
var tests = [XCTestCaseEntry]()
tests += BasicSocketTests.allTests()
XCTMain(tests)
XCTMain([
testCase(SocketTests.allTests),
])
+142
View File
@@ -0,0 +1,142 @@
//
// BasicSocketTests.swift
// BlueSocket
//
// Created by Bill Abt on 3/15/16.
// Copyright © 2016 IBM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import XCTest
@testable import Socket
class SocketTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testSocket() {
do {
let port:Int32 = 1337
let socket = try Socket.create()
XCTAssertNotNil(socket)
XCTAssertFalse(socket.isConnected)
XCTAssertTrue(socket.isBlocking)
try socket.listen(on: Int(port), maxBacklogSize: 10)
XCTAssertTrue(socket.isListening)
XCTAssertEqual(socket.listeningPort, port)
socket.close()
XCTAssertFalse(socket.isActive)
} catch let error {
// See if it's a socket error or something else...
guard let socketError = error as? Socket.Error else {
print("Unexpected error...")
XCTFail()
return
}
print("Error reported: \(socketError.description)")
XCTFail()
}
}
func testDefaultCreate() {
do {
// Create the socket...
let socket = try Socket.create()
XCTAssertNotNil(socket)
// Get the Signature...
let sig = socket.signature
XCTAssertNotNil(sig)
// Check to ensure the family, type and protocol are correct...
XCTAssertEqual(sig!.protocolFamily, Socket.ProtocolFamily.inet)
XCTAssertEqual(sig!.socketType, Socket.SocketType.stream)
XCTAssertEqual(sig!.proto, Socket.SocketProtocol.tcp)
socket.close()
XCTAssertFalse(socket.isActive)
} catch let error {
// See if it's a socket error or something else...
guard let socketError = error as? Socket.Error else {
print("Unexpected error...")
XCTFail()
return
}
print("Error reported: \(socketError.description)")
XCTFail()
}
}
func testCreateIPV6() {
do {
// Create the socket...
let socket = try Socket.create(family: .inet6)
XCTAssertNotNil(socket)
// Get the Signature...
let sig = socket.signature
XCTAssertNotNil(sig)
// Check to ensure the family, type and protocol are correct...
XCTAssertEqual(sig!.protocolFamily, Socket.ProtocolFamily.inet6)
XCTAssertEqual(sig!.socketType, Socket.SocketType.stream)
XCTAssertEqual(sig!.proto, Socket.SocketProtocol.tcp)
socket.close()
XCTAssertFalse(socket.isActive)
} catch let error {
// See if it's a socket error or something else...
guard let socketError = error as? Socket.Error else {
print("Unexpected error...")
XCTFail()
return
}
print("Error reported: \(socketError.description)")
XCTFail()
}
}
static var allTests = [
("testSocket", testSocket),
("testDefaultCreate", testDefaultCreate),
("testCreateIPV6", testCreateIPV6),
]
}