mirror of
https://github.com/uutils/procps.git
synced 2026-06-10 16:14:00 -07:00
Merge branch 'main' into fix/issue-389-vmstat-cache-info
This commit is contained in:
@@ -151,8 +151,20 @@ pub fn get_match_settings(matches: &ArgMatches) -> UResult<Settings> {
|
||||
pub fn find_matching_pids(settings: &Settings) -> UResult<Vec<ProcessInformation>> {
|
||||
let mut pids = collect_matched_pids(settings)?;
|
||||
|
||||
let is_long_match = if settings.exact {
|
||||
settings
|
||||
.regex
|
||||
.as_str()
|
||||
.trim_matches('^')
|
||||
.trim_matches('$')
|
||||
.len()
|
||||
> 15
|
||||
} else {
|
||||
settings.regex.as_str().len() > 15
|
||||
};
|
||||
|
||||
if pids.is_empty() {
|
||||
if !settings.full && settings.regex.as_str().len() > 15 {
|
||||
if !settings.full && is_long_match {
|
||||
let msg = format!("pattern that searches for process name longer than 15 characters will result in zero matches\n\
|
||||
Try `{} -f' option to match against the complete command line.", uucore::util_name());
|
||||
return Err(USimpleError::new(1, msg));
|
||||
|
||||
@@ -654,7 +654,6 @@ fn test_pidfile_fcntl_locked() {
|
||||
|
||||
// spawn a flock process that locks the file
|
||||
let mut flock_process = Command::new("flock")
|
||||
.arg("--fcntl")
|
||||
.arg(temp_file.path())
|
||||
.arg("sleep")
|
||||
.arg("2")
|
||||
@@ -718,3 +717,31 @@ fn test_env_multiple_filters() {
|
||||
// Multiple filters use OR logic
|
||||
new_ucmd!().arg("--env=PATH,NONEXISTENT").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_exact_long_pattern_no_match() {
|
||||
new_ucmd!()
|
||||
.arg("-x")
|
||||
.arg("12345678901234")
|
||||
.fails()
|
||||
.code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pattern_longer_than_15_characters() {
|
||||
new_ucmd!()
|
||||
.arg("1234567890123456")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains("longer than 15 characters");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_pool_workqueue_release() {
|
||||
new_ucmd!()
|
||||
.arg("pool_workqueue_release")
|
||||
.succeeds()
|
||||
.stdout_matches(&Regex::new(MULTIPLE_PIDS).unwrap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user