Skip to content

Commit

Permalink
add changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Oct 22, 2024
1 parent b7e2dc1 commit dc3b011
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/2525.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `close_range` in unistd for Linux/glibc and FreeBSD
15 changes: 12 additions & 3 deletions test/test_unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,10 @@ fn test_group_from() {
}

#[test]
#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "freebsd"))]
#[cfg(any(
all(target_os = "linux", target_env = "gnu"),
target_os = "freebsd"
))]
fn test_close_range() {
use tempfile::NamedTempFile;
const CONTENTS: &[u8] = b"abcdef123456";
Expand All @@ -1403,6 +1406,12 @@ fn test_close_range() {
tempfile3.write_all(CONTENTS).unwrap();
tempfile2.write_all(CONTENTS).unwrap();
tempfile1.write_all(CONTENTS).unwrap();
let areclosed = close_range(tempfile1, tempfile3, CloseRangeFlags::CLOSE_RANGE_CLOEXEC);
assert_eq!(areclosed.expect("close_range failed").expect("invalid flag"), 0);
let areclosed =
close_range(tempfile1, tempfile3, CloseRangeFlags::CLOSE_RANGE_CLOEXEC);
assert_eq!(
areclosed
.expect("close_range failed")
.expect("invalid flag"),
0
);
}

0 comments on commit dc3b011

Please sign in to comment.