mirror of
https://github.com/apple/swift-system
synced 2026-11-29 05:24:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f1a3aceb1 | ||
|
|
1dc5cdc944 | ||
|
|
781b0cfab5 | ||
|
|
e96ba28879 | ||
|
|
c0e3eea428 | ||
|
|
53b1815f41 | ||
|
|
8e71dd3e0d | ||
|
|
677e51f1f2 | ||
|
|
cf29202fc7 | ||
|
|
406f7634f1 | ||
|
|
1da023b4ca | ||
|
|
abc83c2de1 | ||
|
|
2949c1bfcb | ||
|
|
fa6a245b37 | ||
|
|
762c819b0f |
No files matched your search
@@ -9,7 +9,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
create_merge_pr:
|
create_merge_pr:
|
||||||
name: Create PR to merge release branch into main branch
|
name: Create PR to merge release branch into main branch
|
||||||
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.17
|
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.18
|
||||||
with:
|
with:
|
||||||
base_branch: main
|
base_branch: main
|
||||||
head_branch: release/1.9.x
|
head_branch: release/1.9.x
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
create_merge_pr:
|
create_merge_pr:
|
||||||
name: Create PR to merge previous release branch into current release branch
|
name: Create PR to merge previous release branch into current release branch
|
||||||
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.17
|
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.18
|
||||||
with:
|
with:
|
||||||
base_branch: release/1.9.x
|
base_branch: release/1.9.x
|
||||||
head_branch: release/1.8.x
|
head_branch: release/1.8.x
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
name: Test
|
name: Test
|
||||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.17
|
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.18
|
||||||
with:
|
with:
|
||||||
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
|
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
|
||||||
linux_os_versions: '["noble", "jammy", "focal"]'
|
linux_os_versions: '["noble", "jammy", "focal"]'
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
|
|
||||||
build-abi-stable:
|
build-abi-stable:
|
||||||
name: Build ABI Stable
|
name: Build ABI Stable
|
||||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.17
|
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.18
|
||||||
with:
|
with:
|
||||||
enable_linux_checks: false
|
enable_linux_checks: false
|
||||||
enable_macos_checks: true
|
enable_macos_checks: true
|
||||||
@@ -75,7 +75,10 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: apt update && apt install -y cmake ninja-build jq
|
run: |
|
||||||
|
apt update && apt install -y curl ninja-build jq
|
||||||
|
curl -fsSL "https://github.com/Kitware/CMake/releases/download/v4.0.2/cmake-4.0.2-linux-$(uname -m).tar.gz" \
|
||||||
|
| tar --strip-components=1 -xz -C /usr/local
|
||||||
- name: Configure Project
|
- name: Configure Project
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -102,7 +105,7 @@ jobs:
|
|||||||
|
|
||||||
soundness:
|
soundness:
|
||||||
name: Soundness
|
name: Soundness
|
||||||
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.17
|
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.18
|
||||||
with:
|
with:
|
||||||
license_header_check_project_name: "Swift.org"
|
license_header_check_project_name: "Swift.org"
|
||||||
# https://github.com/apple/swift-system/issues/224
|
# https://github.com/apple/swift-system/issues/224
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ Licensed under Apache License v2.0 with Runtime Library Exception
|
|||||||
See https://swift.org/LICENSE.txt for license information
|
See https://swift.org/LICENSE.txt for license information
|
||||||
#]]
|
#]]
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16.0)
|
cmake_minimum_required(VERSION 3.29)
|
||||||
project(SwiftSystem
|
project(SwiftSystem
|
||||||
LANGUAGES C Swift)
|
LANGUAGES C Swift)
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ extension FileDescriptor {
|
|||||||
/// Duplicates this file descriptor and returns the newly created copy.
|
/// Duplicates this file descriptor and returns the newly created copy.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - `target`: The desired target file descriptor, or `nil`, in which case
|
/// - target: The desired target file descriptor, or `nil`, in which case
|
||||||
/// the copy is assigned to the file descriptor with the lowest raw value
|
/// the copy is assigned to the file descriptor with the lowest raw value
|
||||||
/// that is not currently in use by the process.
|
/// that is not currently in use by the process.
|
||||||
/// - retryOnInterrupt: Whether to retry the duplicate operation
|
/// - retryOnInterrupt: Whether to retry the duplicate operation
|
||||||
|
|||||||
@@ -113,13 +113,15 @@ public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
|
|||||||
|
|
||||||
/// Indicates that the file is executed as the owner.
|
/// Indicates that the file is executed as the owner.
|
||||||
///
|
///
|
||||||
/// For more information, see the `setuid(2)` man page.
|
/// For more information, see the `chmod(2)` man page's
|
||||||
|
/// discussion of `S_ISUID` (the set-user-ID bit).
|
||||||
@_alwaysEmitIntoClient
|
@_alwaysEmitIntoClient
|
||||||
public static var setUserID: FilePermissions { .init(rawValue: 0o4000) }
|
public static var setUserID: FilePermissions { .init(rawValue: 0o4000) }
|
||||||
|
|
||||||
/// Indicates that the file is executed as the group.
|
/// Indicates that the file is executed as the group.
|
||||||
///
|
///
|
||||||
/// For more information, see the `setgid(2)` man page.
|
/// For more information, see the `chmod(2)` man page's
|
||||||
|
/// discussion of `S_ISGID` (the set-group-ID bit).
|
||||||
@_alwaysEmitIntoClient
|
@_alwaysEmitIntoClient
|
||||||
public static var setGroupID: FilePermissions { .init(rawValue: 0o2000) }
|
public static var setGroupID: FilePermissions { .init(rawValue: 0o2000) }
|
||||||
|
|
||||||
|
|||||||
@@ -179,11 +179,12 @@ final class FileOperationsTest: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testAdHocPipeWithOptions() throws {
|
func testAdHocPipeWithOptions() throws {
|
||||||
|
#if !SYSTEM_PACKAGE_DARWIN || canImport(Darwin, _version: 428)
|
||||||
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
||||||
throw XCTSkip("pipe2 and PipeOptions require Darwin 27 or newer")
|
throw XCTSkip("pipe2 and PipeOptions require Darwin 27 or newer")
|
||||||
}
|
}
|
||||||
// Ad-hoc test testing `Pipe` functionality.
|
// Ad-hoc test: `MockTestCase` can't match the pointer to the local array
|
||||||
// We cannot test `Pipe` using `MockTestCase` because it calls `pipe` with a pointer to an array local to the `Pipe`, the address of which we do not know prior to invoking `Pipe`.
|
// that `pipe` receives, because its address isn't known in advance.
|
||||||
let options: FileDescriptor.PipeOptions = [.closeOnExec]
|
let options: FileDescriptor.PipeOptions = [.closeOnExec]
|
||||||
let pipe: (readEnd: FileDescriptor, writeEnd: FileDescriptor)
|
let pipe: (readEnd: FileDescriptor, writeEnd: FileDescriptor)
|
||||||
pipe = try FileDescriptor.pipe(options: options)
|
pipe = try FileDescriptor.pipe(options: options)
|
||||||
@@ -194,16 +195,20 @@ final class FileOperationsTest: XCTestCase {
|
|||||||
_ = try pipe.writeEnd.write(UnsafeRawBufferPointer($0))
|
_ = try pipe.writeEnd.write(UnsafeRawBufferPointer($0))
|
||||||
}
|
}
|
||||||
let readLen = 3
|
let readLen = 3
|
||||||
let readBytes = try Array<UInt8>(unsafeUninitializedCapacity: readLen) { buf, count in
|
let readBytes = try Array<UInt8>(unsafeUninitializedCapacity: readLen) {
|
||||||
|
buf, count in
|
||||||
count = try pipe.readEnd.read(into: UnsafeMutableRawBufferPointer(buf))
|
count = try pipe.readEnd.read(into: UnsafeMutableRawBufferPointer(buf))
|
||||||
}
|
}
|
||||||
XCTAssertEqual(readBytes, Array(abc.utf8))
|
XCTAssertEqual(readBytes, Array(abc.utf8))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
throw XCTSkip("pipe2 requires a Darwin SDK for anyAppleOS 27 or newer")
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if canImport(Darwin, _version: 428) // The macOS 27 SDK defines O_CLOFORK.
|
|
||||||
func testAdHocPipeCloseOnFork() throws {
|
func testAdHocPipeCloseOnFork() throws {
|
||||||
|
#if canImport(Darwin, _version: 428)
|
||||||
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
||||||
throw XCTSkip("pipe2 and PipeOptions require anyAppleOS 27 or newer")
|
throw XCTSkip("pipe2 and PipeOptions require anyAppleOS 27 or newer")
|
||||||
}
|
}
|
||||||
@@ -212,11 +217,31 @@ final class FileOperationsTest: XCTestCase {
|
|||||||
let pipe = try FileDescriptor.pipe(options: .closeOnFork)
|
let pipe = try FileDescriptor.pipe(options: .closeOnFork)
|
||||||
try pipe.readEnd.closeAfter {
|
try pipe.readEnd.closeAfter {
|
||||||
try pipe.writeEnd.closeAfter {
|
try pipe.writeEnd.closeAfter {
|
||||||
XCTAssertEqual(fcntl(pipe.readEnd.rawValue, F_GETFD) & FD_CLOFORK, FD_CLOFORK)
|
let flags = fcntl(pipe.readEnd.rawValue, F_GETFD)
|
||||||
|
XCTAssertEqual(flags & FD_CLOFORK, FD_CLOFORK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elseif os(FreeBSD)
|
||||||
|
let pipe: (readEnd: FileDescriptor, writeEnd: FileDescriptor)
|
||||||
|
do {
|
||||||
|
pipe = try FileDescriptor.pipe(options: .closeOnFork)
|
||||||
|
} catch {
|
||||||
|
if (error as? Errno) == .invalidArgument {
|
||||||
|
throw XCTSkip("pipe2 does not support O_CLOFORK before FreeBSD 15")
|
||||||
|
}
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
try pipe.readEnd.closeAfter {
|
||||||
|
try pipe.writeEnd.closeAfter {
|
||||||
|
let flags = fcntl(pipe.readEnd.rawValue, F_GETFD)
|
||||||
|
XCTAssertEqual(flags & FD_CLOEXEC, 0)
|
||||||
|
XCTAssertNotEqual(flags, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
throw XCTSkip("O_CLOFORK requires a Darwin SDK for anyAppleOS 27 or newer")
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif // !os(WASI)
|
#endif // !os(WASI)
|
||||||
|
|
||||||
#if !os(Windows)
|
#if !os(Windows)
|
||||||
@@ -258,6 +283,7 @@ final class FileOperationsTest: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testAdHocDuplicate3() throws {
|
func testAdHocDuplicate3() throws {
|
||||||
|
#if !SYSTEM_PACKAGE_DARWIN || canImport(Darwin, _version: 428)
|
||||||
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
||||||
throw XCTSkip("dup3 and DuplicateOptions require Darwin 27 or newer")
|
throw XCTSkip("dup3 and DuplicateOptions require Darwin 27 or newer")
|
||||||
}
|
}
|
||||||
@@ -292,6 +318,9 @@ final class FileOperationsTest: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
throw XCTSkip("dup3 requires a Darwin SDK for anyAppleOS 27 or newer")
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // !os(Windows)
|
#endif // !os(Windows)
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,6 @@ import XCTest
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
final class TemporaryPathTest: XCTestCase {
|
final class TemporaryPathTest: XCTestCase {
|
||||||
#if SYSTEM_PACKAGE_DARWIN
|
|
||||||
func testNotInSlashTmp() throws {
|
|
||||||
try withTemporaryFilePath(basename: "NotInSlashTmp") { path in
|
|
||||||
// We shouldn't be using "/tmp" on Darwin
|
|
||||||
XCTAssertNotEqual(path.components.first!, "tmp")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
func testUnique() throws {
|
func testUnique() throws {
|
||||||
try withTemporaryFilePath(basename: "test") { path in
|
try withTemporaryFilePath(basename: "test") { path in
|
||||||
let strPath = String(decoding: path)
|
let strPath = String(decoding: path)
|
||||||
|
|||||||
Reference in new issue
Block a user