summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Dryer <tomdryer.com@gmail.com>2021-05-28 14:52:34 -0700
committerTom Dryer <tomdryer.com@gmail.com>2021-05-28 15:01:42 -0700
commit81c9e2d9a84ff8c5d147c321d0a48249891bb1ea (patch)
tree948ad8cbc1931dcaa40d8c40672999ff72bf9f4a /test
parentdc07f6150159514b951b3b5231d216c9622eae4c (diff)
downloadnix-81c9e2d9a84ff8c5d147c321d0a48249891bb1ea.zip
Add sendfile64
`sendfile64` is a Linux-specific call with a wider type for the `offset` argument than `sendfile`. This is largely a copy of the existing `sendfile` function and associated test.
Diffstat (limited to 'test')
-rw-r--r--test/test_sendfile.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_sendfile.rs b/test/test_sendfile.rs
index 3bc7932f..ef8031aa 100644
--- a/test/test_sendfile.rs
+++ b/test/test_sendfile.rs
@@ -36,6 +36,28 @@ fn test_sendfile_linux() {
close(wr).unwrap();
}
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[test]
+fn test_sendfile64_linux() {
+ const CONTENTS: &[u8] = b"abcdef123456";
+ let mut tmp = tempfile().unwrap();
+ tmp.write_all(CONTENTS).unwrap();
+
+ let (rd, wr) = pipe().unwrap();
+ let mut offset: libc::off64_t = 5;
+ let res = sendfile64(wr, tmp.as_raw_fd(), Some(&mut offset), 2).unwrap();
+
+ assert_eq!(2, res);
+
+ let mut buf = [0u8; 1024];
+ assert_eq!(2, read(rd, &mut buf).unwrap());
+ assert_eq!(b"f1", &buf[0..2]);
+ assert_eq!(7, offset);
+
+ close(rd).unwrap();
+ close(wr).unwrap();
+}
+
#[cfg(target_os = "freebsd")]
#[test]
fn test_sendfile_freebsd() {