fs: fix File::from_raw_fd test (#5528)

This commit is contained in:
Tymoteusz Wiśniewski
2023-03-04 11:45:42 +01:00
committed by GitHub
parent bd4ce68864
commit ff2f286c12
+2 -3
View File
@@ -184,14 +184,13 @@ async fn unix_fd_is_valid() {
#[tokio::test]
#[cfg(unix)]
async fn read_file_from_unix_fd() {
use std::os::unix::io::AsRawFd;
use std::os::unix::io::FromRawFd;
use std::os::unix::io::{FromRawFd, IntoRawFd};
let mut tempfile = tempfile();
tempfile.write_all(HELLO).unwrap();
let file1 = File::open(tempfile.path()).await.unwrap();
let raw_fd = file1.as_raw_fd();
let raw_fd = file1.into_std().await.into_raw_fd();
assert!(raw_fd > 0);
let mut file2 = unsafe { File::from_raw_fd(raw_fd) };