33
44use std:: fs:: { File , remove_file, metadata} ;
55use 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 = 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 ] ) { }
620
721fn main ( ) {
822 let path = std:: env:: temp_dir ( ) . join ( "miri_test_fs.txt" ) ;
@@ -22,12 +36,8 @@ fn main() {
2236 file. read_to_end ( & mut contents) . unwrap ( ) ;
2337 assert_eq ! ( bytes, contents. as_slice( ) ) ;
2438
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) ;
3141
3242 // Removing file should succeed.
3343 remove_file ( & path) . unwrap ( ) ;
0 commit comments