Skip to content

Commit 72c04bf

Browse files
committed
Auto merge of #156389 - RalfJung:miri-fs, r=Mark-Simulacrum
prepare fs tests for miri - reduce iteration counts to get rid of timeouts - disable one test that relies on spawning processes
2 parents 4b0c9d7 + 5901bb8 commit 72c04bf

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

library/std/src/fs/tests.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use rand::RngCore;
22

3-
#[cfg(not(miri))]
43
use super::Dir;
54
use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError};
6-
#[cfg(not(miri))]
7-
use crate::io;
85
use crate::io::prelude::*;
96
use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
107
use crate::mem::MaybeUninit;
@@ -20,7 +17,7 @@ use crate::path::Path;
2017
use crate::sync::Arc;
2118
use crate::test_helpers::{TempDir, tmpdir};
2219
use crate::time::{Duration, Instant, SystemTime};
23-
use crate::{assert_matches, env, str, thread};
20+
use crate::{assert_matches, env, io, str, thread};
2421

2522
macro_rules! check {
2623
($e:expr) => {
@@ -825,10 +822,12 @@ fn recursive_mkdir_failure() {
825822

826823
#[test]
827824
fn concurrent_recursive_mkdir() {
828-
for _ in 0..100 {
825+
let count = if cfg!(miri) { 10 } else { 100 };
826+
let nest = if cfg!(miri) { 10 } else { 40 };
827+
for _ in 0..count {
829828
let dir = tmpdir();
830829
let mut dir = dir.join("a");
831-
for _ in 0..40 {
830+
for _ in 0..nest {
832831
dir = dir.join("a");
833832
}
834833
let mut join = vec![];
@@ -1835,7 +1834,7 @@ fn create_dir_long_paths() {
18351834
fn read_large_dir() {
18361835
let tmpdir = tmpdir();
18371836

1838-
let count = 32 * 1024;
1837+
let count = if cfg!(miri) { 1024 } else { 32 * 1024 };
18391838
for i in 0..count {
18401839
check!(fs::File::create(tmpdir.join(&i.to_string())));
18411840
}
@@ -1920,6 +1919,7 @@ fn test_eq_windows_file_type() {
19201919
/// Regression test for https://github.com/rust-lang/rust/issues/50619.
19211920
#[test]
19221921
#[cfg(target_os = "linux")]
1922+
#[cfg_attr(miri, ignore)] // Cannot spawn processes on Miri
19231923
fn test_read_dir_infinite_loop() {
19241924
use crate::io::ErrorKind;
19251925
use crate::process::Command;
@@ -2495,17 +2495,13 @@ fn test_fs_set_times_nofollow() {
24952495
}
24962496

24972497
#[test]
2498-
// FIXME: libc calls fail on miri
2499-
#[cfg(not(miri))]
25002498
fn test_dir_smoke_test() {
25012499
let tmpdir = tmpdir();
25022500
let dir = Dir::open(tmpdir.path());
25032501
check!(dir);
25042502
}
25052503

25062504
#[test]
2507-
// FIXME: libc calls fail on miri
2508-
#[cfg(not(miri))]
25092505
fn test_dir_read_file() {
25102506
let tmpdir = tmpdir();
25112507
let mut f = check!(File::create(tmpdir.join("foo.txt")));

0 commit comments

Comments
 (0)