Skip to content

Commit 7dd12c6

Browse files
committed
fixed indentation
1 parent 5f1e144 commit 7dd12c6

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

test/test_unistd.rs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,41 @@ use libc::off_t;
1717
fn test_fork_and_waitpid() {
1818
let pid = fork();
1919
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")
3939
}
4040
}
4141

4242
#[test]
4343
fn test_wait() {
4444
let pid = fork();
4545
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")
5555
}
5656
}
5757

@@ -124,20 +124,20 @@ macro_rules! execve_test_factory(
124124

125125
#[test]
126126
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());
141141
}
142142

143143
#[test]
@@ -150,10 +150,10 @@ fn test_lseek() {
150150
lseek(tmp.as_raw_fd(), offset, Whence::SeekSet).unwrap();
151151

152152
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());
155155

156-
close(tmp.as_raw_fd()).unwrap();
156+
close(tmp.as_raw_fd()).unwrap();
157157
}
158158

159159
#[cfg(any(target_os = "linux", target_os = "android"))]

0 commit comments

Comments
 (0)