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