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