@@ -105,7 +105,7 @@ mod linux_android {
105
105
}
106
106
107
107
macro_rules! execve_test_factory(
108
- ( $test_name: ident, $syscall: ident, $unix_sh : expr , $android_sh : expr) => (
108
+ ( $test_name: ident, $syscall: ident, $exe : expr) => (
109
109
#[ test]
110
110
fn $test_name( ) {
111
111
#[ allow( unused_variables) ]
@@ -119,19 +119,13 @@ macro_rules! execve_test_factory(
119
119
// The tests make sure not to do that, though.
120
120
match fork( ) . unwrap( ) {
121
121
Child => {
122
- #[ cfg( not( target_os = "android" ) ) ]
123
- const SH_PATH : & ' static [ u8 ] = $unix_sh;
124
-
125
- #[ cfg( target_os = "android" ) ]
126
- const SH_PATH : & ' static [ u8 ] = $android_sh;
127
-
128
122
// Close stdout.
129
123
close( 1 ) . unwrap( ) ;
130
124
// Make `writer` be the stdout of the new process.
131
125
dup( writer) . unwrap( ) ;
132
126
// exec!
133
127
$syscall(
134
- & CString :: new ( SH_PATH ) . unwrap ( ) ,
128
+ $exe ,
135
129
& [ CString :: new( b"" . as_ref( ) ) . unwrap( ) ,
136
130
CString :: new( b"-c" . as_ref( ) ) . unwrap( ) ,
137
131
CString :: new( b"echo nix!!! && echo foo=$foo && echo baz=$baz"
@@ -156,6 +150,14 @@ macro_rules! execve_test_factory(
156
150
)
157
151
) ;
158
152
153
+ #[ cfg( not( target_os = "android" ) ) ]
154
+ const SH_PATH : & ' static str = "/bin/sh" ;
155
+ #[ cfg( target_os = "android" ) ]
156
+ const SH_PATH : & ' static str = "/system/bin/sh" ;
157
+
158
+ execve_test_factory ! ( test_execve, execve, & CString :: new( SH_PATH ) . unwrap( ) ) ;
159
+ execve_test_factory ! ( test_fexecve, fexecve, File :: open( SH_PATH ) . unwrap( ) . into_raw_fd( ) ) ;
160
+
159
161
#[ test]
160
162
fn test_fchdir ( ) {
161
163
// fchdir changes the process's cwd
@@ -231,8 +233,6 @@ fn test_lseek64() {
231
233
close ( tmpfd) . unwrap ( ) ;
232
234
}
233
235
234
- execve_test_factory ! ( test_execve, execve, b"/bin/sh" , b"/system/bin/sh" ) ;
235
-
236
236
#[ test]
237
237
fn test_fpathconf_limited ( ) {
238
238
let f = tempfile ( ) . unwrap ( ) ;
0 commit comments