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! {
4343 /// Any test that changes the process's current working directory must grab
4444 /// this mutex
4545 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( ( ) ) ;
4649 /// Any test that creates child processes must grab this mutex, regardless
4750 /// of what it does with those children.
4851 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 {
128128fn test_setgroups ( ) {
129129 // Skip this test when not run as root as `setgroups()` requires root.
130130 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 ( ) ;
131135 return
132136 }
133137
138+ #[ allow( unused_variables) ]
139+ let m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
140+
134141 // Save the existing groups
135142 let old_groups = getgroups ( ) . unwrap ( ) ;
136143
@@ -152,9 +159,16 @@ fn test_initgroups() {
152159 // Skip this test when not run as root as `initgroups()` and `setgroups()`
153160 // require root.
154161 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 ( ) ;
155166 return
156167 }
157168
169+ #[ allow( unused_variables) ]
170+ let m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
171+
158172 // Save the existing groups
159173 let old_groups = getgroups ( ) . unwrap ( ) ;
160174
You can’t perform that action at this time.
0 commit comments