Skip to content

Commit 11e1720

Browse files
authored
Merge branch 'main' into users/realrajaryan/fsnotify
2 parents ff6ff79 + 06d3a37 commit 11e1720

File tree

223 files changed

+1785
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+1785
-235
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
1+
# Copyright © 2025 Apple Inc. and the Containerization project authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@ SWIFT_CONFIGURATION = $(if $(filter-out false,$(WARNINGS_AS_ERRORS)),-Xswiftc -w
2222
SWIFT := "/usr/bin/swift"
2323
ROOT_DIR := $(shell git rev-parse --show-toplevel)
2424
BUILD_BIN_DIR = $(shell $(SWIFT) build -c $(BUILD_CONFIGURATION) --show-bin-path)
25+
COV_DATA_DIR = $(shell $(SWIFT) test --show-coverage-path | xargs dirname)
26+
COV_REPORT_FILE = $(ROOT_DIR)/code-coverage-report
2527

2628
# Variables for libarchive integration
2729
LIBARCHIVE_UPSTREAM_REPO := https://github.com/libarchive/libarchive
@@ -90,6 +92,18 @@ test:
9092
@echo Testing all test targets...
9193
@$(SWIFT) test --enable-code-coverage $(SWIFT_CONFIGURATION)
9294

95+
.PHONY: coverage
96+
coverage: test
97+
@echo Generating code coverage report...
98+
@xcrun llvm-cov show --compilation-dir=`pwd` \
99+
-instr-profile=$(COV_DATA_DIR)/default.profdata \
100+
--ignore-filename-regex=".build/" \
101+
--ignore-filename-regex=".pb.swift" \
102+
--ignore-filename-regex=".proto" \
103+
--ignore-filename-regex=".grpc.swift" \
104+
$(BUILD_BIN_DIR)/containerizationPackageTests.xctest/Contents/MacOS/containerizationPackageTests > $(COV_REPORT_FILE)
105+
@echo Code coverage report generated: $(COV_REPORT_FILE)
106+
93107
.PHONY: integration
94108
integration:
95109
ifeq (,$(wildcard bin/vmlinux))
@@ -159,5 +173,6 @@ clean:
159173
@rm -rf bin/
160174
@rm -rf _site/
161175
@rm -rf _serve/
176+
@rm -f $(COV_REPORT_FILE)
162177
@$(SWIFT) package clean
163178
@"$(MAKE)" -C vminitd clean

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// swift-tools-version: 6.2
22
//===----------------------------------------------------------------------===//
3-
// Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
3+
// Copyright © 2025 Apple Inc. and the Containerization project authors.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

Sources/CShim/exec_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
* Copyright © 2025 Apple Inc. and the Containerization project authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

Sources/CShim/include/exec_command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
* Copyright © 2025 Apple Inc. and the Containerization project authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

Sources/CShim/include/vsock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
* Copyright © 2025 Apple Inc. and the Containerization project authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

Sources/CShim/vsock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
* Copyright © 2025 Apple Inc. and the Containerization project authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

Sources/Containerization/AttachedFilesystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//===----------------------------------------------------------------------===//
2-
// Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
// Copyright © 2025 Apple Inc. and the Containerization project authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.

Sources/Containerization/Container.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//===----------------------------------------------------------------------===//
2-
// Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
// Copyright © 2025 Apple Inc. and the Containerization project authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.

Sources/Containerization/ContainerManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//===----------------------------------------------------------------------===//
2-
// Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved.
2+
// Copyright © 2025 Apple Inc. and the Containerization project authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2025 Apple Inc. and the Containerization project authors.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
17+
/// Statistics for a container.
18+
public struct ContainerStatistics: Sendable {
19+
public var id: String
20+
public var process: ProcessStatistics
21+
public var memory: MemoryStatistics
22+
public var cpu: CPUStatistics
23+
public var blockIO: BlockIOStatistics
24+
public var networks: [NetworkStatistics]
25+
26+
public init(
27+
id: String,
28+
process: ProcessStatistics,
29+
memory: MemoryStatistics,
30+
cpu: CPUStatistics,
31+
blockIO: BlockIOStatistics,
32+
networks: [NetworkStatistics]
33+
) {
34+
self.id = id
35+
self.process = process
36+
self.memory = memory
37+
self.cpu = cpu
38+
self.blockIO = blockIO
39+
self.networks = networks
40+
}
41+
42+
/// Process statistics for a container.
43+
public struct ProcessStatistics: Sendable {
44+
public var current: UInt64
45+
public var limit: UInt64
46+
47+
public init(current: UInt64, limit: UInt64) {
48+
self.current = current
49+
self.limit = limit
50+
}
51+
}
52+
53+
/// Memory statistics for a container.
54+
public struct MemoryStatistics: Sendable {
55+
public var usageBytes: UInt64
56+
public var limitBytes: UInt64
57+
public var swapUsageBytes: UInt64
58+
public var swapLimitBytes: UInt64
59+
public var cacheBytes: UInt64
60+
public var kernelStackBytes: UInt64
61+
public var slabBytes: UInt64
62+
public var pageFaults: UInt64
63+
public var majorPageFaults: UInt64
64+
65+
public init(
66+
usageBytes: UInt64,
67+
limitBytes: UInt64,
68+
swapUsageBytes: UInt64,
69+
swapLimitBytes: UInt64,
70+
cacheBytes: UInt64,
71+
kernelStackBytes: UInt64,
72+
slabBytes: UInt64,
73+
pageFaults: UInt64,
74+
majorPageFaults: UInt64
75+
) {
76+
self.usageBytes = usageBytes
77+
self.limitBytes = limitBytes
78+
self.swapUsageBytes = swapUsageBytes
79+
self.swapLimitBytes = swapLimitBytes
80+
self.cacheBytes = cacheBytes
81+
self.kernelStackBytes = kernelStackBytes
82+
self.slabBytes = slabBytes
83+
self.pageFaults = pageFaults
84+
self.majorPageFaults = majorPageFaults
85+
}
86+
}
87+
88+
/// CPU statistics for a container.
89+
public struct CPUStatistics: Sendable {
90+
public var usageUsec: UInt64
91+
public var userUsec: UInt64
92+
public var systemUsec: UInt64
93+
public var throttlingPeriods: UInt64
94+
public var throttledPeriods: UInt64
95+
public var throttledTimeUsec: UInt64
96+
97+
public init(
98+
usageUsec: UInt64,
99+
userUsec: UInt64,
100+
systemUsec: UInt64,
101+
throttlingPeriods: UInt64,
102+
throttledPeriods: UInt64,
103+
throttledTimeUsec: UInt64
104+
) {
105+
self.usageUsec = usageUsec
106+
self.userUsec = userUsec
107+
self.systemUsec = systemUsec
108+
self.throttlingPeriods = throttlingPeriods
109+
self.throttledPeriods = throttledPeriods
110+
self.throttledTimeUsec = throttledTimeUsec
111+
}
112+
}
113+
114+
/// Block I/O statistics for a container.
115+
public struct BlockIOStatistics: Sendable {
116+
public var devices: [BlockIODevice]
117+
118+
public init(devices: [BlockIODevice]) {
119+
self.devices = devices
120+
}
121+
}
122+
123+
/// Block I/O statistics for a specific device.
124+
public struct BlockIODevice: Sendable {
125+
public var major: UInt64
126+
public var minor: UInt64
127+
public var readBytes: UInt64
128+
public var writeBytes: UInt64
129+
public var readOperations: UInt64
130+
public var writeOperations: UInt64
131+
132+
public init(
133+
major: UInt64,
134+
minor: UInt64,
135+
readBytes: UInt64,
136+
writeBytes: UInt64,
137+
readOperations: UInt64,
138+
writeOperations: UInt64
139+
) {
140+
self.major = major
141+
self.minor = minor
142+
self.readBytes = readBytes
143+
self.writeBytes = writeBytes
144+
self.readOperations = readOperations
145+
self.writeOperations = writeOperations
146+
}
147+
}
148+
149+
/// Statistics for a network interface.
150+
public struct NetworkStatistics: Sendable {
151+
public var interface: String
152+
public var receivedPackets: UInt64
153+
public var transmittedPackets: UInt64
154+
public var receivedBytes: UInt64
155+
public var transmittedBytes: UInt64
156+
public var receivedErrors: UInt64
157+
public var transmittedErrors: UInt64
158+
159+
public init(
160+
interface: String,
161+
receivedPackets: UInt64,
162+
transmittedPackets: UInt64,
163+
receivedBytes: UInt64,
164+
transmittedBytes: UInt64,
165+
receivedErrors: UInt64,
166+
transmittedErrors: UInt64
167+
) {
168+
self.interface = interface
169+
self.receivedPackets = receivedPackets
170+
self.transmittedPackets = transmittedPackets
171+
self.receivedBytes = receivedBytes
172+
self.transmittedBytes = transmittedBytes
173+
self.receivedErrors = receivedErrors
174+
self.transmittedErrors = transmittedErrors
175+
}
176+
}
177+
}

0 commit comments

Comments
 (0)