Skip to content

Commit 803d1da

Browse files
Serban Iorgabonzini
authored andcommitted
[mmap_unix] remove dependency on tempfile
Signed-off-by: Serban Iorga <seriorga@amazon.com>
1 parent 023082a commit 803d1da

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mmap_unix.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ mod tests {
261261
use std::io::Write;
262262
use std::slice;
263263
use std::sync::Arc;
264+
use vmm_sys_util::tempfile::TempFile;
264265

265266
// Adding a helper method to extract the errno within an Error::Mmap(e), or return a
266267
// distinctive value when the error is represented by another variant.
@@ -291,7 +292,7 @@ mod tests {
291292

292293
#[test]
293294
fn test_mmap_region_from_file() {
294-
let mut f = tempfile::tempfile().unwrap();
295+
let mut f = TempFile::new().unwrap().into_file();
295296
let offset: usize = 0;
296297
let buf1 = [1u8, 2, 3, 4, 5];
297298

@@ -309,7 +310,7 @@ mod tests {
309310

310311
#[test]
311312
fn test_mmap_region_build() {
312-
let a = Arc::new(tempfile::tempfile().unwrap());
313+
let a = Arc::new(TempFile::new().unwrap().into_file());
313314

314315
let prot = libc::PROT_READ | libc::PROT_WRITE;
315316
let flags = libc::MAP_NORESERVE | libc::MAP_PRIVATE;
@@ -372,7 +373,7 @@ mod tests {
372373

373374
#[test]
374375
fn test_mmap_region_fds_overlap() {
375-
let a = Arc::new(tempfile::tempfile().unwrap());
376+
let a = Arc::new(TempFile::new().unwrap().into_file());
376377
assert_eq!(unsafe { libc::ftruncate(a.as_raw_fd(), 1024 * 10) }, 0);
377378

378379
let r1 = MmapRegion::from_file(FileOffset::from_arc(a.clone(), 0), 4096).unwrap();
@@ -386,7 +387,7 @@ mod tests {
386387
assert!(r1.fds_overlap(&r2));
387388

388389
// Different files, so there's not overlap.
389-
let new_file = tempfile::tempfile().unwrap();
390+
let new_file = TempFile::new().unwrap().into_file();
390391
// Resize before mapping.
391392
assert_eq!(
392393
unsafe { libc::ftruncate(new_file.as_raw_fd(), 1024 * 10) },

0 commit comments

Comments
 (0)