tests: Fix missing wait() on spawned support commands

Compiling cloud-hypervisor v41.0.0 (/home/rob/src/cloud-hypervisor)
warning: spawned process is never `wait()`ed on
    --> tests/integration.rs:4250:31
     |
4250 |         let mut socat_child = socat_command.spawn().unwrap();
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: consider calling `.wait()`
     = note: not doing so might leave behind zombie processes
     = note: see https://doc.rust-lang.org/stable/std/process/struct.Child.html#warning
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zombie_processes
     = note: `#[warn(clippy::zombie_processes)]` on by default

warning: spawned process is never `wait()`ed on
    --> tests/integration.rs:6687:9
     |
6687 | /         Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt")
6688 | |             .args(["-i", "0", "-m", "0x1"])
6689 | |             .spawn()
6690 | |             .unwrap();
     | |                     ^- help: try: `.wait()`
     | |_____________________|
     |
     |
     = note: not doing so might leave behind zombie processes
     = note: see https://doc.rust-lang.org/stable/std/process/struct.Child.html#warning
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zombie_processes

warning: `cloud-hypervisor` (test "integration") generated 2 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.83s

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2024-10-21 12:23:15 +01:00
parent 36b59a6d2b
commit 107bfe1075

View File

@ -4255,6 +4255,7 @@ mod common_parallel {
});
let _ = socat_child.kill();
let _ = socat_child.wait();
let r = std::panic::catch_unwind(|| {
guest.ssh_command("sudo shutdown -h now").unwrap();
@ -6664,7 +6665,7 @@ mod common_parallel {
handle_child_output(r, &output);
}
fn setup_spdk_nvme(nvme_dir: &std::path::Path) {
fn setup_spdk_nvme(nvme_dir: &std::path::Path) -> Child {
cleanup_spdk_nvme();
assert!(exec_host_command_status(&format!(
@ -6684,7 +6685,7 @@ mod common_parallel {
.success());
// Start the SPDK nvmf_tgt daemon to present NVMe device as a VFIO user device
Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt")
let child = Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt")
.args(["-i", "0", "-m", "0x1"])
.spawn()
.unwrap();
@ -6713,6 +6714,8 @@ mod common_parallel {
nvme_dir.join("nvme-vfio-user").to_str().unwrap()
))
.success());
child
}
fn cleanup_spdk_nvme() {
@ -6726,7 +6729,7 @@ mod common_parallel {
let guest = Guest::new(Box::new(jammy));
let spdk_nvme_dir = guest.tmp_dir.as_path().join("test-vfio-user");
setup_spdk_nvme(spdk_nvme_dir.as_path());
let mut spdk_child = setup_spdk_nvme(spdk_nvme_dir.as_path());
let api_socket = temp_api_path(&guest.tmp_dir);
let mut child = GuestCommand::new(&guest)
@ -6797,7 +6800,8 @@ mod common_parallel {
);
});
cleanup_spdk_nvme();
let _ = spdk_child.kill();
let _ = spdk_child.wait();
kill_child(&mut child);
let output = child.wait_with_output().unwrap();