|
17 | 17 | import ArgumentParser |
18 | 18 | import Containerization |
19 | 19 | import ContainerizationOCI |
| 20 | +import ContainerizationOS |
20 | 21 | import Crypto |
21 | 22 | import Foundation |
22 | 23 | import Logging |
@@ -261,6 +262,44 @@ extension IntegrationSuite { |
261 | 262 | } |
262 | 263 | } |
263 | 264 |
|
| 265 | + // Ensure if we ask for a terminal we set TERM. |
| 266 | + func testProcessTtyEnvvar() async throws { |
| 267 | + let id = "test-process-tty-envvar" |
| 268 | + |
| 269 | + let bs = try await bootstrap() |
| 270 | + let container = LinuxContainer( |
| 271 | + id, |
| 272 | + rootfs: bs.rootfs, |
| 273 | + vmm: bs.vmm |
| 274 | + ) |
| 275 | + container.arguments = ["env"] |
| 276 | + container.terminal = true |
| 277 | + |
| 278 | + let buffer = BufferWriter() |
| 279 | + container.stdout = buffer |
| 280 | + |
| 281 | + try await container.create() |
| 282 | + try await container.start() |
| 283 | + |
| 284 | + let status = try await container.wait() |
| 285 | + try await container.stop() |
| 286 | + |
| 287 | + guard status == 0 else { |
| 288 | + throw IntegrationError.assert(msg: "process status \(status) != 0") |
| 289 | + } |
| 290 | + |
| 291 | + guard let str = String(data: buffer.data, encoding: .utf8) else { |
| 292 | + throw IntegrationError.assert( |
| 293 | + msg: "failed to convert standard output to a UTF8 string") |
| 294 | + } |
| 295 | + |
| 296 | + let homeEnvvar = "TERM=xterm" |
| 297 | + guard str.contains(homeEnvvar) else { |
| 298 | + throw IntegrationError.assert( |
| 299 | + msg: "process should have TERM environment variable defined") |
| 300 | + } |
| 301 | + } |
| 302 | + |
264 | 303 | // Make sure we set HOME by default if we can find it in /etc/passwd in the guest. |
265 | 304 | func testProcessHomeEnvvar() async throws { |
266 | 305 | let id = "test-process-home-envvar" |
|
0 commit comments