Skip to content

Commit

Permalink
Auto merge of #443 - asomers:mkstemp, r=posborne
Browse files Browse the repository at this point in the history
use tempfile in test_pwrite

Use tempfile in test_pwrite so as not to pollute the source directory.
  • Loading branch information
homu committed Oct 24, 2016
2 parents bf1e6b2 + 40351db commit e618485
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 e618485

Please sign in to comment.