diff options
author | David Tolnay <dtolnay@chromium.org> | 2019-04-17 21:09:41 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-07-11 16:15:38 -0700 |
commit | e33b55c4298c8f0d3dff7f04343e765559463d3a (patch) | |
tree | 6bde0d2e529f9b650270a95526a3a1a4186f7a63 /devices | |
parent | 8f94a9ff71ce766c9e91fb2284d40f327148e708 (diff) | |
download | crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.tar crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.tar.gz crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.tar.bz2 crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.tar.lz crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.tar.xz crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.tar.zst crosvm-e33b55c4298c8f0d3dff7f04343e765559463d3a.zip |
tempfile: Unify the two tempdir implementations
Looks like we ended up with two totally different tempdir implementations: one from CL:520706 and the other from CL:1409705. This CL consolidates them into one implementation. BUG=chromium:974059 TEST=tempfile: cargo test TEST=crosvm: cargo check --all-features TEST=devices: cargo check --tests TEST=sys_util: cargo check --tests TEST=local kokoro TEST=./build_test Cq-Depend: chromium:1574668 Change-Id: Id70e963c9986ed2fc5f160819c4a7f9f16092b3b Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1573227 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Diffstat (limited to 'devices')
-rw-r--r-- | devices/Cargo.toml | 3 | ||||
-rw-r--r-- | devices/src/virtio/block.rs | 19 |
2 files changed, 12 insertions, 10 deletions
diff --git a/devices/Cargo.toml b/devices/Cargo.toml index 62b570e..8cfe8dd 100644 --- a/devices/Cargo.toml +++ b/devices/Cargo.toml @@ -37,3 +37,6 @@ usb_util = { path = "../usb_util" } vhost = { path = "../vhost" } virtio_sys = { path = "../virtio_sys" } vm_control = { path = "../vm_control" } + +[dev-dependencies] +tempfile = { path = "../tempfile" } diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs index 59cc51a..f638a0e 100644 --- a/devices/src/virtio/block.rs +++ b/devices/src/virtio/block.rs @@ -1035,15 +1035,14 @@ impl<T: 'static + AsRawFd + DiskFile + Send> VirtioDevice for Block<T> { #[cfg(test)] mod tests { use std::fs::{File, OpenOptions}; - use std::path::PathBuf; - use sys_util::TempDir; + use tempfile::TempDir; use super::*; #[test] fn read_size() { - let tempdir = TempDir::new("/tmp/block_read_test").unwrap(); - let mut path = PathBuf::from(tempdir.as_path().unwrap()); + let tempdir = TempDir::new().unwrap(); + let mut path = tempdir.path().to_owned(); path.push("disk_image"); let f = File::create(&path).unwrap(); f.set_len(0x1000).unwrap(); @@ -1061,8 +1060,8 @@ mod tests { #[test] fn read_features() { - let tempdir = TempDir::new("/tmp/block_read_test").unwrap(); - let mut path = PathBuf::from(tempdir.as_path().unwrap()); + let tempdir = TempDir::new().unwrap(); + let mut path = tempdir.path().to_owned(); path.push("disk_image"); // read-write block device @@ -1086,8 +1085,8 @@ mod tests { #[test] fn read_last_sector() { - let tempdir = TempDir::new("/tmp/block_read_test").unwrap(); - let mut path = PathBuf::from(tempdir.as_path().unwrap()); + let tempdir = TempDir::new().unwrap(); + let mut path = tempdir.path().to_owned(); path.push("disk_image"); let mut f = OpenOptions::new() .read(true) @@ -1129,8 +1128,8 @@ mod tests { #[test] fn read_beyond_last_sector() { - let tempdir = TempDir::new("/tmp/block_read_test").unwrap(); - let mut path = PathBuf::from(tempdir.as_path().unwrap()); + let tempdir = TempDir::new().unwrap(); + let mut path = tempdir.path().to_owned(); path.push("disk_image"); let mut f = OpenOptions::new() .read(true) |