@@ -13,6 +13,7 @@ use std::path::Path;
1313
1414#[ path = "../../utils/mod.rs" ]
1515mod utils;
16+ use utils:: check_nondet;
1617
1718fn main ( ) {
1819 test_path_conversion ( ) ;
@@ -81,25 +82,25 @@ fn test_file() {
8182}
8283
8384fn test_file_partial_reads_writes ( ) {
84- let path = utils:: prepare_with_content ( "miri_test_fs_file.txt" , b"abcdefg" ) ;
85+ let path1 = utils:: prepare_with_content ( "miri_test_fs_file1.txt" , b"abcdefg" ) ;
86+ let path2 = utils:: prepare_with_content ( "miri_test_fs_file2.txt" , b"abcdefg" ) ;
8587
8688 // Ensure we sometimes do incomplete writes.
87- let got_short_write = ( 0 .. 16 ) . any ( |_ | {
88- let _ = remove_file ( & path ) ; // FIXME(win, issue #4483): errors if the file already exists
89- let mut file = File :: create ( & path ) . unwrap ( ) ;
90- file. write ( & [ 0 ; 4 ] ) . unwrap ( ) ! = 4
89+ check_nondet ( | | {
90+ let _ = remove_file ( & path1 ) ; // FIXME(win, issue #4483): errors if the file already exists
91+ let mut file = File :: create ( & path1 ) . unwrap ( ) ;
92+ file. write ( & [ 0 ; 4 ] ) . unwrap ( ) = = 4
9193 } ) ;
92- assert ! ( got_short_write) ;
9394 // Ensure we sometimes do incomplete reads.
94- let got_short_read = ( 0 .. 16 ) . any ( |_ | {
95- let mut file = File :: open ( & path ) . unwrap ( ) ;
95+ check_nondet ( | | {
96+ let mut file = File :: open ( & path2 ) . unwrap ( ) ;
9697 let mut buf = [ 0 ; 4 ] ;
97- file. read ( & mut buf) . unwrap ( ) ! = 4
98+ file. read ( & mut buf) . unwrap ( ) = = 4
9899 } ) ;
99- assert ! ( got_short_read) ;
100100
101101 // Clean up
102- remove_file ( & path) . unwrap ( ) ;
102+ remove_file ( & path1) . unwrap ( ) ;
103+ remove_file ( & path2) . unwrap ( ) ;
103104}
104105
105106fn test_file_clone ( ) {
0 commit comments