summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/test_fcntl.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs
index 43bfc091..d171b91d 100644
--- a/test/test_fcntl.rs
+++ b/test/test_fcntl.rs
@@ -54,11 +54,11 @@ mod linux_android {
use libc::loff_t;
- use nix::fcntl::{SpliceFFlags, splice, tee, vmsplice};
+ use nix::fcntl::{SpliceFFlags, FallocateFlags, fallocate, splice, tee, vmsplice};
use nix::sys::uio::IoVec;
use nix::unistd::{close, pipe, read, write};
- use tempfile::tempfile;
+ use tempfile::{tempfile, NamedTempFile};
#[test]
fn test_splice() {
@@ -131,4 +131,15 @@ mod linux_android {
close(wr).unwrap();
}
+ #[test]
+ fn test_fallocate() {
+ let tmp = NamedTempFile::new().unwrap();
+
+ let fd = tmp.as_raw_fd();
+ fallocate(fd, FallocateFlags::empty(), 0, 100).unwrap();
+
+ // Check if we read exactly 100 bytes
+ let mut buf = [0u8; 200];
+ assert_eq!(100, read(fd, &mut buf).unwrap());
+ }
}