Skip to content

Commit

Permalink
Merge pull request #1213 from GuillaumeGomez/process-run_time-test
Browse files Browse the repository at this point in the history
Add test for `process::run_time`
  • Loading branch information
GuillaumeGomez authored Mar 1, 2024
2 parents fbb9dbf + 0e4a879 commit b04d3bc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,3 +774,23 @@ fn test_refresh_pids() {
assert!(pids.contains(pid));
}
}

#[test]
fn test_process_run_time() {
if !sysinfo::IS_SUPPORTED_SYSTEM || cfg!(feature = "apple-sandbox") {
return;
}
let mut s = System::new();
let current_pid = sysinfo::get_current_pid().expect("failed to get current pid");
s.refresh_process(current_pid);
let run_time = s.process(current_pid).expect("no process found").run_time();
std::thread::sleep(std::time::Duration::from_millis(1500));
s.refresh_process(current_pid);
let new_run_time = s.process(current_pid).expect("no process found").run_time();
assert!(
new_run_time > run_time,
"{} not superior to {}",
new_run_time,
run_time
);
}

0 comments on commit b04d3bc

Please sign in to comment.