summaryrefslogtreecommitdiff
path: root/test/sys
diff options
context:
space:
mode:
authorBryant Mairs <bryantmairs@google.com>2017-12-15 15:22:01 -0800
committerBryant Mairs <bryantmairs@google.com>2017-12-20 07:05:04 -0800
commit46fe1319a73a9d4c0081c2b5f8900d7943f3a44b (patch)
tree7d7547cf70e4e0f9adb3feb4bcdf167eeb668b1a /test/sys
parent7b4402f091ccac878f3cbb772a6df20ba7a7a9e6 (diff)
downloadnix-46fe1319a73a9d4c0081c2b5f8900d7943f3a44b.zip
Remove useless Err(_) match arms
Diffstat (limited to 'test/sys')
-rw-r--r--test/sys/test_ptrace.rs7
-rw-r--r--test/sys/test_uio.rs7
-rw-r--r--test/sys/test_wait.rs23
3 files changed, 15 insertions, 22 deletions
diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
index d3e579f3..f31ba877 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -66,8 +66,8 @@ fn test_ptrace_cont() {
return;
}
- match fork() {
- Ok(Child) => {
+ match fork().expect("Error: Fork Failed") {
+ Child => {
ptrace::traceme().unwrap();
// As recommended by ptrace(2), raise SIGTRAP to pause the child
// until the parent is ready to continue
@@ -76,7 +76,7 @@ fn test_ptrace_cont() {
}
},
- Ok(Parent { child }) => {
+ Parent { child } => {
assert_eq!(waitpid(child, None), Ok(WaitStatus::Stopped(child, Signal::SIGTRAP)));
ptrace::cont(child, None).unwrap();
assert_eq!(waitpid(child, None), Ok(WaitStatus::Stopped(child, Signal::SIGTRAP)));
@@ -86,6 +86,5 @@ fn test_ptrace_cont() {
_ => panic!("The process should have been killed"),
}
},
- Err(_) => panic!("Error: Fork Failed")
}
}
diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs
index 262874b3..8c326a38 100644
--- a/test/sys/test_uio.rs
+++ b/test/sys/test_uio.rs
@@ -208,8 +208,8 @@ fn test_process_vm_readv() {
let mut vector = vec![1u8, 2, 3, 4, 5];
let (r, w) = pipe().unwrap();
- match fork() {
- Ok(Parent { child }) => {
+ match fork().expect("Error: Fork Failed") {
+ Parent { child } => {
close(w).unwrap();
// wait for child
read(r, &mut [0u8]).unwrap();
@@ -229,7 +229,7 @@ fn test_process_vm_readv() {
assert_eq!(Ok(5), ret);
assert_eq!(20u8, buf.iter().sum());
},
- Ok(Child) => {
+ Child => {
let _ = close(r);
for i in vector.iter_mut() {
*i += 1;
@@ -238,6 +238,5 @@ fn test_process_vm_readv() {
let _ = close(w);
loop { let _ = pause(); }
},
- Err(_) => panic!("fork failed")
}
}
diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs
index e834f9f0..9992607c 100644
--- a/test/sys/test_wait.rs
+++ b/test/sys/test_wait.rs
@@ -11,14 +11,12 @@ fn test_wait_signal() {
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: The child only calls `pause` and/or `_exit`, which are async-signal-safe.
- match fork() {
- Ok(Child) => pause().unwrap_or_else(|_| unsafe { _exit(123) }),
- Ok(Parent { child }) => {
+ match fork().expect("Error: Fork Failed") {
+ Child => pause().unwrap_or_else(|_| unsafe { _exit(123) }),
+ Parent { child } => {
kill(child, Some(SIGKILL)).expect("Error: Kill Failed");
assert_eq!(waitpid(child, None), Ok(WaitStatus::Signaled(child, SIGKILL, false)));
},
- // panic, fork should never fail unless there is a serious problem with the OS
- Err(_) => panic!("Error: Fork Failed")
}
}
@@ -28,13 +26,11 @@ fn test_wait_exit() {
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is async-signal-safe.
- match fork() {
- Ok(Child) => unsafe { _exit(12); },
- Ok(Parent { child }) => {
+ match fork().expect("Error: Fork Failed") {
+ Child => unsafe { _exit(12); },
+ Parent { child } => {
assert_eq!(waitpid(child, None), Ok(WaitStatus::Exited(child, 12)));
},
- // panic, fork should never fail unless there is a serious problem with the OS
- Err(_) => panic!("Error: Fork Failed")
}
}
@@ -100,10 +96,9 @@ mod ptrace {
#[allow(unused_variables)]
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
- match fork() {
- Ok(Child) => ptrace_child(),
- Ok(Parent { child }) => ptrace_parent(child),
- Err(_) => panic!("Error: Fork Failed")
+ match fork().expect("Error: Fork Failed") {
+ Child => ptrace_child(),
+ Parent { child } => ptrace_parent(child),
}
}
}