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