1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-06-08 15:56:16 +02:00

Fix clippy warning (#1638)

Signed-off-by: Eric Fang <yihuaf@unkies.org>
This commit is contained in:
Eric Fang 2023-03-08 22:29:12 -08:00 committed by GitHub
parent 84c0f5bd22
commit fe58002c31
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 33 deletions

View File

@ -47,7 +47,7 @@ test-all: unittest featuretest oci-tests containerd-test # currently not doing r
# Misc
lint:
cargo clippy --all-targets --all-features
cargo clippy --all-targets --all-features -- -D warnings
clean:
./scripts/clean.sh $(ROOT)

View File

@ -340,15 +340,14 @@ fn check_recursive_rdev() -> TestResult {
mount_spec
.set_destination(mount_dest_path)
.set_typ(None)
.set_source(Some(rdev_base_dir.clone()))
.set_source(Some(rdev_base_dir))
.set_options(Some(mount_options));
let spec = get_spec(
vec![mount_spec],
vec!["runtimetest".to_string(), "mounts_recursive".to_string()],
);
let result = test_inside_container(spec, &|_| Ok(()));
result
test_inside_container(spec, &|_| Ok(()))
}
fn check_recursive_rnodev() -> TestResult {
@ -360,15 +359,14 @@ fn check_recursive_rnodev() -> TestResult {
mount_spec
.set_destination(mount_dest_path)
.set_typ(None)
.set_source(Some(rnodev_base_dir.clone()))
.set_source(Some(rnodev_base_dir))
.set_options(Some(mount_options));
let spec = get_spec(
vec![mount_spec],
vec!["runtimetest".to_string(), "mounts_recursive".to_string()],
);
let result = test_inside_container(spec, &|_| Ok(()));
result
test_inside_container(spec, &|_| Ok(()))
}
fn check_recursive_readwrite() -> TestResult {

View File

@ -165,7 +165,7 @@ pub fn validate_mounts_recursive(spec: &Spec) {
}
}
"rdiratime" => {
println!("test_dir_update_access_time: {:?}", mount);
println!("test_dir_update_access_time: {mount:?}");
let rest = utils::test_dir_update_access_time(
mount.destination().to_str().unwrap(),
);
@ -174,7 +174,7 @@ pub fn validate_mounts_recursive(spec: &Spec) {
}
}
"rnodiratime" => {
println!("test_dir_not_update_access_time: {:?}", mount);
println!("test_dir_not_update_access_time: {mount:?}");
let rest = utils::test_dir_not_update_access_time(
mount.destination().to_str().unwrap(),
);
@ -183,7 +183,7 @@ pub fn validate_mounts_recursive(spec: &Spec) {
}
}
"rdev" => {
println!("test_device_access: {:?}", mount);
println!("test_device_access: {mount:?}");
let rest =
utils::test_device_access(mount.destination().to_str().unwrap());
if let Err(e) = rest {
@ -191,7 +191,7 @@ pub fn validate_mounts_recursive(spec: &Spec) {
}
}
"rnodev" => {
println!("test_device_unaccess: {:?}", mount);
println!("test_device_unaccess: {mount:?}");
let rest =
utils::test_device_unaccess(mount.destination().to_str().unwrap());
if rest.is_ok() {

View File

@ -88,14 +88,11 @@ pub fn test_file_executable(path: &str) -> Result<(), std::io::Error> {
}
pub fn test_dir_update_access_time(path: &str) -> Result<(), std::io::Error> {
println!("test_dir_update_access_time path: {:?}", path);
println!("test_dir_update_access_time path: {path:?}");
let metadata = fs::metadata(PathBuf::from(path))?;
let rest = metadata.accessed();
let first_access_time = rest.unwrap();
println!(
"{:?} dir first access time is {:?}",
path, first_access_time
);
println!("{path:?} dir first access time is {first_access_time:?}");
// execute ls command to update access time
Command::new("ls")
.arg(path)
@ -105,28 +102,22 @@ pub fn test_dir_update_access_time(path: &str) -> Result<(), std::io::Error> {
let metadata = fs::metadata(PathBuf::from(path))?;
let rest = metadata.accessed();
let second_access_time = rest.unwrap();
println!(
"{:?} dir second access time is {:?}",
path, second_access_time
);
println!("{path:?} dir second access time is {second_access_time:?}");
if first_access_time == second_access_time {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("cannot update access time for path {:?}", path),
format!("cannot update access time for path {path:?}"),
));
}
Ok(())
}
pub fn test_dir_not_update_access_time(path: &str) -> Result<(), std::io::Error> {
println!("test_dir_not_update_access_time path: {:?}", path);
println!("test_dir_not_update_access_time path: {path:?}");
let metadata = fs::metadata(PathBuf::from(path))?;
let rest = metadata.accessed();
let first_access_time = rest.unwrap();
println!(
"{:?} dir first access time is {:?}",
path, first_access_time
);
println!("{path:?} dir first access time is {first_access_time:?}");
// execute ls command to update access time
Command::new("ls")
.arg(path)
@ -136,21 +127,18 @@ pub fn test_dir_not_update_access_time(path: &str) -> Result<(), std::io::Error>
let metadata = fs::metadata(PathBuf::from(path))?;
let rest = metadata.accessed();
let second_access_time = rest.unwrap();
println!(
"{:?} dir second access time is {:?}",
path, second_access_time
);
println!("{path:?} dir second access time is {second_access_time:?}");
if first_access_time != second_access_time {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("cannot update access time for path {:?}", path),
format!("cannot update access time for path {path:?}"),
));
}
Ok(())
}
pub fn test_device_access(path: &str) -> Result<(), std::io::Error> {
println!("test_device_access path: {:?}", path);
println!("test_device_access path: {path:?}");
let _ = std::fs::OpenOptions::new()
.create(true)
.write(true)
@ -159,7 +147,7 @@ pub fn test_device_access(path: &str) -> Result<(), std::io::Error> {
}
pub fn test_device_unaccess(path: &str) -> Result<(), std::io::Error> {
println!("test_device_unaccess path: {:?}", path);
println!("test_device_unaccess path: {path:?}");
let _ = std::fs::OpenOptions::new()
.create(true)
.write(true)