File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -27,17 +27,34 @@ import Testing
2727// MARK: PlatformOption Tests
2828@Suite ( . serialized)
2929struct SubprocessLinuxTests {
30- @Test func testSubprocessPlatformOptionsPreSpawnProcessConfigurator( ) async throws {
30+ @Test (
31+ . enabled(
32+ if: getgid ( ) == 0 ,
33+ " This test requires root privileges "
34+ )
35+ )
36+ func testSubprocessPlatformOptionsPreSpawnProcessConfigurator( ) async throws {
3137 var platformOptions = PlatformOptions ( )
3238 platformOptions. preSpawnProcessConfigurator = {
33- setgid ( 4321 )
39+ guard setgid ( 4321 ) == 0 else {
40+ // Returns EPERM when:
41+ // The calling process is not privileged (does not have the
42+ // CAP_SETGID capability in its user namespace), and gid does
43+ // not match the real group ID or saved set-group-ID of the
44+ // calling process.
45+ perror ( " setgid " )
46+ abort ( )
47+ }
3448 }
3549 let idResult = try await Subprocess . run (
3650 . path( " /usr/bin/id " ) ,
3751 arguments: [ " -g " ] ,
3852 platformOptions: platformOptions,
39- output: . string
53+ output: . string,
54+ error: . string
4055 )
56+ let error = try #require( idResult. standardError)
57+ try #require( error == " " )
4158 #expect( idResult. terminationStatus. isSuccess)
4259 let id = try #require( idResult. standardOutput)
4360 #expect(
You can’t perform that action at this time.
0 commit comments