File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ lazy_static! {
43
43
/// Any test that changes the process's current working directory must grab
44
44
/// this mutex
45
45
pub static ref CWD_MTX : Mutex <( ) > = Mutex :: new( ( ) ) ;
46
+ /// Any test that changes the process's supplementary groups must grab this
47
+ /// mutex
48
+ pub static ref GROUPS_MTX : Mutex <( ) > = Mutex :: new( ( ) ) ;
46
49
/// Any test that creates child processes must grab this mutex, regardless
47
50
/// of what it does with those children.
48
51
pub static ref FORK_MTX : Mutex <( ) > = Mutex :: new( ( ) ) ;
Original file line number Diff line number Diff line change @@ -128,9 +128,16 @@ mod linux_android {
128
128
fn test_setgroups ( ) {
129
129
// Skip this test when not run as root as `setgroups()` requires root.
130
130
if !Uid :: current ( ) . is_root ( ) {
131
+ use std:: io;
132
+ let stderr = io:: stderr ( ) ;
133
+ let mut handle = stderr. lock ( ) ;
134
+ writeln ! ( handle, "test_setgroups requires root privileges. Skipping test." ) . unwrap ( ) ;
131
135
return
132
136
}
133
137
138
+ #[ allow( unused_variables) ]
139
+ let m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
140
+
134
141
// Save the existing groups
135
142
let old_groups = getgroups ( ) . unwrap ( ) ;
136
143
@@ -152,9 +159,16 @@ fn test_initgroups() {
152
159
// Skip this test when not run as root as `initgroups()` and `setgroups()`
153
160
// require root.
154
161
if !Uid :: current ( ) . is_root ( ) {
162
+ use std:: io;
163
+ let stderr = io:: stderr ( ) ;
164
+ let mut handle = stderr. lock ( ) ;
165
+ writeln ! ( handle, "test_initgroups requires root privileges. Skipping test." ) . unwrap ( ) ;
155
166
return
156
167
}
157
168
169
+ #[ allow( unused_variables) ]
170
+ let m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
171
+
158
172
// Save the existing groups
159
173
let old_groups = getgroups ( ) . unwrap ( ) ;
160
174
You can’t perform that action at this time.
0 commit comments