summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Saveau <saveau.alexandre@gmail.com>2022-12-03 13:40:32 -0800
committerAlex Saveau <saveau.alexandre@gmail.com>2022-12-04 13:44:50 -0800
commitfb802462a6c5c254f544dc2601ebe5ef8ab110bc (patch)
treeb79fe64a43077760ec7ec73cce54d0a93fa52d61 /test
parente2ff9d53b66b719f3d356604497747d87a7474a5 (diff)
downloadnix-fb802462a6c5c254f544dc2601ebe5ef8ab110bc.zip
Fix clippy lints
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_aio.rs2
-rw-r--r--test/sys/test_signal.rs8
-rw-r--r--test/sys/test_socket.rs12
-rw-r--r--test/test_fcntl.rs2
-rw-r--r--test/test_mount.rs42
-rw-r--r--test/test_unistd.rs13
6 files changed, 34 insertions, 45 deletions
diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs
index 84086f80..fdabaca6 100644
--- a/test/sys/test_aio.rs
+++ b/test/sys/test_aio.rs
@@ -610,7 +610,7 @@ fn test_aio_suspend() {
let r = aio_suspend(&cbbuf[..], Some(timeout));
match r {
Err(Errno::EINTR) => continue,
- Err(e) => panic!("aio_suspend returned {:?}", e),
+ Err(e) => panic!("aio_suspend returned {e:?}"),
Ok(_) => (),
};
}
diff --git a/test/sys/test_signal.rs b/test/sys/test_signal.rs
index 3ad14f40..721cb9c9 100644
--- a/test/sys/test_signal.rs
+++ b/test/sys/test_signal.rs
@@ -54,9 +54,8 @@ fn test_sigprocmask() {
// test don't make sense.
assert!(
!old_signal_set.contains(SIGNAL),
- "the {:?} signal is already blocked, please change to a \
- different one",
- SIGNAL
+ "the {SIGNAL:?} signal is already blocked, please change to a \
+ different one"
);
// Now block the signal.
@@ -71,8 +70,7 @@ fn test_sigprocmask() {
.expect("expect to be able to retrieve old signals");
assert!(
old_signal_set.contains(SIGNAL),
- "expected the {:?} to be blocked",
- SIGNAL
+ "expected the {SIGNAL:?} to be blocked"
);
// Reset the signal.
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index 1413eb6b..2ab6c54f 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -626,7 +626,7 @@ mod recvfrom {
println!("IPv6 not available, skipping test.");
return;
}
- Err(e) => panic!("bind: {}", e),
+ Err(e) => panic!("bind: {e}"),
Ok(()) => (),
}
let ssock = socket(
@@ -1272,7 +1272,7 @@ fn test_scm_credentials() {
ControlMessageOwned::ScmCredentials(cred) => cred,
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
ControlMessageOwned::ScmCreds(cred) => cred,
- other => panic!("unexpected cmsg {:?}", other),
+ other => panic!("unexpected cmsg {other:?}"),
};
assert!(received_cred.is_none());
assert_eq!(cred.pid(), getpid().as_raw());
@@ -1550,7 +1550,7 @@ fn loopback_address(
Err(e) => {
let stdioerr = io::stderr();
let mut handle = stdioerr.lock();
- writeln!(handle, "getifaddrs: {:?}", e).unwrap();
+ writeln!(handle, "getifaddrs: {e:?}").unwrap();
return None;
}
};
@@ -2347,7 +2347,7 @@ mod linux_errqueue {
}
*ext_err
} else {
- panic!("Unexpected control message {:?}", cmsg);
+ panic!("Unexpected control message {cmsg:?}");
}
},
)
@@ -2398,7 +2398,7 @@ mod linux_errqueue {
}
*ext_err
} else {
- panic!("Unexpected control message {:?}", cmsg);
+ panic!("Unexpected control message {cmsg:?}");
}
},
)
@@ -2432,7 +2432,7 @@ mod linux_errqueue {
MsgFlags::empty(),
) {
assert_eq!(e, Errno::EADDRNOTAVAIL);
- println!("{:?} not available, skipping test.", af);
+ println!("{af:?} not available, skipping test.");
return;
}
diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs
index e51044a0..fb2a5e2e 100644
--- a/test/test_fcntl.rs
+++ b/test/test_fcntl.rs
@@ -559,7 +559,7 @@ mod test_posix_fallocate {
let err = posix_fallocate(rd as RawFd, 0, 100).unwrap_err();
match err {
Errno::EINVAL | Errno::ENODEV | Errno::ESPIPE | Errno::EBADF => (),
- errno => panic!("unexpected errno {}", errno,),
+ errno => panic!("unexpected errno {errno}",),
}
}
}
diff --git a/test/test_mount.rs b/test/test_mount.rs
index 2fd612e3..5cf00408 100644
--- a/test/test_mount.rs
+++ b/test/test_mount.rs
@@ -38,7 +38,7 @@ exit 23";
MsFlags::empty(),
NONE,
)
- .unwrap_or_else(|e| panic!("mount failed: {}", e));
+ .unwrap_or_else(|e| panic!("mount failed: {e}"));
let test_path = tempdir.path().join("test");
@@ -67,17 +67,17 @@ exit 23";
.unwrap();
process::exit(0);
} else {
- panic!("open failed: {}", e);
+ panic!("open failed: {e}");
}
})
.and_then(|mut f| f.write(SCRIPT_CONTENTS))
- .unwrap_or_else(|e| panic!("write failed: {}", e));
+ .unwrap_or_else(|e| panic!("write failed: {e}"));
// Verify read.
let mut buf = Vec::new();
File::open(&test_path)
.and_then(|mut f| f.read_to_end(&mut buf))
- .unwrap_or_else(|e| panic!("read failed: {}", e));
+ .unwrap_or_else(|e| panic!("read failed: {e}"));
assert_eq!(buf, SCRIPT_CONTENTS);
// Verify execute.
@@ -85,13 +85,12 @@ exit 23";
EXPECTED_STATUS,
Command::new(&test_path)
.status()
- .unwrap_or_else(|e| panic!("exec failed: {}", e))
+ .unwrap_or_else(|e| panic!("exec failed: {e}"))
.code()
.unwrap_or_else(|| panic!("child killed by signal"))
);
- umount(tempdir.path())
- .unwrap_or_else(|e| panic!("umount failed: {}", e));
+ umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}"));
}
pub fn test_mount_rdonly_disallows_write() {
@@ -104,7 +103,7 @@ exit 23";
MsFlags::MS_RDONLY,
NONE,
)
- .unwrap_or_else(|e| panic!("mount failed: {}", e));
+ .unwrap_or_else(|e| panic!("mount failed: {e}"));
// EROFS: Read-only file system
assert_eq!(
@@ -115,8 +114,7 @@ exit 23";
.unwrap()
);
- umount(tempdir.path())
- .unwrap_or_else(|e| panic!("umount failed: {}", e));
+ umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}"));
}
pub fn test_mount_noexec_disallows_exec() {
@@ -129,7 +127,7 @@ exit 23";
MsFlags::MS_NOEXEC,
NONE,
)
- .unwrap_or_else(|e| panic!("mount failed: {}", e));
+ .unwrap_or_else(|e| panic!("mount failed: {e}"));
let test_path = tempdir.path().join("test");
@@ -139,13 +137,13 @@ exit 23";
.mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits())
.open(&test_path)
.and_then(|mut f| f.write(SCRIPT_CONTENTS))
- .unwrap_or_else(|e| panic!("write failed: {}", e));
+ .unwrap_or_else(|e| panic!("write failed: {e}"));
// Verify that we cannot execute despite a+x permissions being set.
let mode = stat::Mode::from_bits_truncate(
fs::metadata(&test_path)
.map(|md| md.permissions().mode())
- .unwrap_or_else(|e| panic!("metadata failed: {}", e)),
+ .unwrap_or_else(|e| panic!("metadata failed: {e}")),
);
assert!(
@@ -164,8 +162,7 @@ exit 23";
.unwrap()
);
- umount(tempdir.path())
- .unwrap_or_else(|e| panic!("umount failed: {}", e));
+ umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}"));
}
pub fn test_mount_bind() {
@@ -182,7 +179,7 @@ exit 23";
MsFlags::MS_BIND,
NONE,
)
- .unwrap_or_else(|e| panic!("mount failed: {}", e));
+ .unwrap_or_else(|e| panic!("mount failed: {e}"));
fs::OpenOptions::new()
.create(true)
@@ -190,10 +187,10 @@ exit 23";
.mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits())
.open(mount_point.path().join(file_name))
.and_then(|mut f| f.write(SCRIPT_CONTENTS))
- .unwrap_or_else(|e| panic!("write failed: {}", e));
+ .unwrap_or_else(|e| panic!("write failed: {e}"));
umount(mount_point.path())
- .unwrap_or_else(|e| panic!("umount failed: {}", e));
+ .unwrap_or_else(|e| panic!("umount failed: {e}"));
}
// Verify the file written in the mount shows up in source directory, even
@@ -202,7 +199,7 @@ exit 23";
let mut buf = Vec::new();
File::open(tempdir.path().join(file_name))
.and_then(|mut f| f.read_to_end(&mut buf))
- .unwrap_or_else(|e| panic!("read failed: {}", e));
+ .unwrap_or_else(|e| panic!("read failed: {e}"));
assert_eq!(buf, SCRIPT_CONTENTS);
}
@@ -214,8 +211,7 @@ exit 23";
let stderr = io::stderr();
let mut handle = stderr.lock();
writeln!(handle,
- "unshare failed: {}. Are unprivileged user namespaces available?",
- e).unwrap();
+ "unshare failed: {e}. Are unprivileged user namespaces available?").unwrap();
writeln!(handle, "mount is not being tested").unwrap();
// Exit with success because not all systems support unprivileged user namespaces, and
// that's not what we're testing for.
@@ -226,8 +222,8 @@ exit 23";
fs::OpenOptions::new()
.write(true)
.open("/proc/self/uid_map")
- .and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes()))
- .unwrap_or_else(|e| panic!("could not write uid map: {}", e));
+ .and_then(|mut f| f.write(format!("1000 {uid} 1\n").as_bytes()))
+ .unwrap_or_else(|e| panic!("could not write uid map: {e}"));
}
}
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 9e20f977..6619262e 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -56,11 +56,11 @@ fn test_fork_and_waitpid() {
// panic, must never happen
s @ Ok(_) => {
- panic!("Child exited {:?}, should never happen", s)
+ panic!("Child exited {s:?}, should never happen")
}
// panic, waitpid should never fail
- Err(s) => panic!("Error: waitpid returned Err({:?}", s),
+ Err(s) => panic!("Error: waitpid returned Err({s:?}"),
}
}
}
@@ -94,7 +94,7 @@ fn test_mkstemp() {
close(fd).unwrap();
unlink(path.as_path()).unwrap();
}
- Err(e) => panic!("mkstemp failed: {}", e),
+ Err(e) => panic!("mkstemp failed: {e}"),
}
}
@@ -799,12 +799,7 @@ static mut ALARM_CALLED: bool = false;
// Used in `test_alarm`.
#[cfg(not(target_os = "redox"))]
pub extern "C" fn alarm_signal_handler(raw_signal: libc::c_int) {
- assert_eq!(
- raw_signal,
- libc::SIGALRM,
- "unexpected signal: {}",
- raw_signal
- );
+ assert_eq!(raw_signal, libc::SIGALRM, "unexpected signal: {raw_signal}");
unsafe { ALARM_CALLED = true };
}