mirror of
https://github.com/apple/swift-system
synced 2026-11-22 04:30:46 +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:
|
||||
create_merge_pr:
|
||||
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:
|
||||
base_branch: main
|
||||
head_branch: release/1.9.x
|
||||
|
||||
@@ -10,7 +10,7 @@ on:
|
||||
jobs:
|
||||
create_merge_pr:
|
||||
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:
|
||||
base_branch: release/1.9.x
|
||||
head_branch: release/1.8.x
|
||||
|
||||
@@ -10,7 +10,7 @@ on:
|
||||
jobs:
|
||||
tests:
|
||||
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:
|
||||
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
|
||||
linux_os_versions: '["noble", "jammy", "focal"]'
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
|
||||
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:
|
||||
enable_linux_checks: false
|
||||
enable_macos_checks: true
|
||||
@@ -75,7 +75,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
- name: Install Dependencies
|
||||
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
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -102,7 +105,7 @@ jobs:
|
||||
|
||||
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:
|
||||
license_header_check_project_name: "Swift.org"
|
||||
# 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
|
||||
#]]
|
||||
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
project(SwiftSystem
|
||||
LANGUAGES C Swift)
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ extension FileDescriptor {
|
||||
/// Duplicates this file descriptor and returns the newly created copy.
|
||||
///
|
||||
/// - 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
|
||||
/// that is not currently in use by the process.
|
||||
/// - 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.
|
||||
///
|
||||
/// 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
|
||||
public static var setUserID: FilePermissions { .init(rawValue: 0o4000) }
|
||||
|
||||
/// 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
|
||||
public static var setGroupID: FilePermissions { .init(rawValue: 0o2000) }
|
||||
|
||||
|
||||
@@ -179,11 +179,12 @@ final class FileOperationsTest: XCTestCase {
|
||||
}
|
||||
|
||||
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 {
|
||||
throw XCTSkip("pipe2 and PipeOptions require Darwin 27 or newer")
|
||||
}
|
||||
// Ad-hoc test testing `Pipe` functionality.
|
||||
// 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`.
|
||||
// Ad-hoc test: `MockTestCase` can't match the pointer to the local array
|
||||
// that `pipe` receives, because its address isn't known in advance.
|
||||
let options: FileDescriptor.PipeOptions = [.closeOnExec]
|
||||
let pipe: (readEnd: FileDescriptor, writeEnd: FileDescriptor)
|
||||
pipe = try FileDescriptor.pipe(options: options)
|
||||
@@ -194,16 +195,20 @@ final class FileOperationsTest: XCTestCase {
|
||||
_ = try pipe.writeEnd.write(UnsafeRawBufferPointer($0))
|
||||
}
|
||||
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))
|
||||
}
|
||||
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 {
|
||||
#if canImport(Darwin, _version: 428)
|
||||
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")
|
||||
}
|
||||
@@ -212,11 +217,31 @@ final class FileOperationsTest: XCTestCase {
|
||||
let pipe = try FileDescriptor.pipe(options: .closeOnFork)
|
||||
try pipe.readEnd.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)
|
||||
|
||||
#if !os(Windows)
|
||||
@@ -258,6 +283,7 @@ final class FileOperationsTest: XCTestCase {
|
||||
}
|
||||
|
||||
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 {
|
||||
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)
|
||||
|
||||
|
||||
@@ -16,15 +16,6 @@ import XCTest
|
||||
#endif
|
||||
|
||||
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 {
|
||||
try withTemporaryFilePath(basename: "test") { path in
|
||||
let strPath = String(decoding: path)
|
||||
|
||||
Reference in new issue
Block a user