summaryrefslogtreecommitdiff
path: root/test/sys
diff options
context:
space:
mode:
authorSteveLauC <stevelauc@outlook.com>2022-08-09 12:15:52 +0800
committerSteveLauC <stevelauc@outlook.com>2022-08-09 12:15:52 +0800
commitd458ecd4e1205d36230ecac85c67472e3227a92d (patch)
treedc1c842152d1f6709ca4366ed92c40fb7d8aad2b /test/sys
parenta10078f35c9564950035dfc88cb3a2cd9f3d9be3 (diff)
downloadnix-d458ecd4e1205d36230ecac85c67472e3227a92d.zip
remove deprecated items
Diffstat (limited to 'test/sys')
-rw-r--r--test/sys/test_pthread.rs2
-rw-r--r--test/sys/test_ptrace.rs52
2 files changed, 27 insertions, 27 deletions
diff --git a/test/sys/test_pthread.rs b/test/sys/test_pthread.rs
index 42a4aefa..ce048bae 100644
--- a/test/sys/test_pthread.rs
+++ b/test/sys/test_pthread.rs
@@ -11,7 +11,7 @@ fn test_pthread_self() {
#[test]
fn test_pthread_self() {
let tid = pthread_self();
- assert!(tid != 0);
+ assert_ne!(tid, 0);
}
#[test]
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)