summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 93b54143..e15fec17 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -20,9 +20,9 @@ fn test_fork_and_waitpid() {
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is signal-safe
- match fork() {
- Ok(Child) => unsafe { _exit(0) },
- Ok(Parent { child }) => {
+ match fork().expect("Error: Fork Failed") {
+ Child => unsafe { _exit(0) },
+ Parent { child } => {
// assert that child was created and pid > 0
let child_raw: ::libc::pid_t = child.into();
assert!(child_raw > 0);
@@ -39,8 +39,6 @@ fn test_fork_and_waitpid() {
}
},
- // panic, fork should never fail unless there is a serious problem with the OS
- Err(_) => panic!("Error: Fork Failed")
}
}
@@ -51,17 +49,14 @@ fn test_wait() {
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is signal-safe
- let pid = fork();
- match pid {
- Ok(Child) => unsafe { _exit(0) },
- Ok(Parent { child }) => {
+ match fork().expect("Error: Fork Failed") {
+ Child => unsafe { _exit(0) },
+ Parent { child } => {
let wait_status = wait();
// just assert that (any) one child returns with WaitStatus::Exited
assert_eq!(wait_status, Ok(WaitStatus::Exited(child, 0)));
},
- // panic, fork should never fail unless there is a serious problem with the OS
- Err(_) => panic!("Error: Fork Failed")
}
}
@@ -319,7 +314,7 @@ fn test_getcwd() {
#[test]
fn test_lseek() {
- const CONTENTS: &'static [u8] = b"abcdef123456";
+ const CONTENTS: &[u8] = b"abcdef123456";
let mut tmp = tempfile().unwrap();
tmp.write_all(CONTENTS).unwrap();
let tmpfd = tmp.into_raw_fd();
@@ -337,9 +332,9 @@ fn test_lseek() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_lseek64() {
- const CONTENTS: &'static [u8] = b"abcdef123456";
+ const CONTENTS: &[u8] = b"abcdef123456";
let mut tmp = tempfile().unwrap();
- tmp.write(CONTENTS).unwrap();
+ tmp.write_all(CONTENTS).unwrap();
let tmpfd = tmp.into_raw_fd();
lseek64(tmpfd, 5, Whence::SeekSet).unwrap();