diff options
author | Steve Lau <stevelauc@outlook.com> | 2022-12-08 14:04:22 +0800 |
---|---|---|
committer | Steve Lau <stevelauc@outlook.com> | 2022-12-08 14:04:22 +0800 |
commit | 8f52bc97c96922f61140948eacabf966712d105e (patch) | |
tree | 5271be5f4aed5ec73304796b002bbfd2edbed76d /test/test_unistd.rs | |
parent | 67f7d46c6e9d2089f03b2322d31dcb4b388eb730 (diff) | |
download | nix-8f52bc97c96922f61140948eacabf966712d105e.zip |
feat: I/O safety for 'sys/termios' & 'pty'
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r-- | test/test_unistd.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs index 6619262e..1d50c5fa 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -555,16 +555,13 @@ fn test_lseek() { const CONTENTS: &[u8] = b"abcdef123456"; let mut tmp = tempfile().unwrap(); tmp.write_all(CONTENTS).unwrap(); - let tmpfd = tmp.into_raw_fd(); let offset: off_t = 5; - lseek(tmpfd, offset, Whence::SeekSet).unwrap(); + lseek(tmp.as_raw_fd(), offset, Whence::SeekSet).unwrap(); let mut buf = [0u8; 7]; - crate::read_exact(tmpfd, &mut buf); + crate::read_exact(&tmp, &mut buf); assert_eq!(b"f123456", &buf); - - close(tmpfd).unwrap(); } #[cfg(any(target_os = "linux", target_os = "android"))] @@ -573,15 +570,12 @@ fn test_lseek64() { const CONTENTS: &[u8] = b"abcdef123456"; let mut tmp = tempfile().unwrap(); tmp.write_all(CONTENTS).unwrap(); - let tmpfd = tmp.into_raw_fd(); - lseek64(tmpfd, 5, Whence::SeekSet).unwrap(); + lseek64(tmp.as_raw_fd(), 5, Whence::SeekSet).unwrap(); let mut buf = [0u8; 7]; - crate::read_exact(tmpfd, &mut buf); + crate::read_exact(&tmp, &mut buf); assert_eq!(b"f123456", &buf); - - close(tmpfd).unwrap(); } cfg_if! { |