1
1
// ignore-windows: File handling is not implemented yet
2
2
// compile-flags: -Zmiri-disable-isolation
3
3
4
- use std:: fs:: { File , remove_file, metadata } ;
4
+ use std:: fs:: { File , remove_file} ;
5
5
use std:: io:: { Read , Write , ErrorKind } ;
6
+ use std:: path:: Path ;
7
+
8
+ #[ cfg( target_os = "linux" ) ]
9
+ fn test_metadata ( path : & Path , bytes : & [ u8 ] ) {
10
+ // Test that the file metadata is correct.
11
+ let metadata = std:: fs:: metadata ( path) . unwrap ( ) ;
12
+ // `path` should point to a file.
13
+ assert ! ( metadata. is_file( ) ) ;
14
+ // The size of the file must be equal to the number of written bytes.
15
+ assert_eq ! ( bytes. len( ) as u64 , metadata. len( ) ) ;
16
+ }
17
+
18
+ #[ cfg( not( target_os = "linux" ) ) ]
19
+ fn test_metadata ( _path : & Path , _bytes : & [ u8 ] ) { }
6
20
7
21
fn main ( ) {
8
22
let path = std:: env:: temp_dir ( ) . join ( "miri_test_fs.txt" ) ;
@@ -22,12 +36,8 @@ fn main() {
22
36
file. read_to_end ( & mut contents) . unwrap ( ) ;
23
37
assert_eq ! ( bytes, contents. as_slice( ) ) ;
24
38
25
- // Test that the file metadata is correct.
26
- let metadata = metadata ( & path) . unwrap ( ) ;
27
- // `path` should point to a file.
28
- assert ! ( metadata. is_file( ) ) ;
29
- // The size of the file must be equal to the number of written bytes.
30
- assert_eq ! ( bytes. len( ) as u64 , metadata. len( ) ) ;
39
+ // FIXME: Implement stat64 for macos.
40
+ test_metadata ( & path, bytes) ;
31
41
32
42
// Removing file should succeed.
33
43
remove_file ( & path) . unwrap ( ) ;
0 commit comments