mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
test_infra: Test multiple spawns share one process group
Spawn two processes under the same test name and verify they have the same group PID. Cleanup kills both. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
6453a9a91a
commit
6e8c2bd2b3
@@ -2626,4 +2626,30 @@ mod unit_tests {
|
||||
let _ = child.wait();
|
||||
assert!(!is_alive(pid));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn process_registry_shared_group() {
|
||||
let name = "test_shared_group";
|
||||
|
||||
let mut cmd1 = Command::new("sleep");
|
||||
cmd1.arg("60");
|
||||
let mut child1 = ProcessRegistry::spawn(name, &mut cmd1).unwrap();
|
||||
let pid1 = child1.id();
|
||||
|
||||
let mut cmd2 = Command::new("sleep");
|
||||
cmd2.arg("60");
|
||||
let mut child2 = ProcessRegistry::spawn(name, &mut cmd2).unwrap();
|
||||
let pid2 = child2.id();
|
||||
|
||||
let pgid1 = unsafe { libc::getpgid(pid1 as i32) };
|
||||
let pgid2 = unsafe { libc::getpgid(pid2 as i32) };
|
||||
assert_eq!(pgid1, pgid2);
|
||||
assert_eq!(pgid1, pid1 as i32);
|
||||
|
||||
assert!(ProcessRegistry::cleanup(name));
|
||||
let _ = child1.wait();
|
||||
let _ = child2.wait();
|
||||
assert!(!is_alive(pid1));
|
||||
assert!(!is_alive(pid2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user