File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -908,21 +908,16 @@ mod tests {
908
908
let td = tempfile:: tempdir ( ) . unwrap ( ) ;
909
909
let d = openat:: Dir :: open ( td. path ( ) ) . unwrap ( ) ;
910
910
d. ensure_dir ( "foo" , 0o755 ) . unwrap ( ) ;
911
- d. syncfs ( ) . unwrap ( ) ;
912
911
let before = d. metadata ( "foo" ) . unwrap ( ) ;
912
+ // File timestamps can not be updated faster than kernel ticking granularity,
913
+ // so this artificially sleeps through several timer interrupts.
914
+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
913
915
914
916
d. update_timestamps ( "foo" ) . unwrap ( ) ;
915
- d. syncfs ( ) . unwrap ( ) ;
916
917
let after = d. metadata ( "foo" ) . unwrap ( ) ;
917
-
918
- assert ! (
919
- before. stat( ) . st_atime != after. stat( ) . st_atime
920
- || before. stat( ) . st_atime_nsec != after. stat( ) . st_atime_nsec
921
- ) ;
922
- assert ! (
923
- before. stat( ) . st_mtime != after. stat( ) . st_mtime
924
- || before. stat( ) . st_mtime_nsec != after. stat( ) . st_mtime_nsec
925
- ) ;
918
+ if before. stat ( ) . st_mtime == after. stat ( ) . st_mtime {
919
+ assert_ne ! ( before. stat( ) . st_mtime_nsec, after. stat( ) . st_mtime_nsec) ;
920
+ }
926
921
}
927
922
928
923
#[ test]
You can’t perform that action at this time.
0 commit comments