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
27
27
// MARK: PlatformOption Tests
28
28
@Suite ( . serialized)
29
29
struct 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 {
31
37
var platformOptions = PlatformOptions ( )
32
38
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
+ }
34
48
}
35
49
let idResult = try await Subprocess . run (
36
50
. path( " /usr/bin/id " ) ,
37
51
arguments: [ " -g " ] ,
38
52
platformOptions: platformOptions,
39
- output: . string
53
+ output: . string,
54
+ error: . string
40
55
)
56
+ let error = try #require( idResult. standardError)
57
+ try #require( error == " " )
41
58
#expect( idResult. terminationStatus. isSuccess)
42
59
let id = try #require( idResult. standardOutput)
43
60
#expect(
You can’t perform that action at this time.
0 commit comments