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 } ;
2
2
3
3
use compio_fs:: File ;
4
4
use compio_io:: { AsyncReadAtExt , AsyncWriteAt , AsyncWriteAtExt } ;
5
+ use compio_runtime:: time:: timeout;
5
6
use tempfile:: NamedTempFile ;
6
7
7
8
#[ compio_macros:: test]
@@ -79,6 +80,21 @@ async fn cancel_read() {
79
80
read_hello ( & file) . await ;
80
81
}
81
82
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
+
82
98
#[ compio_macros:: test]
83
99
async fn drop_open ( ) {
84
100
let tempfile = tempfile ( ) ;
You can’t perform that action at this time.
0 commit comments