Skip to content

Commit 4e42e77

Browse files
committed
Add test for posix_fadvise
1 parent 01b5e82 commit 4e42e77

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/run-pass/fs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// ignore-windows: File handling is not implemented yet
22
// compile-flags: -Zmiri-disable-isolation
33

4+
#![feature(rustc_private)]
5+
6+
extern crate libc;
7+
48
use std::fs::{File, remove_file};
59
use std::io::{Read, Write, ErrorKind, Result};
10+
use std::os::unix::io::AsRawFd;
611
use std::path::{PathBuf, Path};
712

813
fn test_metadata(bytes: &[u8], path: &Path) -> Result<()> {
@@ -40,6 +45,16 @@ fn main() {
4045
file.read_to_end(&mut contents).unwrap();
4146
assert_eq!(bytes, contents.as_slice());
4247

48+
// Test calling posix_fadvise on the file.
49+
unsafe {
50+
libc::posix_fadvise(
51+
file.as_raw_fd(),
52+
0,
53+
bytes.len() as i64,
54+
libc::POSIX_FADV_DONTNEED,
55+
);
56+
}
57+
4358
// Test that metadata of an absolute path is correct.
4459
test_metadata(bytes, &path).unwrap();
4560
// Test that metadata of a relative path is correct.

0 commit comments

Comments
 (0)