1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

fix clippy tests

This commit is contained in:
n4n5 2024-06-30 16:27:08 +02:00
parent 81de2be5ab
commit ab67947321
No known key found for this signature in database
GPG key ID: 79414EADC6D4B457
31 changed files with 1259 additions and 888 deletions

View file

@ -2298,9 +2298,9 @@ fn test_closes_file_descriptors() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_cp_sparse_never_empty() {
const BUFFER_SIZE: usize = 4096 * 4;
let (at, mut ucmd) = at_and_ucmd!();
const BUFFER_SIZE: usize = 4096 * 4;
let buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
at.make_file("src_file1");
@ -2318,10 +2318,10 @@ fn test_cp_sparse_never_empty() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_cp_sparse_always_empty() {
const BUFFER_SIZE: usize = 4096 * 4;
for argument in ["--sparse=always", "--sparse=alway", "--sparse=al"] {
let (at, mut ucmd) = at_and_ucmd!();
const BUFFER_SIZE: usize = 4096 * 4;
let buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
at.make_file("src_file1");
@ -2338,9 +2338,9 @@ fn test_cp_sparse_always_empty() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_cp_sparse_always_non_empty() {
const BUFFER_SIZE: usize = 4096 * 16 + 3;
let (at, mut ucmd) = at_and_ucmd!();
const BUFFER_SIZE: usize = 4096 * 16 + 3;
let mut buf: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE];
let blocks_to_touch = [buf.len() / 3, 2 * (buf.len() / 3)];
@ -2408,12 +2408,11 @@ fn test_cp_sparse_never_reflink_always() {
#[cfg(feature = "truncate")]
#[test]
fn test_cp_reflink_always_override() {
let scene = TestScenario::new(util_name!());
const DISK: &str = "disk.img";
const ROOTDIR: &str = "disk_root/";
const USERDIR: &str = "dir/";
const MOUNTPOINT: &str = "mountpoint/";
let scene = TestScenario::new(util_name!());
let src1_path: &str = &[MOUNTPOINT, USERDIR, "src1"].concat();
let src2_path: &str = &[MOUNTPOINT, USERDIR, "src2"].concat();
@ -2545,12 +2544,12 @@ fn test_no_preserve_mode() {
let umask: u16 = 0o022;
ucmd.arg("file")
.arg("dest")
.umask(umask as libc::mode_t)
.umask(libc::mode_t::from(umask))
.succeeds()
.no_stderr()
.no_stdout();
// remove sticky bit, setuid and setgid bit; apply umask
let expected_perms = PERMS_ALL & !0o7000 & !umask as u32;
let expected_perms = PERMS_ALL & !0o7000 & u32::from(!umask);
assert_eq!(
at.plus("dest").metadata().unwrap().mode() & 0o7777,
expected_perms
@ -5477,16 +5476,17 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
let start_time = std::time::Instant::now();
// wait for cp to create dirs
loop {
if start_time.elapsed() >= timeout {
panic!("timed out: cp took too long to create destination directory")
}
assert!(
start_time.elapsed() < timeout,
"timed out: cp took too long to create destination directory"
);
if at.dir_exists(&format!("{}/{}", DEST_DIR, SRC_DIR)) {
break;
}
std::thread::sleep(Duration::from_millis(100));
}
let mode = at.metadata(&format!("{}/{}", DEST_DIR, SRC_DIR)).mode();
#[allow(clippy::unnecessary_cast)]
#[allow(clippy::unnecessary_cast, clippy::cast_lossless)]
let mask = if attr == "mode" {
libc::S_IWGRP | libc::S_IWOTH
} else {