@@ -105,7 +105,7 @@ mod linux_android {
105105}
106106
107107macro_rules! execve_test_factory(
108- ( $test_name: ident, $syscall: ident, $unix_sh : expr , $android_sh : expr) => (
108+ ( $test_name: ident, $syscall: ident, $exe : expr) => (
109109 #[ test]
110110 fn $test_name( ) {
111111 #[ allow( unused_variables) ]
@@ -119,19 +119,13 @@ macro_rules! execve_test_factory(
119119 // The tests make sure not to do that, though.
120120 match fork( ) . unwrap( ) {
121121 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-
128122 // Close stdout.
129123 close( 1 ) . unwrap( ) ;
130124 // Make `writer` be the stdout of the new process.
131125 dup( writer) . unwrap( ) ;
132126 // exec!
133127 $syscall(
134- & CString :: new ( SH_PATH ) . unwrap ( ) ,
128+ $exe ,
135129 & [ CString :: new( b"" . as_ref( ) ) . unwrap( ) ,
136130 CString :: new( b"-c" . as_ref( ) ) . unwrap( ) ,
137131 CString :: new( b"echo nix!!! && echo foo=$foo && echo baz=$baz"
@@ -156,6 +150,14 @@ macro_rules! execve_test_factory(
156150 )
157151) ;
158152
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+
159161#[ test]
160162fn test_fchdir ( ) {
161163 // fchdir changes the process's cwd
@@ -231,8 +233,6 @@ fn test_lseek64() {
231233 close ( tmpfd) . unwrap ( ) ;
232234}
233235
234- execve_test_factory ! ( test_execve, execve, b"/bin/sh" , b"/system/bin/sh" ) ;
235-
236236#[ test]
237237fn test_fpathconf_limited ( ) {
238238 let f = tempfile ( ) . unwrap ( ) ;
0 commit comments