Skip to content

Commit e618485

Browse files
committed
Auto merge of #443 - asomers:mkstemp, r=posborne
use tempfile in test_pwrite Use tempfile in test_pwrite so as not to pollute the source directory.
2 parents bf1e6b2 + 40351db commit e618485

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

test/sys/test_uio.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::fs::{OpenOptions, remove_file};
66
use std::os::unix::io::AsRawFd;
77

88
use tempdir::TempDir;
9+
use tempfile::tempfile;
910

1011
#[test]
1112
fn test_writev() {
@@ -99,18 +100,14 @@ fn test_readv() {
99100
fn test_pwrite() {
100101
use std::io::Read;
101102

102-
let path = "pwrite_test_file";
103-
let mut file = OpenOptions::new().write(true).read(true).create(true)
104-
.truncate(true).open(path).unwrap();
103+
let mut file = tempfile().unwrap();
105104
let buf = [1u8;8];
106105
assert_eq!(Ok(8), pwrite(file.as_raw_fd(), &buf, 8));
107106
let mut file_content = Vec::new();
108107
file.read_to_end(&mut file_content).unwrap();
109108
let mut expected = vec![0u8;8];
110109
expected.extend(vec![1;8]);
111110
assert_eq!(file_content, expected);
112-
113-
remove_file(path).unwrap();
114111
}
115112

116113
#[test]

0 commit comments

Comments
 (0)