Skip to content

Commit 2adc39f

Browse files
committed
Auto merge of #992 - christianpoveda:check-errno-value, r=RalfJung
Check that fs errors have the proper kind r? @RalfJung
2 parents b0bfe9e + f425f44 commit 2adc39f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/run-pass/fs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// compile-flags: -Zmiri-disable-isolation
33

44
use std::fs::{File, remove_file};
5-
use std::io::{Read, Write};
5+
use std::io::{Read, Write, ErrorKind};
66

77
fn main() {
88
let path = std::env::temp_dir().join("miri_test_fs.txt");
@@ -23,8 +23,10 @@ fn main() {
2323
assert_eq!(bytes, contents.as_slice());
2424
// Removing file should succeed
2525
remove_file(&path).unwrap();
26-
// Opening non-existing file should fail
27-
assert!(File::open(&path).is_err());
28-
// Removing non-existing file should fail
29-
assert!(remove_file(&path).is_err());
26+
27+
// The two following tests also check that the `__errno_location()` shim is working properly.
28+
// Opening a non-existing file should fail with a "not found" error.
29+
assert_eq!(ErrorKind::NotFound, File::open(&path).unwrap_err().kind());
30+
// Removing a non-existing file should fail with a "not found" error.
31+
assert_eq!(ErrorKind::NotFound, remove_file(&path).unwrap_err().kind());
3032
}

0 commit comments

Comments
 (0)