summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Nathan <andre@digirati.com.br>2020-03-27 19:54:41 -0300
committerAndre Nathan <andre@digirati.com.br>2020-03-27 20:33:37 -0300
commit1478315e2caea2b5320d4ff834e19f819fe8a61d (patch)
tree478406556b32b7ad0f76d8aa83a5536209bed906
parent3332c08793750ab1cd94fb9406c154fe5efa53f6 (diff)
downloadnix-1478315e2caea2b5320d4ff834e19f819fe8a61d.zip
Undo rustfmt reformating
-rw-r--r--test/test_fcntl.rs104
1 files changed, 47 insertions, 57 deletions
diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs
index 89235527..6b78bc70 100644
--- a/test/test_fcntl.rs
+++ b/test/test_fcntl.rs
@@ -1,12 +1,12 @@
+use nix::Error;
use nix::errno::*;
-use nix::fcntl::{open, openat, readlink, readlinkat, renameat, OFlag};
+use nix::fcntl::{openat, open, OFlag, readlink, readlinkat, renameat};
use nix::sys::stat::Mode;
use nix::unistd::{close, read};
-use nix::Error;
+use tempfile::{self, NamedTempFile};
use std::fs::File;
use std::io::prelude::*;
use std::os::unix::fs;
-use tempfile::{self, NamedTempFile};
#[test]
fn test_openat() {
@@ -14,14 +14,13 @@ fn test_openat() {
let mut tmp = NamedTempFile::new().unwrap();
tmp.write_all(CONTENTS).unwrap();
- let dirfd = open(tmp.path().parent().unwrap(), OFlag::empty(), Mode::empty()).unwrap();
- let fd = openat(
- dirfd,
- tmp.path().file_name().unwrap(),
- OFlag::O_RDONLY,
- Mode::empty(),
- )
- .unwrap();
+ let dirfd = open(tmp.path().parent().unwrap(),
+ OFlag::empty(),
+ Mode::empty()).unwrap();
+ let fd = openat(dirfd,
+ tmp.path().file_name().unwrap(),
+ OFlag::O_RDONLY,
+ Mode::empty()).unwrap();
let mut buf = [0u8; 1024];
assert_eq!(4, read(fd, &mut buf).unwrap());
@@ -40,10 +39,8 @@ fn test_renameat() {
let new_dir = tempfile::tempdir().unwrap();
let new_dirfd = open(new_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
renameat(Some(old_dirfd), "old", Some(new_dirfd), "new").unwrap();
- assert_eq!(
- renameat(Some(old_dirfd), "old", Some(new_dirfd), "new").unwrap_err(),
- Error::Sys(Errno::ENOENT)
- );
+ assert_eq!(renameat(Some(old_dirfd), "old", Some(new_dirfd), "new").unwrap_err(),
+ Error::Sys(Errno::ENOENT));
close(old_dirfd).unwrap();
close(new_dirfd).unwrap();
assert!(new_dir.path().join("new").exists());
@@ -56,14 +53,14 @@ fn test_readlink() {
let dst = tempdir.path().join("b");
println!("a: {:?}, b: {:?}", &src, &dst);
fs::symlink(&src.as_path(), &dst.as_path()).unwrap();
- let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap();
+ let dirfd = open(tempdir.path(),
+ OFlag::empty(),
+ Mode::empty()).unwrap();
let expected_dir = src.to_str().unwrap();
assert_eq!(readlink(&dst).unwrap().to_str().unwrap(), expected_dir);
- assert_eq!(
- readlinkat(dirfd, "b").unwrap().to_str().unwrap(),
- expected_dir
- );
+ assert_eq!(readlinkat(dirfd, "b").unwrap().to_str().unwrap(), expected_dir);
+
}
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -128,15 +125,8 @@ mod linux_android {
let (rd, wr) = pipe().unwrap();
let mut offset: loff_t = 5;
- let res = splice(
- tmp.as_raw_fd(),
- Some(&mut offset),
- wr,
- None,
- 2,
- SpliceFFlags::empty(),
- )
- .unwrap();
+ let res = splice(tmp.as_raw_fd(), Some(&mut offset),
+ wr, None, 2, SpliceFFlags::empty()).unwrap();
assert_eq!(2, res);
@@ -274,22 +264,20 @@ mod linux_android {
}
}
-#[cfg(any(
- target_os = "linux",
- target_os = "android",
- target_os = "emscripten",
- target_os = "fuchsia",
- any(target_os = "wasi", target_env = "wasi"),
- target_env = "uclibc",
- target_env = "freebsd"
-))]
+#[cfg(any(target_os = "linux",
+ target_os = "android",
+ target_os = "emscripten",
+ target_os = "fuchsia",
+ any(target_os = "wasi", target_env = "wasi"),
+ target_env = "uclibc",
+ target_env = "freebsd"))]
mod test_posix_fadvise {
+ use tempfile::NamedTempFile;
+ use std::os::unix::io::{RawFd, AsRawFd};
use nix::errno::Errno;
use nix::fcntl::*;
use nix::unistd::pipe;
- use std::os::unix::io::{AsRawFd, RawFd};
- use tempfile::NamedTempFile;
#[test]
fn test_success() {
@@ -303,30 +291,25 @@ mod test_posix_fadvise {
#[test]
fn test_errno() {
let (rd, _wr) = pipe().unwrap();
- let errno =
- posix_fadvise(rd as RawFd, 0, 100, PosixFadviseAdvice::POSIX_FADV_WILLNEED).unwrap();
+ let errno = posix_fadvise(rd as RawFd, 0, 100, PosixFadviseAdvice::POSIX_FADV_WILLNEED)
+ .unwrap();
assert_eq!(errno, Errno::ESPIPE as i32);
}
}
-#[cfg(any(
- target_os = "linux",
- target_os = "android",
- target_os = "emscripten",
- target_os = "fuchsia",
- any(target_os = "wasi", target_env = "wasi"),
- target_os = "freebsd"
-))]
+#[cfg(any(target_os = "linux",
+ target_os = "android",
+ target_os = "emscripten",
+ target_os = "fuchsia",
+ any(target_os = "wasi", target_env = "wasi"),
+ target_os = "freebsd"))]
mod test_posix_fallocate {
+ use tempfile::NamedTempFile;
+ use std::{io::Read, os::unix::io::{RawFd, AsRawFd}};
use nix::errno::Errno;
use nix::fcntl::*;
use nix::unistd::pipe;
- use std::{
- io::Read,
- os::unix::io::{AsRawFd, RawFd},
- };
- use tempfile::NamedTempFile;
#[test]
fn success() {
@@ -358,8 +341,15 @@ mod test_posix_fallocate {
let err = posix_fallocate(rd as RawFd, 0, 100).unwrap_err();
use nix::Error::Sys;
match err {
- Sys(Errno::EINVAL) | Sys(Errno::ENODEV) | Sys(Errno::ESPIPE) | Sys(Errno::EBADF) => (),
- errno => panic!("unexpected errno {}", errno,),
+ Sys(Errno::EINVAL)
+ | Sys(Errno::ENODEV)
+ | Sys(Errno::ESPIPE)
+ | Sys(Errno::EBADF) => (),
+ errno =>
+ panic!(
+ "unexpected errno {}",
+ errno,
+ ),
}
}
}