File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ fn send_recv() -> io::Result<()> {
2929}
3030
3131#[ test]
32- fn into_raw_fd ( ) -> io:: Result < ( ) > {
32+ fn into_raw_fd_datagram ( ) -> io:: Result < ( ) > {
3333 use async_std:: os:: unix:: io:: { FromRawFd , IntoRawFd } ;
3434 task:: block_on ( async {
3535 let ( socket1, socket2) = UnixDatagram :: pair ( ) . unwrap ( ) ;
@@ -45,6 +45,23 @@ fn into_raw_fd() -> io::Result<()> {
4545 } )
4646}
4747
48+ #[ test]
49+ fn into_raw_fd_stream ( ) -> io:: Result < ( ) > {
50+ use async_std:: os:: unix:: io:: { FromRawFd , IntoRawFd } ;
51+ task:: block_on ( async {
52+ let ( mut socket1, socket2) = UnixStream :: pair ( ) . unwrap ( ) ;
53+ socket1. write ( JULIUS_CAESAR ) . await ?;
54+
55+ let mut buf = vec ! [ 0 ; 1024 ] ;
56+
57+ let mut socket2 = unsafe { UnixStream :: from_raw_fd ( socket2. into_raw_fd ( ) ) } ;
58+ let n = socket2. read ( & mut buf) . await ?;
59+ assert_eq ! ( & buf[ ..n] , JULIUS_CAESAR ) ;
60+
61+ Ok ( ( ) )
62+ } )
63+ }
64+
4865const PING : & [ u8 ] = b"ping" ;
4966const PONG : & [ u8 ] = b"pong" ;
5067const TEST_TIMEOUT : Duration = Duration :: from_secs ( 3 ) ;
You can’t perform that action at this time.
0 commit comments