summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-08-12 01:22:12 +0000
committerGitHub <noreply@github.com>2022-08-12 01:22:12 +0000
commita9861d873eaba52c9bf0f5b02552c567cadf6591 (patch)
treef62fe97f0ad2c8fee7d4700dde7991981039984f /test
parent09b4b4904641edf786b7b377b7998fab3df4da29 (diff)
parent217c3b514148ff2c7bcfdfa808df2316d56db281 (diff)
downloadnix-a9861d873eaba52c9bf0f5b02552c567cadf6591.zip
Merge #1785
1785: Remove deprecated items r=asomers a=SteveLauC #### What this pr does 1. Convert `assert!(x == y)` to `assert_eq!(x, y)` 2. Convert `assert!(x != y)` to `assert_ne!(x, y)` 3. Add `.unwrap()` to unused `Result/Option` (in code comments) 4. Convert `std::ixx::MAX` to `ixx::MAX` 5. Convert `Box<Trait>` to `Box<dyn Trait>` Co-authored-by: SteveLauC <stevelauc@outlook.com> Co-authored-by: SteveLau <stevelauc@outlook.com>
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_pthread.rs2
-rw-r--r--test/sys/test_ptrace.rs4
-rw-r--r--test/test_dir.rs2
-rw-r--r--test/test_pty.rs6
-rw-r--r--test/test_stat.rs8
-rw-r--r--test/test_unistd.rs22
6 files changed, 22 insertions, 22 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..530560fe 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -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.
diff --git a/test/test_dir.rs b/test/test_dir.rs
index 9d2780c0..f6629921 100644
--- a/test/test_dir.rs
+++ b/test/test_dir.rs
@@ -20,7 +20,7 @@ fn flags() -> OFlag {
fn read() {
let tmp = tempdir().unwrap();
File::create(&tmp.path().join("foo")).unwrap();
- ::std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
+ std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
let mut dir = Dir::open(tmp.path(), flags(), Mode::empty()).unwrap();
let mut entries: Vec<_> = dir.iter().map(|e| e.unwrap()).collect();
entries.sort_by(|a, b| a.file_name().cmp(b.file_name()));
diff --git a/test/test_pty.rs b/test/test_pty.rs
index 3b52289e..5c27e2d6 100644
--- a/test/test_pty.rs
+++ b/test/test_pty.rs
@@ -58,7 +58,7 @@ fn test_ptsname_copy() {
assert_eq!(slave_name1, slave_name2);
// Also make sure that the string was actually copied and they point to different parts of
// memory.
- assert!(slave_name1.as_ptr() != slave_name2.as_ptr());
+ assert_ne!(slave_name1.as_ptr(), slave_name2.as_ptr());
}
/// Test data copying of `ptsname_r`
@@ -73,7 +73,7 @@ fn test_ptsname_r_copy() {
let slave_name1 = ptsname_r(&master_fd).unwrap();
let slave_name2 = ptsname_r(&master_fd).unwrap();
assert_eq!(slave_name1, slave_name2);
- assert!(slave_name1.as_ptr() != slave_name2.as_ptr());
+ assert_ne!(slave_name1.as_ptr(), slave_name2.as_ptr());
}
/// Test that `ptsname` returns different names for different devices
@@ -93,7 +93,7 @@ fn test_ptsname_unique() {
// Get the name of the slave
let slave_name1 = unsafe { ptsname(&master1_fd) }.unwrap();
let slave_name2 = unsafe { ptsname(&master2_fd) }.unwrap();
- assert!(slave_name1 != slave_name2);
+ assert_ne!(slave_name1, slave_name2);
}
/// Common setup for testing PTTY pairs
diff --git a/test/test_stat.rs b/test/test_stat.rs
index 1888c649..55f15c07 100644
--- a/test/test_stat.rs
+++ b/test/test_stat.rs
@@ -378,8 +378,8 @@ fn test_mknod() {
let target = tempdir.path().join(file_name);
mknod(&target, SFlag::S_IFREG, Mode::S_IRWXU, 0).unwrap();
let mode = lstat(&target).unwrap().st_mode as mode_t;
- assert!(mode & libc::S_IFREG == libc::S_IFREG);
- assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
+ assert_eq!(mode & libc::S_IFREG, libc::S_IFREG);
+ assert_eq!(mode & libc::S_IRWXU, libc::S_IRWXU);
}
#[test]
@@ -416,6 +416,6 @@ fn test_mknodat() {
)
.unwrap()
.st_mode as mode_t;
- assert!(mode & libc::S_IFREG == libc::S_IFREG);
- assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
+ 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 b08ab332..eee10103 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -114,7 +114,7 @@ fn test_mkfifo() {
let stats = stat::stat(&mkfifo_fifo).unwrap();
let typ = stat::SFlag::from_bits_truncate(stats.st_mode as mode_t);
- assert!(typ == SFlag::S_IFIFO);
+ assert_eq!(typ, SFlag::S_IFIFO);
}
#[test]
@@ -300,7 +300,7 @@ fn test_initgroups() {
}
#[cfg(not(any(target_os = "fuchsia", target_os = "redox")))]
-macro_rules! execve_test_factory(
+macro_rules! execve_test_factory (
($test_name:ident, $syscall:ident, $exe: expr $(, $pathname:expr, $flags:expr)*) => (
#[cfg(test)]
@@ -694,9 +694,9 @@ fn test_sysconf_unsupported() {
#[test]
fn test_getresuid() {
let resuids = getresuid().unwrap();
- assert!(resuids.real.as_raw() != libc::uid_t::max_value());
- assert!(resuids.effective.as_raw() != libc::uid_t::max_value());
- assert!(resuids.saved.as_raw() != libc::uid_t::max_value());
+ assert_ne!(resuids.real.as_raw(), libc::uid_t::MAX);
+ assert_ne!(resuids.effective.as_raw(), libc::uid_t::MAX);
+ assert_ne!(resuids.saved.as_raw(), libc::uid_t::MAX);
}
#[cfg(any(
@@ -709,9 +709,9 @@ fn test_getresuid() {
#[test]
fn test_getresgid() {
let resgids = getresgid().unwrap();
- assert!(resgids.real.as_raw() != libc::gid_t::max_value());
- assert!(resgids.effective.as_raw() != libc::gid_t::max_value());
- assert!(resgids.saved.as_raw() != libc::gid_t::max_value());
+ assert_ne!(resgids.real.as_raw(), libc::gid_t::MAX);
+ assert_ne!(resgids.effective.as_raw(), libc::gid_t::MAX);
+ assert_ne!(resgids.saved.as_raw(), libc::gid_t::MAX);
}
// Test that we can create a pair of pipes. No need to verify that they pass
@@ -1335,7 +1335,7 @@ fn test_faccessat_not_existing() {
Some(dirfd),
not_exist_file,
AccessFlags::F_OK,
- AtFlags::empty()
+ AtFlags::empty(),
)
.err()
.unwrap(),
@@ -1354,7 +1354,7 @@ fn test_faccessat_none_file_exists() {
None,
&path,
AccessFlags::R_OK | AccessFlags::W_OK,
- AtFlags::empty()
+ AtFlags::empty(),
)
.is_ok());
}
@@ -1372,7 +1372,7 @@ fn test_faccessat_file_exists() {
Some(dirfd),
&path,
AccessFlags::R_OK | AccessFlags::W_OK,
- AtFlags::empty()
+ AtFlags::empty(),
)
.is_ok());
}