File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1- use std:: io:: prelude:: * ;
1+ use std:: { io:: prelude:: * , time :: Duration } ;
22
33use compio_fs:: File ;
44use compio_io:: { AsyncReadAtExt , AsyncWriteAt , AsyncWriteAtExt } ;
5+ use compio_runtime:: time:: timeout;
56use tempfile:: NamedTempFile ;
67
78#[ compio_macros:: test]
@@ -79,6 +80,21 @@ async fn cancel_read() {
7980 read_hello ( & file) . await ;
8081}
8182
83+ #[ compio_macros:: test]
84+ async fn timeout_read ( ) {
85+ let mut tempfile = tempfile ( ) ;
86+ tempfile. write_all ( HELLO ) . unwrap ( ) ;
87+
88+ let file = File :: open ( tempfile. path ( ) ) . await . unwrap ( ) ;
89+
90+ // Read a file with timeout.
91+ let _ = timeout ( Duration :: from_nanos ( 1 ) , async { read_hello ( & file) . await } )
92+ . await
93+ . unwrap_err ( ) ;
94+
95+ read_hello ( & file) . await ;
96+ }
97+
8298#[ compio_macros:: test]
8399async fn drop_open ( ) {
84100 let tempfile = tempfile ( ) ;
You can’t perform that action at this time.
0 commit comments