summaryrefslogtreecommitdiff
path: root/test/sys/test_ptrace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test/sys/test_ptrace.rs')
-rw-r--r--test/sys/test_ptrace.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
index e514832b..16680583 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -1,7 +1,7 @@
#[cfg(all(
- target_os = "linux",
- any(target_arch = "x86_64", target_arch = "x86"),
- target_env = "gnu"
+target_os = "linux",
+any(target_arch = "x86_64", target_arch = "x86"),
+target_env = "gnu"
))]
use memoffset::offset_of;
use nix::errno::Errno;
@@ -33,7 +33,7 @@ fn test_ptrace_setoptions() {
require_capability!("test_ptrace_setoptions", CAP_SYS_PTRACE);
let err = ptrace::setoptions(getpid(), Options::PTRACE_O_TRACESYSGOOD)
.unwrap_err();
- assert!(err != Errno::EOPNOTSUPP);
+ assert_ne!(err, Errno::EOPNOTSUPP);
}
// Just make sure ptrace_getevent can be called at all, for now.
@@ -42,7 +42,7 @@ fn test_ptrace_setoptions() {
fn test_ptrace_getevent() {
require_capability!("test_ptrace_getevent", CAP_SYS_PTRACE);
let err = ptrace::getevent(getpid()).unwrap_err();
- assert!(err != Errno::EOPNOTSUPP);
+ assert_ne!(err, Errno::EOPNOTSUPP);
}
// Just make sure ptrace_getsiginfo can be called at all, for now.
@@ -111,17 +111,17 @@ fn test_ptrace_cont() {
ptrace::cont(child, Some(Signal::SIGKILL)).unwrap();
match waitpid(child, None) {
Ok(WaitStatus::Signaled(pid, Signal::SIGKILL, _))
- if pid == child =>
- {
- // FIXME It's been observed on some systems (apple) the
- // tracee may not be killed but remain as a zombie process
- // affecting other wait based tests. Add an extra kill just
- // to make sure there are no zombies.
- let _ = waitpid(child, Some(WaitPidFlag::WNOHANG));
- while ptrace::cont(child, Some(Signal::SIGKILL)).is_ok() {
+ if pid == child =>
+ {
+ // FIXME It's been observed on some systems (apple) the
+ // tracee may not be killed but remain as a zombie process
+ // affecting other wait based tests. Add an extra kill just
+ // to make sure there are no zombies.
let _ = waitpid(child, Some(WaitPidFlag::WNOHANG));
+ while ptrace::cont(child, Some(Signal::SIGKILL)).is_ok() {
+ let _ = waitpid(child, Some(WaitPidFlag::WNOHANG));
+ }
}
- }
_ => panic!("The process should have been killed"),
}
}
@@ -163,13 +163,13 @@ fn test_ptrace_interrupt() {
ptrace::detach(child, Some(Signal::SIGKILL)).unwrap();
match waitpid(child, None) {
Ok(WaitStatus::Signaled(pid, Signal::SIGKILL, _))
- if pid == child =>
- {
- let _ = waitpid(child, Some(WaitPidFlag::WNOHANG));
- while ptrace::cont(child, Some(Signal::SIGKILL)).is_ok() {
+ if pid == child =>
+ {
let _ = waitpid(child, Some(WaitPidFlag::WNOHANG));
+ while ptrace::cont(child, Some(Signal::SIGKILL)).is_ok() {
+ let _ = waitpid(child, Some(WaitPidFlag::WNOHANG));
+ }
}
- }
_ => panic!("The process should have been killed"),
}
}
@@ -178,9 +178,9 @@ fn test_ptrace_interrupt() {
// ptrace::{setoptions, getregs} are only available in these platforms
#[cfg(all(
- target_os = "linux",
- any(target_arch = "x86_64", target_arch = "x86"),
- target_env = "gnu"
+target_os = "linux",
+any(target_arch = "x86_64", target_arch = "x86"),
+target_env = "gnu"
))]
#[test]
fn test_ptrace_syscall() {
@@ -219,18 +219,18 @@ fn test_ptrace_syscall() {
.unwrap();
#[cfg(target_arch = "x86_64")]
- let get_syscall_id =
+ let get_syscall_id =
|| ptrace::getregs(child).unwrap().orig_rax as libc::c_long;
#[cfg(target_arch = "x86")]
- let get_syscall_id =
+ let get_syscall_id =
|| ptrace::getregs(child).unwrap().orig_eax as libc::c_long;
// this duplicates `get_syscall_id` for the purpose of testing `ptrace::read_user`.
#[cfg(target_arch = "x86_64")]
- let rax_offset = offset_of!(libc::user_regs_struct, orig_rax);
+ let rax_offset = offset_of!(libc::user_regs_struct, orig_rax);
#[cfg(target_arch = "x86")]
- let rax_offset = offset_of!(libc::user_regs_struct, orig_eax);
+ let rax_offset = offset_of!(libc::user_regs_struct, orig_eax);
let get_syscall_from_user_area = || {
// Find the offset of `user.regs.rax` (or `user.regs.eax` for x86)