Skip to content

Commit

Permalink
Add a test for fd_count()
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Jan 15, 2023
1 parent 2f96bfb commit 621886c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/process/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,33 @@ fn test_proc_fds() {
}
}

#[test]
fn test_proc_fd_count_runsinglethread() {
let myself = Process::myself().unwrap();

let before = myself.fd_count().unwrap();

let one = File::open("/proc/self").unwrap();
let two = File::open("/proc/self/status").unwrap();

let after = myself.fd_count().unwrap();

assert_eq!(
before + 2,
after,
"opened two files and expected {} open fds, saw {}",
before + 2,
after
);

drop(one);
drop(two);

let after_closing = myself.fd_count().unwrap();

assert_eq!(before, after_closing);
}

#[test]
fn test_proc_fd() {
let myself = Process::myself().unwrap();
Expand Down

0 comments on commit 621886c

Please sign in to comment.