diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-30 16:26:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-30 16:26:41 +0000 |
commit | df9ed9314d61cc0598de60a401800a24f9c68850 (patch) | |
tree | a0e4ba3b0d76096df355f2f4490022d9638f2602 /test | |
parent | 33df3e7cb638eb3c088f0def18a2d649562c4499 (diff) | |
parent | fb5d942c3cf35b842e913a4cd1ec9a5528a38664 (diff) | |
download | nix-df9ed9314d61cc0598de60a401800a24f9c68850.zip |
Merge #1439
1439: Add sendfile64 r=asomers a=tdryer
`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.
Co-authored-by: Tom Dryer <tomdryer.com@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/test_sendfile.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_sendfile.rs b/test/test_sendfile.rs index 3bc7932f..b6559d32 100644 --- a/test/test_sendfile.rs +++ b/test/test_sendfile.rs @@ -36,6 +36,28 @@ fn test_sendfile_linux() { close(wr).unwrap(); } +#[cfg(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() { |