diff --git a/tests/integration_test.rs b/tests/integration_test.rs index eba4705..0c7f35c 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -23,10 +23,7 @@ fn get_next_free_device() { assert_eq!( ld0.path(), - Some(PathBuf::from(&format!( - "/dev/loop{}", - num_devices_at_start - ))), + Some(PathBuf::from(&format!("/dev/loop{}", num_devices_at_start))), "should find the first loopback device" ); } @@ -63,7 +60,7 @@ fn attach_a_backing_file_with_sizelimit_overflow() { attach_a_backing_file(0, 128 * 1024 * 1024 * 2, 128 * 1024 * 1024); } -fn attach_a_backing_file(offset: u64, sizelimit: u64, file_size: i64) { +fn attach_a_backing_file(offset: u64, sizelimit: u64, file_size: i32) { let _lock = setup(); let (devices, ld0_path, file_path) = { @@ -148,7 +145,7 @@ fn detach_a_backing_file_with_sizelimit_overflow() { detach_a_backing_file(0, 128 * 1024 * 1024 * 2, 128 * 1024 * 1024); } -fn detach_a_backing_file(offset: u64, sizelimit: u64, file_size: i64) { +fn detach_a_backing_file(offset: u64, sizelimit: u64, file_size: i32) { let num_devices_at_start = list_device(None).len(); let _lock = setup(); diff --git a/tests/util/mod.rs b/tests/util/mod.rs index f225cb9..8035dd1 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -1,6 +1,7 @@ use libc::fallocate; use serde::{Deserialize, Deserializer}; use std::{ + convert::TryInto, io, os::unix::io::AsRawFd, process::Command, @@ -15,9 +16,9 @@ lazy_static! { static ref LOCK: Arc> = Arc::new(Mutex::new(())); } -pub fn create_backing_file(size: i64) -> TempPath { +pub fn create_backing_file(size: i32) -> TempPath { let file = NamedTempFile::new().expect("should be able to create a temp file"); - if unsafe { fallocate(file.as_raw_fd(), 0, 0, size) } < 0 { + if unsafe { fallocate(file.as_raw_fd(), 0, 0, size.try_into().unwrap()) } < 0 { panic!( "should be able to allocate the tenp file: {}", io::Error::last_os_error()