From 347915bdb590d9b3437b9c5c69c6f1652017d325 Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Tue, 9 Aug 2022 12:17:27 +0800 Subject: format code --- test/sys/test_ptrace.rs | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'test/sys') diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs index 16680583..530560fe 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; @@ -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. + 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)); - 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 => - { + if pid == child => + { + let _ = waitpid(child, Some(WaitPidFlag::WNOHANG)); + while ptrace::cont(child, Some(Signal::SIGKILL)).is_ok() { 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) -- cgit v1.2.3