@@ -17,41 +17,41 @@ use libc::off_t;
17
17
fn test_fork_and_waitpid ( ) {
18
18
let pid = fork ( ) ;
19
19
match pid {
20
- Ok ( Child ) => { } // ignore child here
21
- Ok ( Parent { child } ) => {
22
- // assert that child was created and pid > 0
23
- assert ! ( child > 0 ) ;
24
- let wait_status = waitpid ( child, None ) ;
25
- match wait_status {
26
- // assert that waitpid returned correct status and the pid is the one of the child
27
- Ok ( WaitStatus :: Exited ( pid_t, _) ) => assert ! ( pid_t == child) ,
28
-
29
- // panic, must never happen
30
- Ok ( _) => panic ! ( "Child still alive, should never happen" ) ,
31
-
32
- // panic, waitpid should never fail
33
- Err ( _) => panic ! ( "Error: waitpid Failed" )
34
- }
35
-
36
- } ,
37
- // panic, fork should never fail unless there is a serious problem with the OS
38
- Err ( _) => panic ! ( "Error: Fork Failed" )
20
+ Ok ( Child ) => { } // ignore child here
21
+ Ok ( Parent { child } ) => {
22
+ // assert that child was created and pid > 0
23
+ assert ! ( child > 0 ) ;
24
+ let wait_status = waitpid ( child, None ) ;
25
+ match wait_status {
26
+ // assert that waitpid returned correct status and the pid is the one of the child
27
+ Ok ( WaitStatus :: Exited ( pid_t, _) ) => assert ! ( pid_t == child) ,
28
+
29
+ // panic, must never happen
30
+ Ok ( _) => panic ! ( "Child still alive, should never happen" ) ,
31
+
32
+ // panic, waitpid should never fail
33
+ Err ( _) => panic ! ( "Error: waitpid Failed" )
34
+ }
35
+
36
+ } ,
37
+ // panic, fork should never fail unless there is a serious problem with the OS
38
+ Err ( _) => panic ! ( "Error: Fork Failed" )
39
39
}
40
40
}
41
41
42
42
#[ test]
43
43
fn test_wait ( ) {
44
44
let pid = fork ( ) ;
45
45
match pid {
46
- Ok ( Child ) => { } // ignore child here
47
- Ok ( Parent { child } ) => {
48
- let wait_status = wait ( ) ;
49
-
50
- // just assert that (any) one child returns with WaitStatus::Exited
51
- assert_eq ! ( wait_status, Ok ( WaitStatus :: Exited ( child, 0 ) ) ) ;
52
- } ,
53
- // panic, fork should never fail unless there is a serious problem with the OS
54
- Err ( _) => panic ! ( "Error: Fork Failed" )
46
+ Ok ( Child ) => { } // ignore child here
47
+ Ok ( Parent { child } ) => {
48
+ let wait_status = wait ( ) ;
49
+
50
+ // just assert that (any) one child returns with WaitStatus::Exited
51
+ assert_eq ! ( wait_status, Ok ( WaitStatus :: Exited ( child, 0 ) ) ) ;
52
+ } ,
53
+ // panic, fork should never fail unless there is a serious problem with the OS
54
+ Err ( _) => panic ! ( "Error: Fork Failed" )
55
55
}
56
56
}
57
57
@@ -124,20 +124,20 @@ macro_rules! execve_test_factory(
124
124
125
125
#[ test]
126
126
fn test_getcwd ( ) {
127
- let mut tmp_dir = TempDir :: new ( "test_getcwd" ) . unwrap ( ) . into_path ( ) ;
128
- assert ! ( chdir( tmp_dir. as_path( ) ) . is_ok( ) ) ;
129
- assert_eq ! ( getcwd( ) . unwrap( ) , current_dir( ) . unwrap( ) ) ;
130
-
131
- // make path 500 chars longer so that buffer doubling in getcwd kicks in.
132
- // Note: One path cannot be longer than 255 bytes (NAME_MAX)
133
- // whole path cannot be longer than PATH_MAX (usually 4096 on linux, 1024 on macos)
134
- for _ in 0 ..5 {
135
- let newdir = iter:: repeat ( "a" ) . take ( 100 ) . collect :: < String > ( ) ;
136
- tmp_dir. push ( newdir) ;
137
- assert ! ( mkdir( tmp_dir. as_path( ) , stat:: S_IRWXU ) . is_ok( ) ) ;
138
- }
139
- assert ! ( chdir( tmp_dir. as_path( ) ) . is_ok( ) ) ;
140
- assert_eq ! ( getcwd( ) . unwrap( ) , current_dir( ) . unwrap( ) ) ;
127
+ let mut tmp_dir = TempDir :: new ( "test_getcwd" ) . unwrap ( ) . into_path ( ) ;
128
+ assert ! ( chdir( tmp_dir. as_path( ) ) . is_ok( ) ) ;
129
+ assert_eq ! ( getcwd( ) . unwrap( ) , current_dir( ) . unwrap( ) ) ;
130
+
131
+ // make path 500 chars longer so that buffer doubling in getcwd kicks in.
132
+ // Note: One path cannot be longer than 255 bytes (NAME_MAX)
133
+ // whole path cannot be longer than PATH_MAX (usually 4096 on linux, 1024 on macos)
134
+ for _ in 0 ..5 {
135
+ let newdir = iter:: repeat ( "a" ) . take ( 100 ) . collect :: < String > ( ) ;
136
+ tmp_dir. push ( newdir) ;
137
+ assert ! ( mkdir( tmp_dir. as_path( ) , stat:: S_IRWXU ) . is_ok( ) ) ;
138
+ }
139
+ assert ! ( chdir( tmp_dir. as_path( ) ) . is_ok( ) ) ;
140
+ assert_eq ! ( getcwd( ) . unwrap( ) , current_dir( ) . unwrap( ) ) ;
141
141
}
142
142
143
143
#[ test]
@@ -150,10 +150,10 @@ fn test_lseek() {
150
150
lseek ( tmp. as_raw_fd ( ) , offset, Whence :: SeekSet ) . unwrap ( ) ;
151
151
152
152
let mut buf = String :: new ( ) ;
153
- tmp. read_to_string ( & mut buf) . unwrap ( ) ;
154
- assert_eq ! ( b"f123456" , buf. as_bytes( ) ) ;
153
+ tmp. read_to_string ( & mut buf) . unwrap ( ) ;
154
+ assert_eq ! ( b"f123456" , buf. as_bytes( ) ) ;
155
155
156
- close ( tmp. as_raw_fd ( ) ) . unwrap ( ) ;
156
+ close ( tmp. as_raw_fd ( ) ) . unwrap ( ) ;
157
157
}
158
158
159
159
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
0 commit comments