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 @@ -110,9 +110,16 @@ mod linux_android {
110
110
fn test_setgroups ( ) {
111
111
// Skip this test when not run as root as `setgroups()` requires root.
112
112
if !Uid :: current ( ) . is_root ( ) {
113
+ use std:: io;
114
+ let stderr = io:: stderr ( ) ;
115
+ let mut handle = stderr. lock ( ) ;
116
+ writeln ! ( handle, "test_setgroups requires root privileges. Skipping test." ) . unwrap ( ) ;
113
117
return
114
118
}
115
119
120
+ #[ allow( unused_variables) ]
121
+ let m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
122
+
116
123
// Save the existing groups
117
124
let old_groups = getgroups ( ) . unwrap ( ) ;
118
125
@@ -134,9 +141,16 @@ fn test_initgroups() {
134
141
// Skip this test when not run as root as `initgroups()` and `setgroups()`
135
142
// require root.
136
143
if !Uid :: current ( ) . is_root ( ) {
144
+ use std:: io;
145
+ let stderr = io:: stderr ( ) ;
146
+ let mut handle = stderr. lock ( ) ;
147
+ writeln ! ( handle, "test_initgroups requires root privileges. Skipping test." ) . unwrap ( ) ;
137
148
return
138
149
}
139
150
151
+ #[ allow( unused_variables) ]
152
+ let m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
153
+
140
154
// Save the existing groups
141
155
let old_groups = getgroups ( ) . unwrap ( ) ;
142
156
You can’t perform that action at this time.
0 commit comments