@@ -4,7 +4,7 @@ use nix::unistd::ForkResult::*;
4
4
use nix:: sys:: signal:: { SaFlags , SigAction , SigHandler , SigSet , Signal , sigaction} ;
5
5
use nix:: sys:: wait:: * ;
6
6
use nix:: sys:: stat:: { self , Mode , SFlag } ;
7
- use std:: { self , env, iter} ;
7
+ use std:: { env, iter} ;
8
8
use std:: ffi:: CString ;
9
9
use std:: fs:: File ;
10
10
use std:: io:: Write ;
@@ -127,12 +127,7 @@ mod linux_android {
127
127
#[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
128
128
fn test_setgroups ( ) {
129
129
// Skip this test when not run as root as `setgroups()` requires root.
130
- if !Uid :: current ( ) . is_root ( ) {
131
- let stderr = std:: io:: stderr ( ) ;
132
- let mut handle = stderr. lock ( ) ;
133
- writeln ! ( handle, "test_setgroups requires root privileges. Skipping test." ) . unwrap ( ) ;
134
- return ;
135
- }
130
+ skip_if_not_root ! ( "test_setgroups" ) ;
136
131
137
132
let _m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
138
133
@@ -156,12 +151,7 @@ fn test_setgroups() {
156
151
fn test_initgroups ( ) {
157
152
// Skip this test when not run as root as `initgroups()` and `setgroups()`
158
153
// require root.
159
- if !Uid :: current ( ) . is_root ( ) {
160
- let stderr = std:: io:: stderr ( ) ;
161
- let mut handle = stderr. lock ( ) ;
162
- writeln ! ( handle, "test_initgroups requires root privileges. Skipping test." ) . unwrap ( ) ;
163
- return ;
164
- }
154
+ skip_if_not_root ! ( "test_initgroups" ) ;
165
155
166
156
let _m = :: GROUPS_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
167
157
0 commit comments