use super::super::{allocate_pids, fill_from_kernel};
#[skuld::test]
fn allocate_pids_surfaces_the_size_check_as_its_own_error() {
let err = allocate_pids(libc::c_int::MAX as usize)
.expect_err("a pid count this large cannot be described in the size argument");
assert!(
err.to_string().contains("int size argument"),
"expected the size-argument refusal, got: {err}"
);
}
#[skuld::test]
fn allocate_pids_returns_a_buffer_of_exactly_the_requested_length() {
let pids = allocate_pids(7).expect("a small allocation succeeds");
assert_eq!(pids.len(), 7, "allocate_pids must resize to exactly cap");
}
#[skuld::test]
fn fill_from_kernel_reports_written_equal_to_the_buffers_own_length() {
let mut buf = [0i32; 2];
let written = fill_from_kernel(&mut buf).expect("a live host always has more than 2 processes");
assert_eq!(
written, 2,
"a 2-pid buffer against a live host must saturate at exactly 2"
);
}