1 // ignore-windows: No libc on Windows
2 // compile-flags: -Zmiri-disable-isolation
4 #![feature(rustc_private)]
6 #[allow(unused)] // necessary on macos due to conditional compilation
9 #[cfg(not(target_os = "macos"))]
10 fn test_posix_fadvise() {
11 use std::convert::TryInto;
12 use std::env::temp_dir;
13 use std::fs::{File, remove_file};
15 use std::os::unix::io::AsRawFd;
17 let path = temp_dir().join("miri_test_libc.txt");
18 // Cleanup before test
19 remove_file(&path).ok();
21 // Set up an open file
22 let mut file = File::create(&path).unwrap();
23 let bytes = b"Hello, World!\n";
24 file.write(bytes).unwrap();
26 // Test calling posix_fadvise on a file.
31 bytes.len().try_into().unwrap(),
32 libc::POSIX_FADV_DONTNEED,
36 remove_file(&path).unwrap();
37 assert_eq!(result, 0);
41 #[cfg(not(target_os = "macos"))]