mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
Add test asserting stdlib uses O_CLOEXEC
This commit is contained in:
parent
d5cde80447
commit
4e95a3713e
2 changed files with 17 additions and 0 deletions
|
@ -18,6 +18,7 @@ mod parser;
|
|||
mod reader;
|
||||
mod redirection;
|
||||
mod screen;
|
||||
mod std;
|
||||
mod string_escape;
|
||||
mod threads;
|
||||
mod tokenizer;
|
||||
|
|
16
src/tests/std.rs
Normal file
16
src/tests/std.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
//! This module contains tests that assert the functionality and behavior of the rust standard
|
||||
//! library, to ensure we can safely use its abstractions to perform low-level operations.
|
||||
|
||||
use std::fs::File;
|
||||
use std::os::fd::AsRawFd;
|
||||
|
||||
#[test]
|
||||
fn test_fd_cloexec() {
|
||||
// Just open a file. Any file.
|
||||
let file = File::create("test_file_for_fd_cloexec").unwrap();
|
||||
let fd = file.as_raw_fd();
|
||||
unsafe {
|
||||
assert_eq!(libc::fcntl(fd, libc::F_GETFD) & libc::FD_CLOEXEC, libc::FD_CLOEXEC);
|
||||
}
|
||||
let _ = std::fs::remove_file("test_file_for_fd_cloexec");
|
||||
}
|
Loading…
Reference in a new issue