Skip to content

Commit

Permalink
use tempfile in test_pwrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers committed Oct 24, 2016
1 parent 001fecb commit 40351db
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/sys/test_uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::fs::{OpenOptions, remove_file};
use std::os::unix::io::AsRawFd;

use tempdir::TempDir;
use tempfile::tempfile;

#[test]
fn test_writev() {
Expand Down Expand Up @@ -99,18 +100,14 @@ fn test_readv() {
fn test_pwrite() {
use std::io::Read;

let path = "pwrite_test_file";
let mut file = OpenOptions::new().write(true).read(true).create(true)
.truncate(true).open(path).unwrap();
let mut file = tempfile().unwrap();
let buf = [1u8;8];
assert_eq!(Ok(8), pwrite(file.as_raw_fd(), &buf, 8));
let mut file_content = Vec::new();
file.read_to_end(&mut file_content).unwrap();
let mut expected = vec![0u8;8];
expected.extend(vec![1;8]);
assert_eq!(file_content, expected);

remove_file(path).unwrap();
}

#[test]
Expand Down

0 comments on commit 40351db

Please sign in to comment.