diff options
-rw-r--r-- | src/sys/time.rs | 50 | ||||
-rw-r--r-- | src/unistd.rs | 58 | ||||
-rw-r--r-- | test/sys/test_ptrace.rs | 48 | ||||
-rw-r--r-- | test/test_stat.rs | 58 | ||||
-rw-r--r-- | test/test_unistd.rs | 194 |
5 files changed, 204 insertions, 204 deletions
diff --git a/src/sys/time.rs b/src/sys/time.rs index 36279978..e7a72f02 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -7,17 +7,17 @@ use std::time::Duration; use std::{cmp, fmt, ops}; #[cfg(any( -all(feature = "time", any(target_os = "android", target_os = "linux")), -all( -any( -target_os = "freebsd", -target_os = "illumos", -target_os = "linux", -target_os = "netbsd" -), -feature = "time", -feature = "signal" -) + all(feature = "time", any(target_os = "android", target_os = "linux")), + all( + any( + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd" + ), + feature = "time", + feature = "signal" + ) ))] pub(crate) mod timer { use crate::sys::time::TimeSpec; @@ -98,10 +98,10 @@ pub(crate) mod timer { } } #[cfg(any( - target_os = "freebsd", - target_os = "netbsd", - target_os = "dragonfly", - target_os = "illumos" + target_os = "freebsd", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "illumos" ))] bitflags! { /// Flags that are used for arming the timer. @@ -114,17 +114,17 @@ pub(crate) mod timer { fn from(timerspec: TimerSpec) -> Expiration { match timerspec { TimerSpec(libc::itimerspec { - it_interval: - libc::timespec { - tv_sec: 0, - tv_nsec: 0, - }, - it_value: ts, - }) => Expiration::OneShot(ts.into()), + it_interval: + libc::timespec { + tv_sec: 0, + tv_nsec: 0, + }, + it_value: ts, + }) => Expiration::OneShot(ts.into()), TimerSpec(libc::itimerspec { - it_interval: int_ts, - it_value: val_ts, - }) => { + it_interval: int_ts, + it_value: val_ts, + }) => { if (int_ts.tv_sec == val_ts.tv_sec) && (int_ts.tv_nsec == val_ts.tv_nsec) { diff --git a/src/unistd.rs b/src/unistd.rs index 69419d64..2209c069 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -7,15 +7,15 @@ use crate::fcntl::{at_rawfd, AtFlags}; #[cfg(feature = "fs")] use crate::fcntl::{fcntl, FcntlArg::F_SETFD, FdFlag, OFlag}; #[cfg(all( -feature = "fs", -any( -target_os = "openbsd", -target_os = "netbsd", -target_os = "freebsd", -target_os = "dragonfly", -target_os = "macos", -target_os = "ios" -) + feature = "fs", + any( + target_os = "openbsd", + target_os = "netbsd", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "macos", + target_os = "ios" + ) ))] use crate::sys::stat::FileFlag; #[cfg(feature = "fs")] @@ -45,20 +45,20 @@ feature! { } #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "freebsd", -target_os = "linux", -target_os = "openbsd" + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd" ))] pub use self::setres::*; #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "freebsd", -target_os = "linux", -target_os = "openbsd" + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd" ))] pub use self::getres::*; @@ -2752,11 +2752,11 @@ mod pivot_root { } #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "freebsd", -target_os = "linux", -target_os = "openbsd" + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd" ))] mod setres { feature! { @@ -2801,11 +2801,11 @@ mod setres { } #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "freebsd", -target_os = "linux", -target_os = "openbsd" + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd" ))] mod getres { feature! { 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) diff --git a/test/test_stat.rs b/test/test_stat.rs index bed33b54..55f15c07 100644 --- a/test/test_stat.rs +++ b/test/test_stat.rs @@ -20,11 +20,11 @@ use nix::errno::Errno; #[cfg(not(target_os = "redox"))] use nix::fcntl; #[cfg(any( -target_os = "linux", -target_os = "ios", -target_os = "macos", -target_os = "freebsd", -target_os = "netbsd" + target_os = "linux", + target_os = "ios", + target_os = "macos", + target_os = "freebsd", + target_os = "netbsd" ))] use nix::sys::stat::lutimes; #[cfg(not(any(target_os = "redox", target_os = "haiku")))] @@ -234,11 +234,11 @@ fn test_utimes() { #[test] #[cfg(any( -target_os = "linux", -target_os = "ios", -target_os = "macos", -target_os = "freebsd", -target_os = "netbsd" + target_os = "linux", + target_os = "ios", + target_os = "macos", + target_os = "freebsd", + target_os = "netbsd" ))] fn test_lutimes() { let tempdir = tempfile::tempdir().unwrap(); @@ -299,7 +299,7 @@ fn test_utimensat() { &TimeSpec::seconds(678), UtimensatFlags::FollowSymlink, ) - .unwrap(); + .unwrap(); assert_times_eq(12345, 678, &fs::metadata(&fullpath).unwrap()); chdir(tempdir.path()).unwrap(); @@ -311,7 +311,7 @@ fn test_utimensat() { &TimeSpec::seconds(800), UtimensatFlags::FollowSymlink, ) - .unwrap(); + .unwrap(); assert_times_eq(500, 800, &fs::metadata(&fullpath).unwrap()); } @@ -356,19 +356,19 @@ fn test_mkdirat_fail() { fcntl::OFlag::O_CREAT, stat::Mode::empty(), ) - .unwrap(); + .unwrap(); let result = mkdirat(dirfd, filename, Mode::S_IRWXU).unwrap_err(); assert_eq!(result, Errno::ENOTDIR); } #[test] #[cfg(not(any( -target_os = "dragonfly", -target_os = "freebsd", -target_os = "ios", -target_os = "macos", -target_os = "haiku", -target_os = "redox" + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "haiku", + target_os = "redox" )))] fn test_mknod() { use stat::{lstat, mknod, SFlag}; @@ -384,13 +384,13 @@ fn test_mknod() { #[test] #[cfg(not(any( -target_os = "dragonfly", -target_os = "freebsd", -target_os = "illumos", -target_os = "ios", -target_os = "macos", -target_os = "haiku", -target_os = "redox" + target_os = "dragonfly", + target_os = "freebsd", + target_os = "illumos", + target_os = "ios", + target_os = "macos", + target_os = "haiku", + target_os = "redox" )))] fn test_mknodat() { use fcntl::{AtFlags, OFlag}; @@ -408,14 +408,14 @@ fn test_mknodat() { Mode::S_IRWXU, 0, ) - .unwrap(); + .unwrap(); let mode = fstatat( target_dir.as_raw_fd(), file_name, AtFlags::AT_SYMLINK_NOFOLLOW, ) - .unwrap() - .st_mode as mode_t; + .unwrap() + .st_mode as mode_t; assert_eq!(mode & libc::S_IFREG, libc::S_IFREG); assert_eq!(mode & libc::S_IRWXU, libc::S_IRWXU); } diff --git a/test/test_unistd.rs b/test/test_unistd.rs index e4750d4b..eee10103 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -6,9 +6,9 @@ use nix::fcntl::OFlag; #[cfg(not(target_os = "redox"))] use nix::fcntl::{self, open}; #[cfg(not(any( -target_os = "redox", -target_os = "fuchsia", -target_os = "haiku" + target_os = "redox", + target_os = "fuchsia", + target_os = "haiku" )))] use nix::pty::{grantpt, posix_openpt, ptsname, unlockpt}; #[cfg(not(target_os = "redox"))] @@ -28,9 +28,9 @@ use std::fs::{self, File}; use std::io::Write; use std::os::unix::prelude::*; #[cfg(not(any( -target_os = "fuchsia", -target_os = "redox", -target_os = "haiku" + target_os = "fuchsia", + target_os = "redox", + target_os = "haiku" )))] use std::path::Path; use tempfile::{tempdir, tempfile}; @@ -126,11 +126,11 @@ fn test_mkfifo_directory() { #[test] #[cfg(not(any( -target_os = "macos", -target_os = "ios", -target_os = "android", -target_os = "redox", -target_os = "haiku" + target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "redox", + target_os = "haiku" )))] fn test_mkfifoat_none() { let _m = crate::CWD_LOCK.read(); @@ -147,11 +147,11 @@ fn test_mkfifoat_none() { #[test] #[cfg(not(any( -target_os = "macos", -target_os = "ios", -target_os = "android", -target_os = "redox", -target_os = "haiku" + target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "redox", + target_os = "haiku" )))] fn test_mkfifoat() { use nix::fcntl; @@ -170,11 +170,11 @@ fn test_mkfifoat() { #[test] #[cfg(not(any( -target_os = "macos", -target_os = "ios", -target_os = "android", -target_os = "redox", -target_os = "haiku" + target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "redox", + target_os = "haiku" )))] fn test_mkfifoat_directory_none() { let _m = crate::CWD_LOCK.read(); @@ -186,11 +186,11 @@ fn test_mkfifoat_directory_none() { #[test] #[cfg(not(any( -target_os = "macos", -target_os = "ios", -target_os = "android", -target_os = "redox", -target_os = "haiku" + target_os = "macos", + target_os = "ios", + target_os = "android", + target_os = "redox", + target_os = "haiku" )))] fn test_mkfifoat_directory() { // mkfifoat should fail if a directory is given @@ -234,11 +234,11 @@ mod linux_android { #[test] // `getgroups()` and `setgroups()` do not behave as expected on Apple platforms #[cfg(not(any( -target_os = "ios", -target_os = "macos", -target_os = "redox", -target_os = "fuchsia", -target_os = "haiku" + target_os = "ios", + target_os = "macos", + target_os = "redox", + target_os = "fuchsia", + target_os = "haiku" )))] fn test_setgroups() { // Skip this test when not run as root as `setgroups()` requires root. @@ -263,12 +263,12 @@ fn test_setgroups() { #[test] // `getgroups()` and `setgroups()` do not behave as expected on Apple platforms #[cfg(not(any( -target_os = "ios", -target_os = "macos", -target_os = "redox", -target_os = "fuchsia", -target_os = "haiku", -target_os = "illumos" + target_os = "ios", + target_os = "macos", + target_os = "redox", + target_os = "fuchsia", + target_os = "haiku", + target_os = "illumos" )))] fn test_initgroups() { // Skip this test when not run as root as `initgroups()` and `setgroups()` @@ -609,9 +609,9 @@ cfg_if! { #[test] #[cfg(not(any( -target_os = "redox", -target_os = "fuchsia", -target_os = "haiku" + target_os = "redox", + target_os = "fuchsia", + target_os = "haiku" )))] fn test_acct() { use std::process::Command; @@ -685,11 +685,11 @@ fn test_sysconf_unsupported() { } #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "freebsd", -target_os = "linux", -target_os = "openbsd" + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd" ))] #[test] fn test_getresuid() { @@ -700,11 +700,11 @@ fn test_getresuid() { } #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "freebsd", -target_os = "linux", -target_os = "openbsd" + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "openbsd" ))] #[test] fn test_getresgid() { @@ -733,16 +733,16 @@ fn test_pipe() { // pipe2(2) is the same as pipe(2), except it allows setting some flags. Check // that we can set a flag. #[cfg(any( -target_os = "android", -target_os = "dragonfly", -target_os = "emscripten", -target_os = "freebsd", -target_os = "illumos", -target_os = "linux", -target_os = "netbsd", -target_os = "openbsd", -target_os = "redox", -target_os = "solaris" + target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox", + target_os = "solaris" ))] #[test] fn test_pipe2() { @@ -918,7 +918,7 @@ fn test_linkat_file() { newfilename, LinkatFlags::SymlinkFollow, ) - .unwrap(); + .unwrap(); assert!(newfilepath.exists()); } @@ -944,7 +944,7 @@ fn test_linkat_olddirfd_none() { fcntl::OFlag::empty(), stat::Mode::empty(), ) - .unwrap(); + .unwrap(); // Attempt hard link file using curent working directory as relative path for old file path chdir(tempdir_oldfile.path()).unwrap(); @@ -955,7 +955,7 @@ fn test_linkat_olddirfd_none() { newfilename, LinkatFlags::SymlinkFollow, ) - .unwrap(); + .unwrap(); assert!(newfilepath.exists()); } @@ -981,7 +981,7 @@ fn test_linkat_newdirfd_none() { fcntl::OFlag::empty(), stat::Mode::empty(), ) - .unwrap(); + .unwrap(); // Attempt hard link file using current working directory as relative path for new file path chdir(tempdir_newfile.path()).unwrap(); @@ -992,16 +992,16 @@ fn test_linkat_newdirfd_none() { newfilename, LinkatFlags::SymlinkFollow, ) - .unwrap(); + .unwrap(); assert!(newfilepath.exists()); } #[test] #[cfg(not(any( -target_os = "ios", -target_os = "macos", -target_os = "redox", -target_os = "haiku" + target_os = "ios", + target_os = "macos", + target_os = "redox", + target_os = "haiku" )))] fn test_linkat_no_follow_symlink() { let _m = crate::CWD_LOCK.read(); @@ -1035,7 +1035,7 @@ fn test_linkat_no_follow_symlink() { newfilename, LinkatFlags::NoSymlinkFollow, ) - .unwrap(); + .unwrap(); // Assert newfile is actually a symlink to oldfile. assert_eq!( @@ -1078,7 +1078,7 @@ fn test_linkat_follow_symlink() { newfilename, LinkatFlags::SymlinkFollow, ) - .unwrap(); + .unwrap(); let newfilestat = stat::stat(&newfilepath).unwrap(); @@ -1180,10 +1180,10 @@ fn test_access_file_exists() { fn test_user_into_passwd() { // get the UID of the "nobody" user #[cfg(not(target_os = "haiku"))] - let test_username = "nobody"; + let test_username = "nobody"; // "nobody" unavailable on haiku #[cfg(target_os = "haiku")] - let test_username = "user"; + let test_username = "user"; let nobody = User::from_name(test_username).unwrap().unwrap(); let pwd: libc::passwd = nobody.into(); @@ -1221,8 +1221,8 @@ fn test_setfsuid() { let prev_fuid = setfsuid(Uid::from_raw(-1i32 as u32)); assert_ne!(prev_fuid, fuid); }) - .join() - .unwrap(); + .join() + .unwrap(); // open the temporary file with the current thread filesystem UID fs::File::open(temp_path_2).unwrap(); @@ -1230,9 +1230,9 @@ fn test_setfsuid() { #[test] #[cfg(not(any( -target_os = "redox", -target_os = "fuchsia", -target_os = "haiku" + target_os = "redox", + target_os = "fuchsia", + target_os = "haiku" )))] fn test_ttyname() { let fd = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed"); @@ -1262,9 +1262,9 @@ fn test_ttyname_not_pty() { #[test] #[cfg(not(any( -target_os = "redox", -target_os = "fuchsia", -target_os = "haiku" + target_os = "redox", + target_os = "fuchsia", + target_os = "haiku" )))] fn test_ttyname_invalid_fd() { assert_eq!(ttyname(-1), Err(Errno::EBADF)); @@ -1272,12 +1272,12 @@ fn test_ttyname_invalid_fd() { #[test] #[cfg(any( -target_os = "macos", -target_os = "ios", -target_os = "freebsd", -target_os = "openbsd", -target_os = "netbsd", -target_os = "dragonfly", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd", + target_os = "dragonfly", ))] fn test_getpeereid() { use std::os::unix::net::UnixStream; @@ -1297,12 +1297,12 @@ fn test_getpeereid() { #[test] #[cfg(any( -target_os = "macos", -target_os = "ios", -target_os = "freebsd", -target_os = "openbsd", -target_os = "netbsd", -target_os = "dragonfly", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd", + target_os = "dragonfly", ))] fn test_getpeereid_invalid_fd() { // getpeereid is not POSIX, so error codes are inconsistent between different Unices. @@ -1337,8 +1337,8 @@ fn test_faccessat_not_existing() { AccessFlags::F_OK, AtFlags::empty(), ) - .err() - .unwrap(), + .err() + .unwrap(), Errno::ENOENT ); } @@ -1356,7 +1356,7 @@ fn test_faccessat_none_file_exists() { AccessFlags::R_OK | AccessFlags::W_OK, AtFlags::empty(), ) - .is_ok()); + .is_ok()); } #[test] @@ -1374,5 +1374,5 @@ fn test_faccessat_file_exists() { AccessFlags::R_OK | AccessFlags::W_OK, AtFlags::empty(), ) - .is_ok()); + .is_ok()); } |