Tests: find agents with pgrep, since macOS has no /proc
This commit is contained in:
+6
-14
@@ -453,20 +453,12 @@ fn agent_rust_client_go_agent() {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn agent_pids(sock_dir: &Path) -> Vec<u32> {
|
fn agent_pids(sock_dir: &Path) -> Vec<u32> {
|
||||||
let mut pids = Vec::new();
|
// pgrep, not /proc: macOS has no /proc.
|
||||||
for e in std::fs::read_dir("/proc").into_iter().flatten().flatten() {
|
let o = Command::new("pgrep")
|
||||||
let Ok(pid) = e.file_name().to_string_lossy().parse::<u32>() else {
|
.args(["-f", &format!("__agent {}", sock_dir.display())])
|
||||||
continue;
|
.output()
|
||||||
};
|
.unwrap();
|
||||||
let Ok(cmd) = std::fs::read(e.path().join("cmdline")) else {
|
String::from_utf8_lossy(&o.stdout).lines().filter_map(|l| l.parse().ok()).collect()
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let cmd = String::from_utf8_lossy(&cmd);
|
|
||||||
if cmd.contains("__agent") && cmd.contains(&*sock_dir.to_string_lossy()) {
|
|
||||||
pids.push(pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pids
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
Reference in New Issue
Block a user