mirror of
https://github.com/uutils/procps.git
synced 2026-06-10 16:14:00 -07:00
pidof: Add test for no name and no pid found case.
This commit is contained in:
@@ -25,6 +25,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
};
|
||||
|
||||
let mut collected = collect_matched_pids(&matches);
|
||||
|
||||
if collected.is_empty() {
|
||||
uucore::error::set_exit_code(1);
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
collected.sort_by(|a, b| b.pid.cmp(&a.pid));
|
||||
|
||||
let output = collected
|
||||
|
||||
@@ -21,3 +21,15 @@ fn test_find_init() {
|
||||
fn test_find_kthreadd() {
|
||||
new_ucmd!().arg("kthreadd").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_no_program() {
|
||||
new_ucmd!().fails().code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_no_pid_found() {
|
||||
new_ucmd!().arg("NO_THIS_PROGRAM").fails().code_is(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user