From f425f445d14007d3a3dd10c7f0ca90177b9dee2e Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sun, 13 Oct 2019 14:48:07 -0500 Subject: [PATCH] Check that fs errors have the proper kind --- tests/run-pass/fs.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/run-pass/fs.rs b/tests/run-pass/fs.rs index 212e5e27d8a..7765e5b368e 100644 --- a/tests/run-pass/fs.rs +++ b/tests/run-pass/fs.rs @@ -2,7 +2,7 @@ // compile-flags: -Zmiri-disable-isolation use std::fs::{File, remove_file}; -use std::io::{Read, Write}; +use std::io::{Read, Write, ErrorKind}; fn main() { let path = std::env::temp_dir().join("miri_test_fs.txt"); @@ -23,8 +23,10 @@ fn main() { assert_eq!(bytes, contents.as_slice()); // Removing file should succeed remove_file(&path).unwrap(); - // Opening non-existing file should fail - assert!(File::open(&path).is_err()); - // Removing non-existing file should fail - assert!(remove_file(&path).is_err()); + + // The two following tests also check that the `__errno_location()` shim is working properly. + // Opening a non-existing file should fail with a "not found" error. + assert_eq!(ErrorKind::NotFound, File::open(&path).unwrap_err().kind()); + // Removing a non-existing file should fail with a "not found" error. + assert_eq!(ErrorKind::NotFound, remove_file(&path).unwrap_err().kind()); } -- 2.44.0