File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ fn main() {
3838 test_posix_fadvise ( ) ;
3939 #[ cfg( target_os = "linux" ) ]
4040 test_sync_file_range ( ) ;
41+ #[ cfg( target_os = "linux" ) ]
42+ test_fstat ( ) ;
4143 test_isatty ( ) ;
4244 test_read_and_uninit ( ) ;
4345 test_nofollow_not_symlink ( ) ;
@@ -380,6 +382,25 @@ fn test_sync_file_range() {
380382 assert_eq ! ( result_2, 0 ) ;
381383}
382384
385+ #[ cfg( target_os = "linux" ) ]
386+ fn test_fstat ( ) {
387+ use std:: mem:: MaybeUninit ;
388+ use std:: os:: unix:: io:: AsRawFd ;
389+
390+ let path = utils:: prepare_with_content ( "miri_test_libc_fstat.txt" , b"hello" ) ;
391+ let file = File :: open ( & path) . unwrap ( ) ;
392+ let fd = file. as_raw_fd ( ) ;
393+
394+ let mut stat: libc:: stat = unsafe { MaybeUninit :: zeroed ( ) . assume_init ( ) } ;
395+ let res = unsafe { libc:: fstat ( fd, & mut stat) } ;
396+ assert_eq ! ( res, 0 ) ;
397+
398+ assert_eq ! ( stat. st_size, 5 ) ;
399+ assert_eq ! ( stat. st_mode & libc:: S_IFMT , libc:: S_IFREG ) ;
400+
401+ remove_file ( & path) . unwrap ( ) ;
402+ }
403+
383404fn test_isatty ( ) {
384405 // Testing whether our isatty shim returns the right value would require controlling whether
385406 // these streams are actually TTYs, which is hard.
You can’t perform that action at this time.
0 commit comments