File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
// ignore-windows: File handling is not implemented yet
2
2
// compile-flags: -Zmiri-disable-isolation
3
3
4
+ #![ feature( rustc_private) ]
5
+
6
+ extern crate libc;
7
+
4
8
use std:: fs:: { File , remove_file} ;
5
9
use std:: io:: { Read , Write , ErrorKind , Result } ;
10
+ use std:: os:: unix:: io:: AsRawFd ;
6
11
use std:: path:: { PathBuf , Path } ;
7
12
8
13
fn test_metadata ( bytes : & [ u8 ] , path : & Path ) -> Result < ( ) > {
@@ -40,6 +45,16 @@ fn main() {
40
45
file. read_to_end ( & mut contents) . unwrap ( ) ;
41
46
assert_eq ! ( bytes, contents. as_slice( ) ) ;
42
47
48
+ // Test calling posix_fadvise on the file.
49
+ unsafe {
50
+ libc:: posix_fadvise (
51
+ file. as_raw_fd ( ) ,
52
+ 0 ,
53
+ bytes. len ( ) as i64 ,
54
+ libc:: POSIX_FADV_DONTNEED ,
55
+ ) ;
56
+ }
57
+
43
58
// Test that metadata of an absolute path is correct.
44
59
test_metadata ( bytes, & path) . unwrap ( ) ;
45
60
// Test that metadata of a relative path is correct.
You can’t perform that action at this time.
0 commit comments